春季启动,使用MariaDB和JWT OAuth2进行身份验证的流程

时间:2018-10-16 12:43:26

标签: spring jdbc oauth-2.0 jwt mariadb

我想基于JWT创建身份验证。 用户凭据位于Mariadb数据库中,我使用jdbc驱动程序进行数据库访问。我想使用这样的密码grandType发出OAuth2请求

POST /oauth/token HTTP/1.1
Host: authorization-server.com
Content-type: application/x-www-form-urlencoded

grant_type=password
&username=exampleuser
&password=1234luggage
&client_id=xxxxxxxxxx

src:https://developer.okta.com/blog/2018/06/29/what-is-the-oauth2-password-grant

使用access_token和refresh_token进行响应。

我使用了类似的配置 https://github.com/nydiarra/springboot-jwt/tree/master/src/main/java/com/nouhoun/springboot/jwt/integration/config

我不太了解系统如何工作来获取和比较存储在数据库中的用户凭据。 我真的需要使用OAuth2服务器的特定数据库架构吗?像这样https://www.baeldung.com/rest-api-spring-oauth2-angularjs 我已经有一个数据库,可以指定验证发送的用户凭据数据的逻辑吗?

阅读本教程。

1 个答案:

答案 0 :(得分:0)

您可以通过覆盖userdetailsservice来定制从数据库中获取用户数据的方式。 该bean从数据库中获取用户。 有关更多详细信息,请参阅本文:https://www.baeldung.com/spring-security-authentication-with-a-database