简体   繁体   中英

AngularJS with spring security - general flow of authentication

Can anyone how look general flow of authentication in spring security, where frontend (so also login panel) is provieded by angularJS and node server ?
How should be these modules connected ?

I have been involved in three angularjs apps and in each of them we handled the whole user authentication/authorization in following way:

we defined a currentUser service which holds the information of current user of our application, things like user roles, email, name and ..., and this service have a very important method named isLoggedIn which based on this service values determine if user is logged in or not.

on the server side we have some sort of api which returns a token to a user after user have provided valid credentials, we post username/pass to the api and in response we receive a token and store it in a cookie or local sotrage. there are various ways of returning a token on would be using JWT(Json Web Token).

Tokens are sent in each request by help of $http interceptors , token may expire after 30 minutes which result in an unauthorized response from server.

for JWT refer to this link. for client side authentication/authorization you can take a look at ng-book or this link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM