-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fetch group info for users from DB when oktaMigrationEnabled is true #8105
Conversation
backend/src/main/java/gov/cdc/usds/simplereport/idp/repository/DemoOktaRepository.java
Fixed
Show fixed
Hide fixed
backend/src/test/java/gov/cdc/usds/simplereport/service/DbAuthorizationServiceTest.java
Fixed
Show fixed
Hide fixed
acf4def
to
754ae1f
Compare
754ae1f
to
b7956bc
Compare
} | ||
|
||
// To be addressed in #8108 | ||
@AuthorizationConfiguration.RequirePermissionManageUsers | ||
public List<ApiUserWithStatus> getUsersAndStatusInCurrentOrg() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String orgAdminEmail = orgAdmin.get().getLoginEmail(); | ||
return oktaRepository.activateUser(orgAdminEmail); | ||
} else { | ||
throw new IllegalStateException("Organization does not have any org admins."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else
block changes the behavior of this method when the feature flag is enabled.
Previously, even if the org had no admin users this method would succeed
However, with this implementation if an org does not have an admin it will throw an exception.
Let me know if you think this should continue to have the same behavior as before. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense. Btw do we have any additional context on the comment on this method? Is this an old reference to some account request workflow that hasn't been implemented?
/**
* This method is for verifying an organization after the Experian identity verification process.
* It should not be used for any other purpose and once we move to the updated account request
* workflow this should be removed.
*/
@Transactional(readOnly = false)
public String verifyOrganizationNoPermissions(String externalId) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question... Let me check that commit history in see if I can uncover anything... 🕵️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the PR that introduced this change: #2096
I did a search in the repo and couldn't find any mention of a new or updated account request flow 🤔 so I'm not entirely sure what that comment is referencing....
* @return Integer - count of ApiUsers | ||
*/ | ||
public Integer getUserWithSingleFacilityAccessCount(Facility facility) { | ||
List<ApiUser> users = _userRepo.findAllBySingleFacilityAccess(facility); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will fix this bug #7873 🤩
backend/src/main/java/gov/cdc/usds/simplereport/db/repository/ApiUserRepository.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really great overall! Awesome work on this Elisa!
...end/src/main/java/gov/cdc/usds/simplereport/api/accountrequest/AccountRequestController.java
Outdated
Show resolved
Hide resolved
String orgAdminEmail = orgAdmin.get().getLoginEmail(); | ||
return oktaRepository.activateUser(orgAdminEmail); | ||
} else { | ||
throw new IllegalStateException("Organization does not have any org admins."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense. Btw do we have any additional context on the comment on this method? Is this an old reference to some account request workflow that hasn't been implemented?
/**
* This method is for verifying an organization after the Experian identity verification process.
* It should not be used for any other purpose and once we move to the updated account request
* workflow this should be removed.
*/
@Transactional(readOnly = false)
public String verifyOrganizationNoPermissions(String externalId) {
.anyMatch(Predicate.isEqual(email))) { | ||
List<String> adminUserEmails = getOrgAdminUserEmails(duplicateOrg.get()); | ||
|
||
if (adminUserEmails.stream().anyMatch(Predicate.isEqual(email))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to handle or otherwise flag if the org doesn't have any admins? (was thinking about no admin users after this comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK in this context because we are trying to check if the to-be-created new org might be a duplicate of another org. If there are no org admins in that duplicate org, it would throw the exception on line 155. Let me know what you think!
backend/src/main/java/gov/cdc/usds/simplereport/service/OrganizationService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in dev2 and dev3 and is working as excepted -- LGTM! Thank you for you continued heavy effort on this big lift 🙌🏻
@mpbrown @mehansen @DanielSass Ready for re-review! Changes have been redeployed to dev2 and dev3 respectively |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on dev2 and dev3! Great work on this Elisa!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! I have some non-blocking naming nits but they are more personal preference so still approving
backend/src/main/java/gov/cdc/usds/simplereport/db/repository/ApiUserRepository.java
Outdated
Show resolved
Hide resolved
backend/src/main/java/gov/cdc/usds/simplereport/db/repository/ApiUserRepository.java
Outdated
Show resolved
Hide resolved
backend/src/main/java/gov/cdc/usds/simplereport/db/repository/ApiUserRepository.java
Outdated
Show resolved
Hide resolved
* @return Integer - count of ApiUsers | ||
*/ | ||
public Integer getUserWithSingleFacilityAccessCount(Facility facility) { | ||
List<ApiUser> users = _userRepo.findAllBySingleFacilityAccess(facility); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will fix this bug #7873 🤩
d9af933
Quality Gate passedIssues Measures |
private String getOrgExternalId(ApiUser apiUser) { | ||
String orgExternalId; | ||
if (_featureFlagsConfig.isOktaMigrationEnabled()) { | ||
Optional<Organization> org = apiUser.getOrganizations().stream().findFirst(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have users with more than one organization? I don't think we do, but do we know that for certain / are there guardrails in place to ensure that can't happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good, thanks for pairing with me on the review @emyl3.
I think the only issues we noted were specific corner cases we need to make sure get included in the test plan.
Thanks for all your work on this
BACKEND PULL REQUEST
Related Issue
Changes Proposed
oktaMigrationEnabled
flag status, continue to update groups and roles in OktaoktaMigrationEnabled
flag is set totrue
, read groups and roles from DBoktaMigrationEnabled
flag is set tofalse
, read groups and roles from OktaAffected flows:
users
graphql query (I don't think we are calling this on the frontend 🤔)Additional Information
Testing
dev2 -
oktaMigrationEnabled
-true
dev3 -
oktaMigrationEnabled
-false