Skip to content

Commit db13fce

Browse files
committed
✨ Update standard JWTUser template to current ego
1 parent 332d95a commit db13fce

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/java/bio/overture/microservicetemplate/jwt/JWTAuthorizationFilter.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
@Slf4j
3131
public class JWTAuthorizationFilter extends GenericFilterBean {
3232

33-
private final String REQUIRED_ROLE = "USER";
33+
private final String TYPE_ADMIN = "ADMIN";
34+
private final String TYPE_USER = "USER";
35+
private final String REQUIRED_TYPE = TYPE_ADMIN;
3436
private final String REQUIRED_STATUS = "Approved";
3537

3638
@Override
@@ -42,7 +44,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
4244
val details = (OAuth2AuthenticationDetails) authentication.getDetails();
4345
val user = (JWTUser) details.getDecodedDetails();
4446

45-
boolean hasCorrectRole = user.getRoles().contains(REQUIRED_ROLE);
47+
boolean hasCorrectRole = user.getType().equals(REQUIRED_TYPE);
4648
boolean hasCorrectStatus = user.getStatus().equalsIgnoreCase(REQUIRED_STATUS);
4749

4850
if(!hasCorrectRole || !hasCorrectStatus) {

src/main/java/bio/overture/microservicetemplate/jwt/JWTUser.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class JWTUser {
3131
private String createdAt;
3232
private String lastLogin;
3333
private String preferredLanguage;
34-
private List<String> roles;
34+
private String type;
35+
private List<String> permissions;
3536

3637
}

0 commit comments

Comments
 (0)