处理oauth2客户端无法登录的问题

This commit is contained in:
wanggeng 2022-08-26 18:51:08 +08:00
parent 277cfb2e11
commit dcb038f331
5 changed files with 6 additions and 2 deletions

View File

@ -55,6 +55,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
baseProperties.getLoginFailure(), baseProperties.getLoginFailure(),
"/oauth/**", "/oauth/**",
"/oauth2_client/**", "/oauth2_client/**",
"/error"
}; };
LoginFailureHandler loginFailureHandler = new LoginFailureHandler(baseProperties.getLoginFailure()); LoginFailureHandler loginFailureHandler = new LoginFailureHandler(baseProperties.getLoginFailure());
http http

View File

@ -19,6 +19,8 @@ import java.util.Map;
**/ **/
public interface IOAuth2ClientService { public interface IOAuth2ClientService {
String BCRYPT_PREFIX = "{bcrypt}";
/** /**
* 客户端加密规则 * 客户端加密规则
*/ */

View File

@ -72,7 +72,7 @@ public class OAuth2ClientDetailsServiceImpl implements ClientDetailsService {
oAuth2ClientPO.getAuthorizedGrantTypes(), oAuth2ClientPO.getAuthorizedGrantTypes(),
oAuth2ClientPO.getAuthorities()); oAuth2ClientPO.getAuthorities());
clientDetails.setAutoApproveScopes(Arrays.asList(oAuth2ClientPO.getAutoapprove().split(","))); clientDetails.setAutoApproveScopes(Arrays.asList(oAuth2ClientPO.getAutoapprove().split(",")));
clientDetails.setClientSecret(oAuth2ClientPO.getClientSecret()); clientDetails.setClientSecret(oAuth2ClientPO.getClientSecret().replace(IOAuth2ClientService.BCRYPT_PREFIX, ""));
clientDetails.setAccessTokenValiditySeconds(oAuth2ClientPO.getAccessTokenValidity()); clientDetails.setAccessTokenValiditySeconds(oAuth2ClientPO.getAccessTokenValidity());
clientDetails.setRefreshTokenValiditySeconds(oAuth2ClientPO.getRefreshTokenValidity()); clientDetails.setRefreshTokenValiditySeconds(oAuth2ClientPO.getRefreshTokenValidity());
// 设置附加信息json格式 // 设置附加信息json格式

View File

@ -48,7 +48,7 @@ public class OAuth2ClientServiceImpl extends DefaultBaseService implements IOAut
@Override @Override
public void save(OAuth2ClientVO oauth2ClientVO) throws SaveException { public void save(OAuth2ClientVO oauth2ClientVO) throws SaveException {
oauth2ClientVO.setClientSecret("{bcrypt}" + passwordEncoder.encode(oauth2ClientVO.getClientSecret())); oauth2ClientVO.setClientSecret(BCRYPT_PREFIX + passwordEncoder.encode(oauth2ClientVO.getClientSecret()));
Map<String, Object> params = HashMapUtil.beanToMap(oauth2ClientVO); Map<String, Object> params = HashMapUtil.beanToMap(oauth2ClientVO);
setSaveInfo(params); setSaveInfo(params);
oauth2ClientDao.save(params); oauth2ClientDao.save(params);

View File

@ -54,6 +54,7 @@
<module>module-wechat-pay</module> <module>module-wechat-pay</module>
<module>module-attn</module> <module>module-attn</module>
<module>service-core</module> <module>service-core</module>
<module>docs</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>