Explorar o código

Default principalClaimName to SUB

Closes gh-10214
/usr/local/ΕΨΗΕΛΩΝ %!s(int64=4) %!d(string=hai) anos
pai
achega
4302a86fad

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

@@ -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");
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with 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 Converter<Jwt, Collection<GrantedAuthority>> jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
 
 
-	private String principalClaimName;
+	private String principalClaimName = JwtClaimNames.SUB;
 
 
 	@Override
 	@Override
 	public final AbstractAuthenticationToken convert(Jwt jwt) {
 	public final AbstractAuthenticationToken convert(Jwt jwt) {
 		Collection<GrantedAuthority> authorities = extractAuthorities(jwt);
 		Collection<GrantedAuthority> authorities = extractAuthorities(jwt);
-		if (this.principalClaimName == null) {
-			return new JwtAuthenticationToken(jwt, authorities);
-		}
+
 		String principalClaimValue = jwt.getClaimAsString(this.principalClaimName);
 		String principalClaimValue = jwt.getClaimAsString(this.principalClaimName);
 		return new JwtAuthenticationToken(jwt, authorities, principalClaimValue);
 		return new JwtAuthenticationToken(jwt, authorities, principalClaimValue);
 	}
 	}