TokenService.java and JWTTokenService.java Login does the reverse: It takes a user name, grabs the user with userService, verifies that the password matches, then uses tokenService to create the token. If the token is good, findByToken uses UserService to get the actual user object. findByToken takes a token, then uses tokenService to verify its validity. The protected API and login calls (index.html) let token = null async function protectedAPI()īoth methods - findByToken and login - rely on TokenService and UserService. You can see the JS for handling these interactions in Listing 1. It also provides a simple log-in capability. This simple index.html file allows the user to click a button and see the message returned from the protected endpoint. This will give you a sense of how a JavaScript front end interacts with the server security. That is where the client lives in the form of a small index.html file. Spring Web will by default serve files in the resources/static folder. The front end with simple log-in capability There is also an index.html file serving the simple front end from /resources/static. To keep things as simple as possible and make it easier to get your mind around things, I’ve spurned Java best practice and put all of the classes you will use in a single package. In this case, a simple collection of users.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |