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

Refactor OIDC client to include refresh token exchange #2667

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

john-odonnell
Copy link
Contributor

Desired Outcome

The OIDC client wrapper class needs updating so it can facilitate a refresh token-for-ID token exchange. Future tasks will use the updated client functionality as part of a new OIDC authentication strategy.

The new OIDC client wrapper method should take a refresh token as argument, and return a decoded ID token, along with a fresh refresh token if applicable.

Implemented Changes

  • Renamed client.callback -> client.get_token_with_code
  • Added client.get_token_with_refresh_token
  • Includes RSpec tests for the new method

Connected Issue/Story

CyberArk internal issue link: ONYX-26609

Definition of Done

At least 1 todo must be completed in the sections below for the PR to be
merged.

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a
    CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code
    changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: insert issue ID
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

Copy link
Contributor

@gl-johnson gl-johnson left a comment

Choose a reason for hiding this comment

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

LGTM. Had a small question/comment

decoded_id_token = decode_id_token(id_token)

nonce_to_verify = nonce
nonce_to_verify = nil unless decoded_id_token.raw_attributes['nonce']
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the idea here that returning the original nonce value is optional for the authorization server when using the refresh_token grant type, versus required when making the original authorization code request?

I'm wondering if this could be handled more cleanly in the verify_id_token method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly - more detail here:

it SHOULD NOT have a nonce Claim, even when the ID Token issued at the time of the original authentication contained nonce; however, if it is present, its value MUST be the same as in the ID Token issued at the time of the original authentication

I'm wondering if this could be handled more cleanly in the verify_id_token method

You're probably right - I'll refactor.

@john-odonnell john-odonnell marked this pull request as ready for review October 25, 2022 13:37
@john-odonnell john-odonnell requested a review from a team as a code owner October 25, 2022 13:37
Copy link
Contributor

@gl-johnson gl-johnson left a comment

Choose a reason for hiding this comment

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

LGTM

@john-odonnell john-odonnell merged commit 127967c into oidc-code-with-refresh Oct 26, 2022
@john-odonnell john-odonnell deleted the johnodon-onyx-26609 branch October 26, 2022 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants