Skip to content

Comments

DT-2918: Add user status info to the user in the GET /me call#2817

Open
rushtong wants to merge 12 commits intodevelopfrom
gr-DT-2918-show-tos-for-user
Open

DT-2918: Add user status info to the user in the GET /me call#2817
rushtong wants to merge 12 commits intodevelopfrom
gr-DT-2918-show-tos-for-user

Conversation

@rushtong
Copy link
Contributor

@rushtong rushtong commented Feb 20, 2026

Addresses

Partially addresses https://broadworkbench.atlassian.net/browse/DT-2918
See front end PR here: DataBiosphere/duos-ui#3337

Summary

This PR makes a different call to Sam to get the user's combined state when any API call is made (during the initial OAuth filter process). It then tacks on an additional field to UserStatusInfo to reflect the current tosAccepted that we would normally get from the diagnostics call. The generated userStatusInfo is then added to the user response object in the current GET /api/user/me call.

Example response snippet from GET /api/user/me:

...
  "userStatusInfo": {
    "userSubjectId": "103..................318",
    "userEmail": "gr......@broadinstitute.org",
    "enabled": true,
    "tosAccepted": true
  },
...

The reason to do this is to reduce the number of API calls the UI has to make when a user signs in. Currently, it calls the me API and then after waiting for that, it makes a call to the diagnostics API which returns terms of service information:

Screenshot 2026-02-20 at 1 01 28 PM

In a future UI PR, we can trim that down and skip the diagnostics API call altogether because we'll have terms of service information stored directly on the user.


Have you read CONTRIBUTING.md lately? If not, do that first.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@rushtong rushtong marked this pull request as ready for review February 20, 2026 20:39
@rushtong rushtong requested a review from a team as a code owner February 20, 2026 20:39
@rushtong rushtong requested review from Copilot, eweitz, fboulnois, kevinmarete and otchet-broad and removed request for a team and Copilot February 20, 2026 20:39
Copilot AI review requested due to automatic review settings February 21, 2026 18:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the GET /api/user/me response to include Sam-derived userStatusInfo (including Terms of Service acceptance), using Sam’s “combined state” endpoint to reduce UI follow-up calls.

Changes:

  • Add a Sam “combined state” API call and map it into UserStatusInfo.tosAccepted.
  • Attach userStatusInfo onto the User object returned from GET /api/user/me.
  • Update OpenAPI schemas and add/adjust unit tests for the new behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main/java/org/broadinstitute/consent/http/db/SamDAO.java Adds getCombinedUserStatusInfo and Gson singleton usage for parsing
src/main/java/org/broadinstitute/consent/http/service/sam/SamService.java Exposes getCombinedUserStatusInfo passthrough
src/main/java/org/broadinstitute/consent/http/authentication/AuthorizationHelper.java Switches status lookup to combined-state call
src/main/java/org/broadinstitute/consent/http/resources/UserResource.java Enriches /me response with userStatusInfo
src/main/java/org/broadinstitute/consent/http/models/sam/UserStatusInfo.java Adds tosAccepted field
src/main/java/org/broadinstitute/consent/http/models/sam/CombinedState.java Adds model wrapper for Sam combined-state response
src/main/java/org/broadinstitute/consent/http/models/User.java Adds userStatusInfo field to API user model
src/main/java/org/broadinstitute/consent/http/configurations/ServicesConfiguration.java Adds combined-state URL path helper
src/main/resources/assets/schemas/User.yaml Documents userStatusInfo on User schema
src/main/resources/assets/schemas/SamUserStatusInfo.yaml New schema for userStatusInfo object
src/test/java/org/broadinstitute/consent/http/service/dao/SamDAOTest.java Adds combined-state DAO tests + refactors randomness helpers
src/test/java/org/broadinstitute/consent/http/service/SamServiceTest.java New tests for SamService method passthroughs/order
src/test/java/org/broadinstitute/consent/http/resources/UserResourceTest.java Adds tests validating /me includes userStatusInfo
src/test/java/org/broadinstitute/consent/http/authentication/AuthorizationHelperTest.java Updates tests to mock combined-state call
src/test/java/org/broadinstitute/consent/http/AbstractTestHelper.java Adds randomBoolean() helper

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

rushtong and others added 2 commits February 21, 2026 14:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link

Copy link
Contributor

@kevinmarete kevinmarete left a comment

Choose a reason for hiding this comment

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

Nice

Copy link
Contributor

@fboulnois fboulnois left a comment

Choose a reason for hiding this comment

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

thank you 👍

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