Skip to content

Commit

Permalink
Default principalClaimName to SUB
Browse files Browse the repository at this point in the history
  • Loading branch information
djechelon authored and Ayush Kohli committed Aug 25, 2021
1 parent 56e50f3 commit fc6057a
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit fc6057a

Please sign in to comment.