REST/JAVA+ANGULAR2 authentication

Asked

Viewed 150 times

0

I have a java Rest api and need to perform an authentication (login/password). I’m basing myself on this java code that uses Jwt: http://www.totalcross.com/blog/seguranca-com-jwt-e-java/

My question is: how to treat this token at the angle and authenticate the user? Every source of study is welcome. From now on, thank you..

  • https://blog.angular-university.io/angular-jwt-authentication/

  • @merchant Thank you for the reply. I will try to delve deeper into the material, my own doubts are being on how the angular treats this token that is returned..

1 answer

0

I often trigger a service in my backend that receives a user and password. This service validates and returns a JWT token.

At the angle, I use the Provider $localStorage to store it. For each request that will be made to my API, I search the token stored in the login and include it in the HEADERS of the request to validate it in the backend.

If you want to use the token at the angle for any kind of purpose, you can use the angular-jwt to decode it with the jwtHelper.decodeToken(token) function; and/or validate through the jwtHelper.isTokenExpired(token) function)

Ah, to use this angular-jwt you need to add it to your app’s module ('angular-jwt').

Browser other questions tagged

You are not signed in. Login or sign up in order to post.