Skip to content

Commit

Permalink
fix: add client id to concrete roles
Browse files Browse the repository at this point in the history
  • Loading branch information
craigyu committed Aug 26, 2024
1 parent 4a9c59c commit 641065c
Show file tree
Hide file tree
Showing 2 changed files with 9 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,8 @@
/** This class contains methods for handling JWT requests. */
public final class JwtSecurityUtil {

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

/**
* Gets user roles from user JWT token.
*
Expand Down Expand Up @@ -48,6 +51,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 641065c

Please sign in to comment.