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

[WIP] Introduce generic OIDC provider #45366

Open
wants to merge 28 commits into
base: release/v2.9
Choose a base branch
from

Conversation

crobby
Copy link
Contributor

@crobby crobby commented May 3, 2024

Issue:

#10053

Problem

New feature: Generic support OIDC auth providers

Solution

New auth provider added that relies on the existing OIDC functionality as much as possible, but provides support for extra options (custom scopes, custom endpoints or use of discovery)
There is no periodic refresh for user attributes when using the generic provider.

Testing

A full test plan should be developed by QA for this feature.

Engineering Testing

Manual Testing

I've tested this manually against a few different OIDC providers. I have a containerized Keycloak OIDC setup that can be used for quick testing, but other OIDC providers should also be tested.

Automated Testing

Unit tests will be added as this PR evolves.

  • If "None" - Reason: EXPLAIN THE REASON
  • If "None" - GH Issue/PR: LINK TO GH ISSUE/PR TO ADD TESTS

Summary: TODO

QA Testing Considerations

The new provider should be tested with multiple OIDC providers.

Regressions Considerations

We should also perform some regression tests against the existing OIDC providers. There was some minor refactoring that shouldn't impact anything, but it's worth testing.

@crobby crobby marked this pull request as ready for review May 17, 2024 12:27
@crobby crobby marked this pull request as draft May 17, 2024 12:28
@crobby crobby marked this pull request as ready for review May 17, 2024 15:28
pkg/auth/providers/genericoidc/genericoidc_provider.go Outdated Show resolved Hide resolved
}

// getRedirectURL uses the AuthConfig map to build-up the redirect URL passed to the OIDC provider at login-time.
func (g *GenOIDCProvider) getRedirectURL(config map[string]interface{}) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder about using https://pkg.go.dev/golang.org/x/oauth2#Config.AuthCodeURL to generate the URL?

You'd create an oauth2.Config value and then use the AuthCodeURL() to generate the URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting thought, I'll give it a look. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may opt to just make sure that this is all encoded correctly. AuthCodeURL does a bit more than what we're currently doing here. Currently, the dashboard is expecting to handle the addition of the state param (I don't have the history on that), so going with AuthCodeURL would be a departure from what they're expecting to get.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interestingly enough, the dashboard currently seems to be expecting the not-properly encoded version and then it does the encoding itself. If I return a nicely encoded version, the dashboard winds-up double-encoding...which fails eventually after login.
I will keep this comment open and work with the dashboard folks to see if they can adjust to a better-behaved backend.

pkg/auth/providers/oidc/oidc_client.go Outdated Show resolved Hide resolved
pkg/auth/providers/oidc/oidc_provider.go Outdated Show resolved Hide resolved
Copy link
Contributor

@pmatseykanets pmatseykanets left a comment

Choose a reason for hiding this comment

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

This looks good 👍

pkg/auth/providers/genericoidc/genericoidc_provider.go Outdated Show resolved Hide resolved
pkg/auth/providers/genericoidc/genericoidc_provider.go Outdated Show resolved Hide resolved
Comment on lines +138 to +142
return fmt.Sprintf(
"%s?client_id=%s&response_type=code&redirect_uri=%s",
authURL,
config["clientId"],
config["rancherUrl"],
Copy link
Contributor

Choose a reason for hiding this comment

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

These need to be query encoded, or use AuthCodeURL, as Kevin suggests, which already does it.

pkg/auth/providers/oidc/oidc_client.go Outdated Show resolved Hide resolved
pkg/auth/providers/oidc/oidc_client.go Outdated Show resolved Hide resolved
pkg/auth/providers/oidc/oidc_client.go Outdated Show resolved Hide resolved
pkg/auth/providers/oidc/oidc_client.go Outdated Show resolved Hide resolved
pkg/auth/providers/oidc/oidc_client.go Outdated Show resolved Hide resolved
use http client with timeout for discovery
error formatting cleanup
use JoinPath instead of Sprintf
… and be able to handle colons in the externalID
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.

None yet

3 participants