diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/config/Constants.java b/backend/src/main/java/ca/bc/gov/backendstartapi/config/Constants.java index d5c458468..aa1c6250e 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/config/Constants.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/config/Constants.java @@ -8,4 +8,5 @@ public final class Constants { public static final String INCOMPLETE_SEEDLOT_STATUS = "INC"; public static final String PENDING_SEEDLOT_STATUS = "PND"; public static final String SUBMITTED_SEEDLOT_STATUS = "SUB"; + public static final String MINITRY_OF_FORESTS_ID = "00012797"; } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/security/JwtSecurityUtil.java b/backend/src/main/java/ca/bc/gov/backendstartapi/security/JwtSecurityUtil.java index 150a657b9..8986d14b6 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/security/JwtSecurityUtil.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/security/JwtSecurityUtil.java @@ -1,5 +1,6 @@ package ca.bc.gov.backendstartapi.security; +import ca.bc.gov.backendstartapi.config.Constants; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -9,6 +10,9 @@ /** This class contains methods for handling JWT requests. */ public final class JwtSecurityUtil { + private static final List concreteRoles = + List.of("SPAR_MINISTRY_ORCHARD", "SPAR_TSC_ADMIN"); + /** * Gets user roles from user JWT token. * @@ -48,6 +52,11 @@ public static List getClientIdsFromJwt(Jwt jwtPrincipal) { clientIds.add(clientNumber); } } + // Handling concrete roles with no client id affixed + if (concreteRoles.contains(role) + && !clientIds.contains(Constants.MINITRY_OF_FORESTS_ID)) { + clientIds.add(Constants.MINITRY_OF_FORESTS_ID); + } }); return clientIds; }