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

Token exchange for device sso clients #16832

Merged
merged 3 commits into from
Jun 3, 2024
Merged

Conversation

rileyanderson
Copy link
Contributor

@rileyanderson rileyanderson commented May 21, 2024

Summary

  • Token exchange for device sso clients

Related issue(s)

Testing

  • Authenticate with SiS using a client that has api authentication and shared_sessions (vamobile will work)
  • When you call /authorize send scope=device_sso param
  • Call /token normally to get you tokens, you should receive a device_secret
  • Exchange tokens by calling /token with:
    {
      "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
      "subject_token": "{access_token}",
      "subject_token_type": "urn:ietf:params:oauth:token-type:access_token",
      "actor_token": "{device_secret}",
      "actor_token_type": "urn:x-oath:params:oauth:token-type:device-secret",
      "client_id": "vaweb"
    }
  • You should receive new tokens in the set-cookie header

What areas of the site does it impact?

Authentication

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected

Copy link

github-actions bot commented May 21, 2024

1 Error
🚫 This PR changes 1143 LoC (not counting whitespace/newlines).

In order to ensure each PR receives the proper attention it deserves, those exceeding
500 will not be reviewed, nor will they be allowed to merge. Please break this PR up into
smaller ones.

If you have reason to believe that this PR should be granted an exception, please see the
Submitting pull requests for approval - FAQ.

File Summary

Files

  • app/controllers/concerns/sign_in/audience_validator.rb (+1/-1)

  • app/controllers/v0/sign_in_controller.rb (+1/-1)

  • app/services/sign_in/client_assertion_validator.rb (+1/-1)

  • app/services/sign_in/constants/auth.rb (+2/-3)

  • app/services/sign_in/constants/urn.rb (+13/-0)

  • app/services/sign_in/errors.rb (+4/-0)

  • app/services/sign_in/session_spawner.rb (+124/-0)

  • app/services/sign_in/token_exchanger.rb (+101/-0)

  • app/services/sign_in/token_params_validator.rb (+19/-4)

  • app/services/sign_in/token_response_generator.rb (+11/-0)

  • modules/accredited_representative_portal/spec/requests/accredited_representative_portal/application_spec.rb (+1/-1)

  • spec/controllers/sign_in/audience_validator_spec.rb (+1/-1)

  • spec/controllers/v0/sign_in_controller_spec.rb (+272/-2)

  • spec/services/sign_in/client_assertion_validator_spec.rb (+1/-1)

  • spec/services/sign_in/code_validator_spec.rb (+1/-1)

  • spec/services/sign_in/session_spawner_spec.rb (+239/-0)

  • spec/services/sign_in/token_exchanger_spec.rb (+215/-0)

  • spec/services/sign_in/token_params_validator_spec.rb (+73/-4)

  • spec/services/sign_in/token_response_generator_spec.rb (+43/-0)

    Note: We exclude files matching the following when considering PR size:

    *.csv, *.json, *.tsv, *.txt, Gemfile.lock, app/swagger, modules/mobile/docs, spec/fixtures/, spec/support/vcr_cassettes/, modules/mobile/spec/support/vcr_cassettes/, db/seeds, modules/vaos/app/docs, modules/meb_api/app/docs, modules/appeals_api/app/swagger/, *.bru
    

Big PRs are difficult to review, often become stale, and cause delays.

Generated by 🚫 Danger

@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 21, 2024 17:21 Inactive
@rileyanderson rileyanderson force-pushed the token-exchange-device-secret branch from b511955 to 67e6040 Compare May 21, 2024 17:26
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 21, 2024 17:35 Inactive
@rileyanderson rileyanderson force-pushed the token-exchange-device-secret branch from 67e6040 to 2dafcdc Compare May 22, 2024 17:04
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 22, 2024 17:13 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 22, 2024 19:47 Inactive
@rileyanderson rileyanderson force-pushed the token-exchange-device-secret branch from 2dafcdc to 6ba7b1e Compare May 23, 2024 21:27
@rileyanderson rileyanderson marked this pull request as ready for review May 23, 2024 21:46
@rileyanderson rileyanderson requested a review from a team as a code owner May 23, 2024 21:46
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 23, 2024 21:54 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 24, 2024 01:32 Inactive
@rileyanderson rileyanderson force-pushed the token-exchange-device-secret branch 2 times, most recently from a353d9a to d992e8e Compare May 24, 2024 18:18
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 24, 2024 18:18 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 24, 2024 18:32 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 24, 2024 19:40 Inactive
@bosawt bosawt requested review from a team as code owners May 31, 2024 19:40
@bosawt bosawt force-pushed the token-exchange-device-secret branch from c908cd3 to 429aea0 Compare May 31, 2024 19:47
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 31, 2024 19:48 Inactive
@bosawt bosawt force-pushed the token-exchange-device-secret branch from 429aea0 to dbc73d1 Compare May 31, 2024 19:56
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 31, 2024 20:22 Inactive
Copy link
Contributor

@dickdavis dickdavis left a comment

Choose a reason for hiding this comment

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

LGTM, just a few questions and nitpick suggestions, but overall implementation looks solid.

app/services/sign_in/session_spawner.rb Outdated Show resolved Hide resolved
app/services/sign_in/session_spawner.rb Outdated Show resolved Hide resolved
app/services/sign_in/token_exchanger.rb Outdated Show resolved Hide resolved
app/services/sign_in/token_exchanger.rb Outdated Show resolved Hide resolved
app/services/sign_in/token_exchanger.rb Outdated Show resolved Hide resolved
app/services/sign_in/token_exchanger.rb Outdated Show resolved Hide resolved
@bosawt bosawt force-pushed the token-exchange-device-secret branch from dbc73d1 to 8fac4ca Compare May 31, 2024 20:50
@bosawt bosawt requested a review from dickdavis May 31, 2024 20:51
@bosawt
Copy link
Contributor

bosawt commented May 31, 2024

@dickdavis I believe I've addressed your comments, I made changes in response to all of them except the TokenParamValidator one since that's not actionable in this PR

@bosawt bosawt force-pushed the token-exchange-device-secret branch from 8fac4ca to 6f4e378 Compare May 31, 2024 21:08
@va-vfs-bot va-vfs-bot temporarily deployed to token-exchange-device-secret/main/main May 31, 2024 21:17 Inactive
dickdavis
dickdavis previously approved these changes May 31, 2024
Copy link
Contributor

@dickdavis dickdavis left a comment

Choose a reason for hiding this comment

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

Tested locally and works as expected

@bosawt bosawt self-requested a review June 3, 2024 17:37
Copy link
Contributor

@gabezurita gabezurita left a comment

Choose a reason for hiding this comment

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

The one ARP change LGTM 😄

Copy link
Contributor

@ericboehs ericboehs left a comment

Choose a reason for hiding this comment

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

Code looking clean.
kevin-the-office-gif

@ericboehs ericboehs merged commit eac1210 into master Jun 3, 2024
18 of 19 checks passed
@ericboehs ericboehs deleted the token-exchange-device-secret branch June 3, 2024 20:17
cloudmagic80 pushed a commit that referenced this pull request Jun 4, 2024
* Add token exchange for device sso

* [82121] refactoring and updating token exchange functionality

* use ActiveModel::Validations

---------

Co-authored-by: Trevor Bosaw <bosawt@gmail.com>
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.

7 participants