diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java index 7f650a3a6..2e899ad53 100644 --- a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java @@ -104,9 +104,19 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap return tokenStore; } + /** + * token增强,客户端模式不增强。 + * + * @return TokenEnhancer + */ @Bean public TokenEnhancer tokenEnhancer() { return (accessToken, authentication) -> { + if (SecurityConstants.CLIENT_CREDENTIALS + .equals(authentication.getOAuth2Request().getGrantType())) { + return accessToken; + } + final Map additionalInfo = new HashMap<>(8); PigxUser pigxUser = (PigxUser) authentication.getUserAuthentication().getPrincipal(); additionalInfo.put("user_id", pigxUser.getId()); diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java index 22935a874..b1ad0b556 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java @@ -120,4 +120,9 @@ public interface SecurityConstants { */ String RESOURCE_SERVER_CONFIGURER = "resourceServerConfigurerAdapter"; + /** + * 客户端模式 + */ + String CLIENT_CREDENTIALS = "client_credentials"; + }