-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.comin: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
Description
Summary
user-name-attribute not reflected in SecurityContextHolder. This is the follow up on https://stackoverflow.com/questions/59410641/spring-oauth2-resource-server-user-name-attribute-not-reflected-in-securitycon
Actual Behavior
JwtAuthenticationConverter has
@Override
public final AbstractAuthenticationToken convert(Jwt jwt) {
Collection<GrantedAuthority> authorities = extractAuthorities(jwt);
return new JwtAuthenticationToken(jwt, authorities);
}
where:
public JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities) {
super(jwt, authorities);
this.setAuthenticated(true);
**this.name = jwt.getSubject();**
}
Expected Behavior
JwtAuthenticationConverter convert method if there is userNameAttribute set should return new JwtAuthenticationToken(jwt, authorities, userNameAttribute)
where
public JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities, String name) {
super(jwt, authorities);
this.setAuthenticated(true);
**this.name = name;**
}
Version
spring-security-oauth2-resource-server-5.2.1.RELEASE (Spring Boot 2.2.2.RELEASE)
rigon
Metadata
Metadata
Assignees
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.comin: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)