上一篇:【SpringBoot攻略十三、spring security oauth2服务端(password密码模式)】
基于上一篇做如下修改就OK了!
1、OAuth2AuthorizationServerConfig授权服务器
删除
// password模式需要authenticationManager
//endpoints.authenticationManager(authenticationManager)
添加
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
2、OAuth2ResourceServerConfig资源服务器
.antMatchers("/order/**").authenticated()
替换
.antMatchers("/order/**").hasRole("USER")
因为此时没有用户了
3、删除WebSecurityConfig
4、数据库添加一个grant_type等于client_credentials的用户
5、测试时可以按照上一篇的步骤


注意:client_credentials客户端模式没有refresh_token更新令牌!!!
本文详细介绍如何在SpringBoot项目中配置OAuth2客户端模式,包括修改授权服务器和资源服务器配置,数据库用户设置,以及注意事项。文章强调客户端模式下无refresh_token更新令牌的特点。
2800

被折叠的 条评论
为什么被折叠?



