|
@@ -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);
|
|
}
|
|
}
|