Skip to content

Commit

Permalink
[Fix partially kbss-cvut/23ava-distribution#23] If security provider …
Browse files Browse the repository at this point in the history
…is oidc don't add a default user role
  • Loading branch information
kostobog committed Oct 22, 2024
1 parent 62aa0d1 commit e8b6fae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/main/java/cz/cvut/kbss/analysis/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;

import static java.util.stream.Collectors.toList;

Expand All @@ -36,7 +33,7 @@ public class User extends AbstractEntity implements UserDetails {
private String password;

@Transient
private List<String> roles = Collections.singletonList(SecurityConstants.ROLE_USER);
private List<String> roles = new ArrayList<>();

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ private Converter<Jwt, AbstractAuthenticationToken> grantedAuthoritiesExtractor(
new OidcGrantedAuthoritiesExtractor(config).convert(source);
assert extractedRoles != null;
final Set<SimpleGrantedAuthority> authorities = new HashSet<>(extractedRoles);
// Add default role if it is not present
authorities.add(new SimpleGrantedAuthority(SecurityConstants.ROLE_USER));
return new JwtAuthenticationToken(source, authorities);
};
}
Expand Down

0 comments on commit e8b6fae

Please sign in to comment.