Skip to content

Pkce support#2143

Merged
matttrach merged 2 commits into
rancher:mainfrom
bigkevmcd:pkce-support
May 5, 2026
Merged

Pkce support#2143
matttrach merged 2 commits into
rancher:mainfrom
bigkevmcd:pkce-support

Conversation

@bigkevmcd

Copy link
Copy Markdown
Contributor

Addresses # rancher/rancher#53638

Description

Add PKCE Support for Generic OIDC, Keycloak OIDC and Cognito Auth Providers.

This updates the version of Rancher pulled in by the terraform provider and configures the PKCEMethod field on OIDC Providers.

Testing

Configured the relevant providers with PKCE.

Not a breaking change.

Copilot AI review requested due to automatic review settings April 13, 2026 14:25
@bigkevmcd bigkevmcd self-assigned this Apr 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds PKCE support to the Terraform provider’s OIDC-based auth config resources (Generic OIDC, Keycloak OIDC, Cognito) by surfacing a pkce_method field, mapping it to Rancher’s PKCEMethod, and updating the Rancher dependency versions to include the upstream field.

Changes:

  • Add pkce_method to the shared OIDC schema and wire it into OIDC flatten/expand logic.
  • Update unit tests for Generic OIDC / Keycloak OIDC / Cognito auth config structures and add schema validation coverage for pkce_method.
  • Bump Rancher (and related) module versions in go.mod.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rancher2/structure_auth_config_generic_oidc.go Maps Terraform pkce_method to/from Rancher PKCEMethod in shared OIDC flatten/expand.
rancher2/schema_auth_config_generic_oidc.go Adds pkce_method to the shared OIDC schema fields used by multiple auth providers.
rancher2/schema_auth_config_generic_oidc_test.go Adds schema validation test for pkce_method allowed values.
rancher2/structure_auth_config_generic_oidc_test.go Extends generic OIDC structure tests to include PKCEMethod/pkce_method.
rancher2/structure_auth_config_keycloak_oidc_test.go Extends Keycloak OIDC structure tests to include PKCEMethod/pkce_method.
rancher2/structure_auth_config_cognito_test.go Extends Cognito structure tests to include PKCEMethod/pkce_method.
go.mod Updates Rancher/NorMan and other module versions to pull in PKCE-related upstream changes.

Comment thread rancher2/structure_auth_config_generic_oidc.go Outdated
Comment thread rancher2/schema_auth_config_generic_oidc.go Outdated
Copilot AI review requested due to automatic review settings April 13, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Comment thread rancher2/structure_auth_config_generic_oidc.go
This was referenced Apr 13, 2026
@matttrach matttrach added the area/authentication This appears to be related to authentication. label Apr 13, 2026
warns, errs := r.Validate(d)

assert.Empty(t, warns)
assert.ErrorContains(t, errors.Join(errs...), "expected pkce_method to be one of [S256 ]")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is the extra space here going to mess up the search function?

@bigkevmcd bigkevmcd Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In what sense? We have two possible values for the pkce_method "S256" and "" ?

It would be easy enough to change the validation func not to use the slice version tho'

Copilot AI review requested due to automatic review settings April 14, 2026 08:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Comment on lines 90 to +95
if v, ok := oidcData["EndSessionEndpoint"]; ok {
d.Set("end_session_endpoint", v)
}

d.Set("pkce_method", oidcData["PKCEMethod"])

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

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

flattenOIDCConfig sets pkce_method without checking whether PKCEMethod is present/non-nil in oidcData, and it ignores the d.Set error. If the upstream struct omits this field (or decodes to nil), d.Set can fail and the error will be silently dropped, leaving state inconsistent. Please guard the lookup like EndSessionEndpoint and return a wrapped error when d.Set("pkce_method", v) fails (e.g., return fmt.Errorf("setting pkce_method: %w", err)).

Copilot generated this review using guidance from repository custom instructions.
Comment thread rancher2/schema_auth_config_generic_oidc.go Outdated
Comment thread rancher2/schema_auth_config_generic_oidc.go Outdated

@matttrach matttrach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@bigkevmcd bigkevmcd requested a review from a team April 15, 2026 13:39
Copilot AI review requested due to automatic review settings April 21, 2026 12:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Comment thread rancher2/schema_auth_config_generic_oidc.go Outdated
Copilot AI review requested due to automatic review settings April 21, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.

@JonCrowther JonCrowther left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. One minor nit

Comment thread rancher2/schema_auth_config_generic_oidc.go Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 08:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

}

if valString != "" && valString != "S256" {
errors = append(errors, fmt.Errorf("%q: only supported value is 256, got %q", k, valString))

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

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

validatePKCEMethod checks for the string value "S256", but the returned error message says the only supported value is 256 (missing the leading "S" and missing quotes). This makes the error misleading and will also fail TestAuthConfigGenericOIDCResourcePKCEMethodValidation, which expects "S256" in the message.

Suggested change
errors = append(errors, fmt.Errorf("%q: only supported value is 256, got %q", k, valString))
errors = append(errors, fmt.Errorf("%q: only supported value is %q, got %q", k, "S256", valString))

Copilot uses AI. Check for mistakes.
This adds support for enabling PKCE for Generic OIDC, Keycloak OIDC and
Cognito.
Copilot AI review requested due to automatic review settings April 24, 2026 08:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.

@matttrach matttrach merged commit 1556ea2 into rancher:main May 5, 2026
9 checks passed
@github-actions github-actions Bot mentioned this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/authentication This appears to be related to authentication.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants