如何在Spring Boot中与JWT身份验证一起实现oAuth2? [英] How to implement oAuth2 along with JWT authentication in spring boot?

查看:336
本文介绍了如何在Spring Boot中与JWT身份验证一起实现oAuth2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jhipster和mongodb作为主要数据库来创建Spring Boot Web应用程序.需要将Oauth2与JWT令牌机制一起实现身份验证,以便每个请求都不会到达数据库进行身份验证.如何实现这种机制?

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?

推荐答案

MongoDB(或任何数据库)与JWT身份验证没有特别关系,因为资源服务器可以使用授权的公钥在本地验证JWT本身.服务器,而无需转到数据库(如您所说).

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).

密钥正在使用JwtTokenStore

The key is using a JwtTokenStore

我发现此github示例很有帮助: https://github.com /dsyer/spring-security-angular/tree/master/oauth2

I found this github sample helpful: https://github.com/dsyer/spring-security-angular/tree/master/oauth2

我还用jhipster创建了一个基本的jwt实现,供您查看.以下是jhipster为我生成的内容的更改: https://github.com/sdoxsee/jwt-jhipster/commit/40090fcf4fab1b556ae28532c4ba8a33e70460c9

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

这篇关于如何在Spring Boot中与JWT身份验证一起实现oAuth2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