File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
src/main/java/com/example/spring/authorizationserver/config Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 3
3
import com .example .spring .authorizationserver .security .OidcUserInfoService ;
4
4
import org .springframework .context .annotation .Bean ;
5
5
import org .springframework .context .annotation .Configuration ;
6
+ import org .springframework .security .oauth2 .core .AuthorizationGrantType ;
6
7
import org .springframework .security .oauth2 .core .oidc .OidcUserInfo ;
7
8
import org .springframework .security .oauth2 .server .authorization .token .JwtEncodingContext ;
8
9
import org .springframework .security .oauth2 .server .authorization .token .OAuth2TokenCustomizer ;
@@ -15,11 +16,13 @@ public class JwtTokenCustomizerConfig {
15
16
@ Bean
16
17
public OAuth2TokenCustomizer <JwtEncodingContext > tokenCustomizer (OidcUserInfoService userInfoService ) {
17
18
return (context ) -> {
18
- if (ID_TOKEN .equals (context .getTokenType ().getValue ()) || ACCESS_TOKEN .equals (context .getTokenType ())) {
19
- OidcUserInfo userInfo = userInfoService .loadUser (
20
- context .getPrincipal ().getName ());
21
- context .getClaims ().claims (claims ->
22
- claims .putAll (userInfo .getClaims ()));
19
+ if (!AuthorizationGrantType .CLIENT_CREDENTIALS .equals (context .getAuthorizationGrantType ())) {
20
+ if (ID_TOKEN .equals (context .getTokenType ().getValue ()) || ACCESS_TOKEN .equals (context .getTokenType ())) {
21
+ OidcUserInfo userInfo = userInfoService .loadUser (
22
+ context .getPrincipal ().getName ());
23
+ context .getClaims ().claims (claims ->
24
+ claims .putAll (userInfo .getClaims ()));
25
+ }
23
26
}
24
27
};
25
28
}
You can’t perform that action at this time.
0 commit comments