Skip to content

Commit

Permalink
fix: add client id to concrete roles (#1570)
Browse files Browse the repository at this point in the history
Co-authored-by: Craig Yu <[email protected]>
  • Loading branch information
ngunner15 and craigyu authored Aug 29, 2024
1 parent a5b5b1f commit 48ded19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,6 +10,9 @@
/** This class contains methods for handling JWT requests. */
public final class JwtSecurityUtil {

private static final List<String> concreteRoles =
List.of("SPAR_MINISTRY_ORCHARD", "SPAR_TSC_ADMIN");

/**
* Gets user roles from user JWT token.
*
Expand Down Expand Up @@ -48,6 +52,11 @@ public static List<String> 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;
}
Expand Down

0 comments on commit 48ded19

Please sign in to comment.