Skip to content

Comments

PKCE and Adding private key JWT support for OIDC#22732

Merged
panman90 merged 20 commits intomainfrom
mansi/jwt_int
Sep 17, 2025
Merged

PKCE and Adding private key JWT support for OIDC#22732
panman90 merged 20 commits intomainfrom
mansi/jwt_int

Conversation

@panman90
Copy link
Contributor

@panman90 panman90 commented Sep 9, 2025

Description

Adding support for private key(client assertion) and PKCE for OIDC

Testing & Reproduction steps

Tested with Keyclock and Auth0 with private key JWT instead of client secret

Links

https://auth0.com/docs/authenticate/enterprise-connections/private-key-jwt-client-auth

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@github-actions github-actions bot added theme/api Relating to the HTTP API interface theme/ui Anything related to the UI pr/dependencies PR specifically updates dependencies of project labels Sep 9, 2025
@panman90 panman90 marked this pull request as ready for review September 10, 2025 05:41
@panman90 panman90 requested a review from a team as a code owner September 10, 2025 05:41
@panman90 panman90 added the type/enhancement Proposed improvement or new feature label Sep 10, 2025
@panman90 panman90 self-assigned this Sep 10, 2025
@panman90 panman90 changed the title Adding private key JWT support for OIDC PKCE and Adding private key JWT support for OIDC Sep 10, 2025
Copy link
Contributor

@suresh-hashicorp suresh-hashicorp left a comment

Choose a reason for hiding this comment

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

UI changes are good.

