I am creating a spring boot web app using jhipster and mongodb as primary database. Need to implement Oauth2 for authentication along with JWT token mechanism so that every request does not hit the database for authentication. How can I implement this mechanism?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
MongoDB (or any database) is not particularly relevant to the JWT authentication since the JWT itself can be validated locally by the resource server using the public key of the authorization server without going to the database (as you say).
The key is using a JwtTokenStore
I found this github sample helpful: https://github.com/dsyer/spring-security-angular/tree/master/oauth2
I also created a basic jwt implementation with jhipster for you to look at. Here are the changes from what jhipster generated for me: https://github.com/sdoxsee/jwt-jhipster/commit/40090fcf4fab1b556ae28532c4ba8a33e70460c9