Skip to content

Commit 4302a86

Browse files
djechelonjzheaux
authored andcommitted
Default principalClaimName to SUB
Closes gh-10214
1 parent 9b4ddd7 commit 4302a86

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtAuthenticationConverter.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,14 +36,12 @@ public class JwtAuthenticationConverter implements Converter<Jwt, AbstractAuthen
3636

3737
private Converter<Jwt, Collection<GrantedAuthority>> jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
3838

39-
private String principalClaimName;
39+
private String principalClaimName = JwtClaimNames.SUB;
4040

4141
@Override
4242
public final AbstractAuthenticationToken convert(Jwt jwt) {
4343
Collection<GrantedAuthority> authorities = extractAuthorities(jwt);
44-
if (this.principalClaimName == null) {
45-
return new JwtAuthenticationToken(jwt, authorities);
46-
}
44+
4745
String principalClaimValue = jwt.getClaimAsString(this.principalClaimName);
4846
return new JwtAuthenticationToken(jwt, authorities, principalClaimValue);
4947
}

0 commit comments

Comments
 (0)