Oauth 2.0 如何使用SpringRESTAPI和oauth安全性对数据库中的用户进行身份验证

Oauth 2.0 如何使用SpringRESTAPI和oauth安全性对数据库中的用户进行身份验证,oauth-2.0,spring-jdbc,spring-restcontroller,Oauth 2.0,Spring Jdbc,Spring Restcontroller,我想使用oauth2实现RESTAPI安全性,我已经通过以下方式使用静态用户数据实现了这种安全性。现在,我想将这种情况更改为使用jdbc对数据库中的数据进行身份验证,但到目前为止,我还没有找到任何关于jdbc身份验证的教程。请给我推荐一些我的需求示例,我的需求是Spring mvc Rest api+OAuth2+jdbc数据库+java配置示例 目前,我已经对静态用户进行了测试,如下所示 public void globalUserDetails(AuthenticationManagerBu

我想使用oauth2实现RESTAPI安全性,我已经通过以下方式使用静态用户数据实现了这种安全性。现在,我想将这种情况更改为使用jdbc对数据库中的数据进行身份验证,但到目前为止,我还没有找到任何关于jdbc身份验证的教程。请给我推荐一些我的需求示例,我的需求是Spring mvc Rest api+OAuth2+jdbc数据库+java配置示例

目前,我已经对静态用户进行了测试,如下所示

public void globalUserDetails(AuthenticationManagerBuilder auth) throws 
 Exception {
    auth.inMemoryAuthentication()
    .withUser("crmadmin").password("crmpass").roles("ADMIN","USER").and()
    .withUser("crmuser").password("pass123").roles("USER");
}

我认为您可以按如下方式进行配置: 将下面的代码放入扩展WebSecurityConfigureAdapter的类中

@Autowired
private DataSource securityDataSource; // from Bean where you have connection, jdbc driver set up for database containing login information
@凌驾

protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.jdbcAuthentication().dataSource(securityDataSource);
}