Skip to content

Commit

Permalink
fix: add attribute in oauth authority
Browse files Browse the repository at this point in the history
  • Loading branch information
goathoon committed Oct 26, 2023
1 parent 57514a3 commit 9a0a195
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CustomUserDetails implements UserDetails, OAuth2User, Serializable
public CustomUserDetails(String id, String roles, Map<String, Object> attributes) {
//PrincipalOauth2UserService 참고
this.id = id;
this.authorities = createAuthoritiesOfSocial(roles);
this.authorities = createAuthoritiesOfSocial(roles,attributes);
this.attributes = attributes;
}

Expand All @@ -57,12 +57,12 @@ private Collection<GrantedAuthority> createAuthoritiesOfNonSocial(String roles){
}
return authorities;
}
private Collection<GrantedAuthority> createAuthoritiesOfSocial(String roles){
private Collection<GrantedAuthority> createAuthoritiesOfSocial(String roles,Map<String, Object> attributes){
Collection<GrantedAuthority> authorities = new ArrayList<>();

for(String role : roles.split(",")){
if (!StringUtils.hasText(role)) continue;
authorities.add(new OAuth2UserAuthority(role,this.attributes));
authorities.add(new OAuth2UserAuthority(role,attributes));
}
return authorities;
}
Expand Down

0 comments on commit 9a0a195

Please sign in to comment.