- 
                Notifications
    
You must be signed in to change notification settings  - Fork 4.5k
 
PKCE and Adding private key JWT support for OIDC #22732
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
Conversation
There was a problem hiding this 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.
        
          
                .changelog/22732.txt
              
                Outdated
          
        
      | @@ -0,0 +1,3 @@ | |||
| ```release-note:feature | |||
| oidc: Added support for client authentication using JWT assertion and PKCE. default PKCE is disable | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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. | 
There was a problem hiding this comment.
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
        
          
                internal/go-sso/oidcauth/jwt.go
              
                Outdated
          
        
      | } | ||
| 
               | 
          ||
| func (a *Authenticator) verifyOIDCToken(ctx context.Context, rawToken string) (map[string]interface{}, error) { | ||
| allClaims := make(map[string]interface{}) | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken care
        
          
                internal/go-sso/oidcauth/oidc.go
              
                Outdated
          
        
      | "time" | ||
| 
               | 
          ||
| "github.com/coreos/go-oidc/v3/oidc" | ||
| // HashiCorp CAP (Cloud Authentication Primitives) library for OIDC flows | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
There was a problem hiding this 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 
algportion please? There are also various tests we can include which were captured in Nomads implementation (ref) 
| 
           @dduzgun-security - Thanks for your feedback 
  | 
    
| 
           @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   | 
    
        
          
                internal/go-sso/oidcauth/auth.go
              
                Outdated
          
        
      | return nil, fmt.Errorf("error creating provider config: %v", err) | ||
| } | ||
| 
               | 
          ||
| provider, error := capOidc.NewProvider(providerConfig) | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken care
        
          
                internal/go-sso/oidcauth/jwt.go
              
                Outdated
          
        
      | 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) { | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" | 
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
        
          
                internal/go-sso/oidcauth/oidc.go
              
                Outdated
          
        
      | 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) | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care
| 
           @dduzgun-security  | 
    
* Adding private key JWT support for OIDC
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
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.