diff --git a/pom.xml b/pom.xml index b1e90ea..61b7f1d 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.9.RELEASE + 2.1.6.RELEASE @@ -50,6 +50,7 @@ org.springframework.security.oauth spring-security-oauth2 + 2.3.6.RELEASE org.springframework.boot @@ -67,12 +68,12 @@ org.springframework.security spring-security-jwt + 1.0.10.RELEASE com.fasterxml.jackson.core jackson-databind - 2.8.9 diff --git a/src/main/java/bio/overture/microservicetemplate/jwt/JWTAuthorizationFilter.java b/src/main/java/bio/overture/microservicetemplate/jwt/JWTAuthorizationFilter.java index e969d1e..816ceac 100644 --- a/src/main/java/bio/overture/microservicetemplate/jwt/JWTAuthorizationFilter.java +++ b/src/main/java/bio/overture/microservicetemplate/jwt/JWTAuthorizationFilter.java @@ -30,7 +30,9 @@ @Slf4j public class JWTAuthorizationFilter extends GenericFilterBean { - private final String REQUIRED_ROLE = "USER"; + private final String TYPE_ADMIN = "ADMIN"; + private final String TYPE_USER = "USER"; + private final String REQUIRED_TYPE = TYPE_ADMIN; private final String REQUIRED_STATUS = "Approved"; @Override @@ -42,7 +44,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha val details = (OAuth2AuthenticationDetails) authentication.getDetails(); val user = (JWTUser) details.getDecodedDetails(); - boolean hasCorrectRole = user.getRoles().contains(REQUIRED_ROLE); + boolean hasCorrectRole = user.getType().equals(REQUIRED_TYPE); boolean hasCorrectStatus = user.getStatus().equalsIgnoreCase(REQUIRED_STATUS); if(!hasCorrectRole || !hasCorrectStatus) { diff --git a/src/main/java/bio/overture/microservicetemplate/jwt/JWTUser.java b/src/main/java/bio/overture/microservicetemplate/jwt/JWTUser.java index c7f64b9..ec208d7 100644 --- a/src/main/java/bio/overture/microservicetemplate/jwt/JWTUser.java +++ b/src/main/java/bio/overture/microservicetemplate/jwt/JWTUser.java @@ -31,6 +31,7 @@ public class JWTUser { private String createdAt; private String lastLogin; private String preferredLanguage; - private List roles; + private String type; + private List permissions; } \ No newline at end of file