Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add client id to concrete roles #1570

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading