Skip to content

Commit

Permalink
[ALS-6235] Investigate: BDC Auth login issue: Explore delays creating…
Browse files Browse the repository at this point in the history
… the user roles (#173)

[ALS-6235] Investigate: BDC Auth login issue: Explore delays creating the user roles

FenceAuthorization service has been refactored to improve readability and modularity.
Fence mapping utility now loads the fence mapping json data on application startup and initializes two maps used by the application. This reduced execution time from ~13.25 minutes to ~9 minutes.
AccessRules now uses a cache when creating new AccessRules. This reduces the time spent querying the database as many access rules are reused by privileges. This change reduced execution time from ~9 minutes down to 2.25 - 2.5 minutes.
Refactor Role creation to allow for parallelization. This reduced execution time from 2.25 - 2.5 minutes down to ~30seconds.
Roles are no longer removed from the user on login. We now update the user roles in place.
  • Loading branch information
Gcolon021 committed May 28, 2024
1 parent 95d0ad6 commit ce9c376
Show file tree
Hide file tree
Showing 5 changed files with 748 additions and 682 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import javax.enterprise.context.ApplicationScoped;
import javax.transaction.Transactional;
import java.util.List;
import java.util.UUID;

/**
Expand All @@ -18,4 +19,14 @@ public class RoleRepository extends BaseRepository<Role, UUID> {
protected RoleRepository() {
super(Role.class);
}

public void persistAll(List<Role> newRoles) {
for (Role newRole : newRoles) {
if (newRole.getUuid() == null) {
em.persist(newRole);
} else {
em.merge(newRole);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import edu.harvard.hms.dbmi.avillach.auth.data.entity.Role;
import edu.harvard.hms.dbmi.avillach.auth.data.repository.RoleRepository;
import edu.harvard.hms.dbmi.avillach.auth.service.auth.FENCEAuthenticationService;
import edu.harvard.hms.dbmi.avillach.auth.utils.FenceMappingUtility;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
Expand Down Expand Up @@ -37,6 +38,9 @@ public class StudyAccessService {
public static final String STUDY_IDENTIFIER = "study_identifier";
public static final String CONSENT_GROUP_CODE = "consent_group_code";

@Inject
private FenceMappingUtility fenceUtilityMapping;

@Inject
FENCEAuthenticationService fenceAuthenticationService;

Expand All @@ -55,7 +59,7 @@ public Response addStudyAccess(@ApiParam(value="The Study Identifier of the new
Map fenceMappingForStudy = null;

try {
Map<String, Map> fenceMapping = fenceAuthenticationService.getFENCEMapping();
Map<String, Map> fenceMapping = this.fenceUtilityMapping.getFENCEMapping();
if (fenceMapping == null) {
throw new Exception("Fence mapping is null");
}
Expand Down
Loading

0 comments on commit ce9c376

Please sign in to comment.