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

Update how we save and log org claims on whoami calls #8254

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

emyl3
Copy link
Collaborator

@emyl3 emyl3 commented Oct 31, 2024

BACKEND PULL REQUEST

Related Issue

Changes Proposed

  • Move the check to the level of the getCurrentUserInfoForWhoAmI method
  • Remove check happening at the LoggedInAuthorizationService level

Additional Information

Testing

  • deployed on dev3

    • find a user that you can log in as that is not a site admin
    • use this mutation to clear that user's roles and facilities
    mutation ($username: String!) {
      clearUserRolesAndFacilities (
          username: $username
      ) {
          id
          nameInfo {
              firstName
              lastName
          }
          email
      }
    }
    
    • log in as that user (check what time you logged in at)
    • check that their roles and facilities have populated
    • do a transaction search in Azure app insights for dev3 with the string (below) and make sure your user's ID does not appear as a log message during that timeframe

Okta OrganizationRoleClaims do not match database OrganizationRoleClaims for User ID:

@emyl3 emyl3 force-pushed the elisa-merethe/fix-logging branch from 1e347c7 to d24b232 Compare October 31, 2024 15:58
Copy link

if (!isAdmin) {
if (currentOrgRoles.isPresent()) {
PartialOktaUser oktaUser = _oktaRepo.findUser(currentUser.getLoginEmail());
return consolidateUser(currentUser, oktaUser);
Copy link
Collaborator Author

@emyl3 emyl3 Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Making use of the consolidateUser method that also handles the comparison check, logging (regardless of the status of the feature flag) and setting the user's role and facilities (if the feature flag is off)

String username = currentAuth.getName();
List<OrganizationRoleClaims> dbOrgRoleClaims =
Copy link
Collaborator Author

@emyl3 emyl3 Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Before I was doing the comparison check way lower in the stack for whoami calls.

Moved the check to the level of the getCurrentUserInfoForWhoAmI method to avoid instances where users who were not migrated were being checked (thus, logging an error).

Copy link
Collaborator

@mpbrown mpbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on dev3 with clearing roles for Oktavius Migratius, successfully populated the cleared roles, and found no log describing a mismatch in app insights. LGTM!

Copy link
Collaborator

@bobbywells52 bobbywells52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks for you work on this!

@emyl3 emyl3 added this pull request to the merge queue Nov 6, 2024
Merged via the queue into main with commit 9ef5878 Nov 6, 2024
38 checks passed
@emyl3 emyl3 deleted the elisa-merethe/fix-logging branch November 6, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants