如何解决如何在 OAuth2 spring boot 中使用 mytable 更改 jdbc 模式用户
我必须使用 mytable 名称更改默认架构用户的名称。
解决方法
要使用您自己的表,您必须使用 authenticationmanager 从该表中读取用户,如下所示。它应该能够提供用户和权限的详细信息。 您可以创建自己的配置类,它扩展 WebSecurityConfigurerAdapter 并覆盖如下所示的配置方法。
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication()
.dataSource(dataSource)
.usersByUsernameQuery("select userid,password,enabled "
+ "from yourtable"
+ "where userid = ?")
.authoritiesByUsernameQuery("select userid,authority "
+ "from yourauthoritytable"
+ "where userid= ?");
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。