🐛 Fixing a bug. #I8AOYB 客户端模式,请求接口提示错误

This commit is contained in:
lbw 2023-10-25 10:41:25 +08:00
parent 7fc753d85a
commit 99c7edf03e

View File

@ -12,6 +12,7 @@ import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.DefaultOAuth2AuthenticatedPrincipal;
import org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal;
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
@ -44,8 +45,8 @@ public class PigCustomOpaqueTokenIntrospector implements OpaqueTokenIntrospector
// 客户端模式默认返回
if (AuthorizationGrantType.CLIENT_CREDENTIALS.equals(oldAuthorization.getAuthorizationGrantType())) {
return new PigClientCredentialsOAuth2AuthenticatedPrincipal(oldAuthorization.getAttributes(),
AuthorityUtils.NO_AUTHORITIES, oldAuthorization.getPrincipalName());
return new DefaultOAuth2AuthenticatedPrincipal(oldAuthorization.getPrincipalName(),
Objects.requireNonNull(oldAuthorization.getAccessToken().getClaims()), AuthorityUtils.NO_AUTHORITIES);
}
Map<String, PigUserDetailsService> userDetailsServiceMap = SpringUtil