✨ 添加新特性,支持客户端模式令牌方法
This commit is contained in:
1 parent
6496de2b54
commit
02fa2dcd73
2 files changed
+15
No files matched your search
@@ -104,9 +104,19 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
|||||||
return tokenStore;
|
return tokenStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token增强,客户端模式不增强。
|
||||||
|
*
|
||||||
|
* @return TokenEnhancer
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public TokenEnhancer tokenEnhancer() {
|
public TokenEnhancer tokenEnhancer() {
|
||||||
return (accessToken, authentication) -> {
|
return (accessToken, authentication) -> {
|
||||||
|
if (SecurityConstants.CLIENT_CREDENTIALS
|
||||||
|
.equals(authentication.getOAuth2Request().getGrantType())) {
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
final Map<String, Object> additionalInfo = new HashMap<>(8);
|
final Map<String, Object> additionalInfo = new HashMap<>(8);
|
||||||
PigxUser pigxUser = (PigxUser) authentication.getUserAuthentication().getPrincipal();
|
PigxUser pigxUser = (PigxUser) authentication.getUserAuthentication().getPrincipal();
|
||||||
additionalInfo.put("user_id", pigxUser.getId());
|
additionalInfo.put("user_id", pigxUser.getId());
|
||||||
|
|||||||
+5
@@ -120,4 +120,9 @@ public interface SecurityConstants {
|
|||||||
*/
|
*/
|
||||||
String RESOURCE_SERVER_CONFIGURER = "resourceServerConfigurerAdapter";
|
String RESOURCE_SERVER_CONFIGURER = "resourceServerConfigurerAdapter";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端模式
|
||||||
|
*/
|
||||||
|
String CLIENT_CREDENTIALS = "client_credentials";
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user