Skip to content

Commit

Permalink
Refactor handling of user role open access assignment in OktaOAuthAut…
Browse files Browse the repository at this point in the history
…henticationService
  • Loading branch information
Gcolon021 committed Jan 25, 2024
1 parent 5c419ca commit 059167c
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import edu.harvard.dbmi.avillach.util.HttpClientUtil;
import edu.harvard.dbmi.avillach.util.response.PICSUREResponse;
import edu.harvard.hms.dbmi.avillach.auth.JAXRSConfiguration;
import edu.harvard.hms.dbmi.avillach.auth.data.entity.Role;
import edu.harvard.hms.dbmi.avillach.auth.data.entity.User;
import edu.harvard.hms.dbmi.avillach.auth.data.repository.RoleRepository;
import edu.harvard.hms.dbmi.avillach.auth.data.repository.UserRepository;
Expand Down Expand Up @@ -122,9 +123,9 @@ private User loadUser(JsonNode introspectResponse) {
}

// All users that login through OKTA should have the fence_open_access role, or they will not be able to interact with the UI
String fenceOpenAccessRoleName = FENCEAuthenticationService.fence_open_access_role_name;
if (user.getRoles().stream().noneMatch(role -> role.getName().equals(fenceOpenAccessRoleName))) {
user.getRoles().add(roleRepository.getUniqueResultByColumn("name", fenceOpenAccessRoleName));
Role fenceOpenAccessRole = roleRepository.getUniqueResultByColumn("name", FENCEAuthenticationService.fence_open_access_role_name);
if (!user.getRoles().contains(fenceOpenAccessRole)) {
user.getRoles().add(fenceOpenAccessRole);
userRepository.persist(user);
}

Expand Down

0 comments on commit 059167c

Please sign in to comment.