Skip to content

Commit

Permalink
fix: do not use session for teamproject role management
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlukasse committed Jul 31, 2024
1 parent a559470 commit 52d0262
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/main/java/org/ohdsi/webapi/shiro/PermissionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class PermissionManager {

private ThreadLocal<ConcurrentHashMap<String, UserSimpleAuthorizationInfo>> authorizationInfoCache = ThreadLocal.withInitial(ConcurrentHashMap::new);

private Map<AbstractMap.SimpleEntry<String,String>, String> teamProjectRoles = new HashMap<>();
private Map<String, String> teamProjectRoles = new HashMap<>();

public static class PermissionsDTO {

Expand Down Expand Up @@ -658,25 +658,14 @@ public boolean roleExists(String roleName) {
return this.roleRepository.existsByName(roleName);
}

private String getCurrentUserSessionId() {
Subject subject = SecurityUtils.getSubject();
return subject.getSession(false).getId().toString();
}

private AbstractMap.SimpleEntry<String,String> getCurrentUserAndSessionTuple() {
AbstractMap.SimpleEntry<String, String> userAndSessionTuple = new AbstractMap.SimpleEntry<>
(getCurrentUser().getLogin(), getCurrentUserSessionId());
return userAndSessionTuple;
}

public void setCurrentTeamProjectRoleForCurrentUser(String teamProjectRole, String login) {
logger.debug("Current user in setCurrentTeamProjectRoleForCurrentUser() {}", login);
this.teamProjectRoles.put(getCurrentUserAndSessionTuple(), teamProjectRole);
this.teamProjectRoles.put(getCurrentUser().getLogin(), teamProjectRole);
}

public RoleEntity getCurrentTeamProjectRoleForCurrentUser() {
logger.debug("Current user in getCurrentTeamProjectRoleForCurrentUser(): {}", getCurrentUser().getLogin());
String teamProjectRole = this.teamProjectRoles.get(getCurrentUserAndSessionTuple());
String teamProjectRole = this.teamProjectRoles.get(getCurrentUser().getLogin());
if (teamProjectRole == null) {
return null;
} else {
Expand Down

0 comments on commit 52d0262

Please sign in to comment.