Default principalClaimName to SUB

Closes gh-10214
This commit is contained in:
/usr/local/ΕΨΗΕΛΩΝ 2021-08-20 16:09:33 +02:00 committed by Josh Cummings
parent 9b4ddd7e0a
commit 4302a86fad
No known key found for this signature in database
GPG Key ID: 49EF60DD7FF83443

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,14 +36,12 @@ public class JwtAuthenticationConverter implements Converter<Jwt, AbstractAuthen
private Converter<Jwt, Collection<GrantedAuthority>> jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
private String principalClaimName;
private String principalClaimName = JwtClaimNames.SUB;
@Override
public final AbstractAuthenticationToken convert(Jwt jwt) {
Collection<GrantedAuthority> authorities = extractAuthorities(jwt);
if (this.principalClaimName == null) {
return new JwtAuthenticationToken(jwt, authorities);
}
String principalClaimValue = jwt.getClaimAsString(this.principalClaimName);
return new JwtAuthenticationToken(jwt, authorities, principalClaimValue);
}