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

Wrap discovery and callback calls #2933

Merged
merged 2 commits into from
Sep 6, 2023
Merged

Conversation

gl-johnson
Copy link
Contributor

@gl-johnson gl-johnson commented Aug 31, 2023

Desired Outcome

Implement the wrapper methods introduced in #2919 and the optional ca-cert config in #2920 to allow custom certs to be provided in the OIDC authenticator config.

Implemented Changes

  • Added wrapper methods around:
    • OAuth discovery + JWKS retrieval
    • Identity resolution callback
    • OIDC configuration discovery
  • Updated keycloak OIDC environment to use ca-cert variable instead of container truststore (includes integration tests)

Connected Issue/Story

CNJR-2476

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: CNJR-2309
  • 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

@gl-johnson gl-johnson force-pushed the oidc-configurable-truststore branch 3 times, most recently from 38701a4 to 362d7cf Compare September 1, 2023 15:53
jwks = {
keys: @discovered_provider.jwks
Copy link
Contributor Author

@gl-johnson gl-johnson Sep 1, 2023

Choose a reason for hiding this comment

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

@john-odonnell This is still a WIP, but I'm curious if you have thoughts about this: turns out that .jwks makes a separate call to the provider's JWKS uri so the cert needs to be available for that as well.

As a workaround I added an optional jwks flag to the custom Client.discover which updates the lambda to include the .jwks call accordingly. Feels a bit hacky but better than the alternative of adding yet another wrapper imo.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to say:

I think the only downside to this is that we wouldn't be able to take advantage of previously cached discovery responses.

but as it turns out, the DiscoverIdentityProvider class was never using the discovery cache anyways. Maybe this is a future low-hanging advancement.

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise, you're right - feels hacky, but I think this works for now. Makes me think that ditching the underlying OIDC client gem might make all this a bit cleaner, though.

d = -> { discovery_configuration.discover!(provider_uri) }
case jwks
when false
d = -> { discovery_configuration.discover!(provider_uri) }
Copy link

Choose a reason for hiding this comment

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

Authentication::AuthnOidc::V2::Client#self.discover calls 'discovery_configuration.discover!(provider_uri)' 2 times

)
d = -> { discovery_configuration.discover!(provider_uri) }
case jwks
Copy link

Choose a reason for hiding this comment

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

Authentication::AuthnOidc::V2::Client#self.discover is controlled by argument 'jwks'

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
@@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
[cyberark/conjur#2901](https://github.com/cyberark/conjur/pull/2901)

### Added
- Support an optional`ca-cert` variable for providing custom certs/chains for to verify
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Support an optional`ca-cert` variable for providing custom certs/chains for to verify
- Support an optional`ca-cert` variable for providing custom certs/chains to verify

jwks = {
keys: @discovered_provider.jwks
Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to say:

I think the only downside to this is that we wouldn't be able to take advantage of previously cached discovery responses.

but as it turns out, the DiscoverIdentityProvider class was never using the discovery cache anyways. Maybe this is a future low-hanging advancement.

jwks = {
keys: @discovered_provider.jwks
Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise, you're right - feels hacky, but I think this works for now. Makes me think that ditching the underlying OIDC client gem might make all this a bit cleaner, though.

@gl-johnson gl-johnson force-pushed the oidc-configurable-truststore branch from 560c526 to 89dd2af Compare September 5, 2023 20:41
CHANGELOG.md Show resolved Hide resolved
@gl-johnson gl-johnson force-pushed the oidc-configurable-truststore branch from 89dd2af to 932bb49 Compare September 5, 2023 22:03
@codeclimate
Copy link

codeclimate bot commented Sep 5, 2023

Code Climate has analyzed commit 932bb49 and detected 5 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 1
Complexity 4

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 88.5% (0.0% change).

View more on Code Climate.

@gl-johnson gl-johnson marked this pull request as ready for review September 5, 2023 22:57
@gl-johnson gl-johnson requested a review from a team as a code owner September 5, 2023 22:57
Copy link
Contributor

@john-odonnell john-odonnell left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@gl-johnson gl-johnson merged commit b9130ad into master Sep 6, 2023
@gl-johnson gl-johnson deleted the oidc-configurable-truststore branch September 6, 2023 14:57
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