@@ -0,0 +1,3 @@
```release-note:feature
oidc: Added support for client authentication using JWT assertion and PKCE. default PKCE is disable
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
oidc: Added support for client authentication using JWT assertion and PKCE. default PKCE is disable
auth: add client authentication using JWT assertion and PKCE. default PKCE is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated message, mentioning OIDC as it only cover that auth flow

}

func (a *Authenticator) verifyOIDCToken(ctx context.Context, rawToken string) (map[string]interface{}, error) {
allClaims := make(map[string]interface{})
Copy link
Member

Choose a reason for hiding this comment

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

Please replace interface{} with any

Copy link
Contributor Author

Choose a reason for hiding this comment

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

taken care

"time"

"github.com/coreos/go-oidc/v3/oidc"
// HashiCorp CAP (Cloud Authentication Primitives) library for OIDC flows
Copy link
Member

Choose a reason for hiding this comment

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

This comment is unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

Copy link
Collaborator

@dduzgun-security dduzgun-security left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this.
Here are a few security points which could be reviewed:

  • Can we have the PKCE check enabled explicitly by default?
  • Can we add the kid header to identify which key was used to sign the JWT?
  • If the kid not set, can we include the same x5t header logic as Nomad (ref)? By defaulting the checksum to x5t#S256
  • Can we default to Elliptic Curve instead of RS256? It's more performant. We can also include RS256 in the list of allowed algs
  • Can we add some unit tests for the alg portion please? There are also various tests we can include which were captured in Nomads implementation (ref)

@panman90
Copy link
Contributor Author

@dduzgun-security - Thanks for your feedback

  • Will make necessary change to enable PKCE by default.
  • Regarding kid and EC algorithm, we have kept it out of scope for this release.

@dduzgun-security
Copy link
Collaborator

dduzgun-security commented Sep 15, 2025

@mansi991999 thanks for the reply and looking at it. I forgot to mention on the initial comment but could we also include some unit tests for jwt.go and auth.go?

I've added a comment in the internal RFC to understand more why the kid was moved to out of scope.

mrgupta7
mrgupta7 previously approved these changes Sep 16, 2025
return nil, fmt.Errorf("error creating provider config: %v", err)
}

provider, error := capOidc.NewProvider(providerConfig)
Copy link
Member

Choose a reason for hiding this comment

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

Please don't use 'error' for an error since this is a built in keyword. You can reuse err.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

taken care

return nil, errors.New("data does not contain any valid RSA, ECDSA, or ED25519 public keys")
}

func (a *Authenticator) verifyOIDCToken(ctx context.Context, rawToken string) (map[string]interface{}, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Please replace interface{} with any.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

taken care


"github.com/coreos/go-oidc/v3/oidc"
"github.com/hashicorp/cap/oidc"
cass "github.com/hashicorp/cap/oidc/clientassertion"
Copy link
Member

Choose a reason for hiding this comment

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

Why is this alias required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to make references more concise

authURL, err := provider.AuthURL(ctx, request)
if err != nil {
return "", fmt.Errorf("error generating OAuth state: %v", err)
return "", fmt.Errorf("Error while generating AuthURL %q", err)
Copy link
Member

Choose a reason for hiding this comment

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

error string should start with a lower case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taken care

@panman90
Copy link
Contributor Author

panman90 commented Sep 16, 2025

@dduzgun-security
Added comment on RFC.
Regarding JWT, tests are already there. Added for Auth

@panman90 panman90 requested a review from sreeram77 September 16, 2025 11:23
@panman90 panman90 enabled auto-merge (squash) September 17, 2025 09:34
@panman90 panman90 merged commit 5c4ec6c into main Sep 17, 2025
282 of 290 checks passed
sanikachavan5 pushed a commit that referenced this pull request Sep 23, 2025
* Adding private key JWT support for OIDC
sanikachavan5 added a commit that referenced this pull request Jan 28, 2026
* add timeouts to prevent slowloris attacks

* rename

* fix tests

* fix test

* fix failing test

* add docs and tests

* lint issues

* Added support for IPv6 virtual IP offset calculation and validation. (#22741)

* - Added support for IPv6 virtual IP offset calculation and validation.
- Upgraded `github.com/miekg/dns` dependency to v1.1.68.
- Included `BindAddr` in agent endpoint and enabled binding logic in IP offset calculations.
- Updated `go.mod` and `go.sum` to reflect dependency changes.

* Refactored `addIPOffset` to utilize `BindAddr` and introduced `getAgentBindAddr` for improved binding logic and IP offset calculation.
Added utility function isDualStack

* Executed go mod tidy

* Refactored network utilities into `netutil` package and updated `catalog.go` to use new functions for improved modularity and clarity. Removed duplicate implementations of `GetAgentConfig` and `isDualStack`.

* Added comprehensive unit tests for `netutil` package covering `GetAgentConfig`, `GetAgentBindAddr`, and `IsDualStack`. Refactored functions to support mocking for improved testability.

* only retaining utility function changes.

* added changelog

* Latest Envoy version update - default v1.34.7 (#22735)

* docs: Additional entries for versioned redirects (#22694)

* "Get started" section redirects

* deploy & secure

* Consul operations complete

* register & discover

* Finish service networking

* Enterprise, Runtimes, and Plugins sections

* Reference docs

* added BinAddr field in agent/self API response (#22761)

* PKCE and Adding private key JWT support for OIDC (#22732)

* Adding private key JWT support for OIDC

* Submodules Version upgrade (#22776)

* [CSL-11760] [Envoy Bootstrap] Defaults to IPv6 for admin-bind and grpc-addr in dual stack if its empty (#22763)

* add: func to check dual-stack configuration

* add: testcases for dual-stack of admin-bind and grpc adrr

* envoy: admin-bind and grpc-addr dual-stack defaults to ipv6

* fix(review comment): creates a constant for loopback address

* add: debug log to verify recieved isDualStack value

* add: changelog file added

* update: changelog file

* fix: correct format specifier

* fix(review): make constant for default envoy admin port

* Update .changelog/22763.txt

Co-authored-by: Sreeram Narayanan <sreeram.narayanan@hashicorp.com>

* fix: TestAgent_Monitor flaky test

---------

Co-authored-by: Sreeram Narayanan <sreeram.narayanan@hashicorp.com>

* update: default upstream.local_bind_address to ::1 for IPv6 agent bind address (#22773)

* update: default upstream.local_bind_address to ::1 for IPv6 agent bind addr

* add: changelog

---------

Co-authored-by: Mukul Anand <mukul.anand@hashicorp.com>

* update: set proxy.local_service_address to ::1 for IPv6 agent bind addr (#22772)

* update: set proxy.local_service_address to ::1 for IPv6 agent bind addr

* add: changelog

---------

Co-authored-by: Mukul Anand <mukul.anand@hashicorp.com>

* update: default proxy BindAddress to :: for IPv6 agent bind addr (#22774)

* update: default proxy BindAddress to :: for IPv6 agent bind addr

* add: changelog

* fixing conflicts

---------

Co-authored-by: Mukul Anand <mukul.anand@hashicorp.com>

* Consul ENT default version change #22783 (#22784)

* [Bugfix]: suppress lacks token permission while checking dual stack (#22788)

fix: suppress lacks token permission while checking dual stack

* updated redhat image to latest (#22794)

* Suppress CVEs (#22801)

* redhat version revert (#22806)

redhat image version revert to 9.6

* Suppress CVE-2025-6395 (#22808)

* fix path cleaning of proxied urls (#22671)

* fix path cleaning of proxied urls

* add changelog

* added more tests

* add tests and address review comments

* address review changes

* remove usage of dynamic GitHub actions variable (#22725)

use hardcoded names for preventing attacks

* Multi Port Service Discovery (#22769)

1. Support for registering a service with multiple named ports
2. The named ports can be used in DNS queries to discover ports based on usecase

* add timeouts to prevent slowloris attacks

* Delete .changelog/22625.txt

* doc changes

* run codegen

* simplify error handling

* test: add long-running profile and trace tests for pprof handlers

* changelog: update security note to clarify HTTP server timeout configurations against Slowloris attacks

test: remove short test skip for HTTP server timeout tests

---------

Co-authored-by: nitin-sachdev-29 <nitin.sachdev@hashicorp.com>
Co-authored-by: LakshmiNarayananDesikan <lakshminarayanan.desikan@hashicorp.com>
Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com>
Co-authored-by: mansi991999 <mansi.panchal@hashicorp.com>
Co-authored-by: anilvpatel <anilkumarvinodbhai.patel@hashicorp.com>
Co-authored-by: Sreeram Narayanan <sreeram.narayanan@hashicorp.com>
Co-authored-by: Mukul Anand <mukul.anand@hashicorp.com>
Co-authored-by: Manisha Kumari <manisha.kumari@hashicorp.com>
Co-authored-by: Sriram R <sriramr083@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr/dependencies PR specifically updates dependencies of project pr/no-backport theme/api Relating to the HTTP API interface theme/ui Anything related to the UI type/enhancement Proposed improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants