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

Feat jwe #140

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3c9ec5e
feat(jwt): support jwe
james-d-elliott Jul 14, 2024
edd6187
refactor: misc
james-d-elliott Sep 4, 2024
1fd7ad6
temp
james-d-elliott Sep 4, 2024
d2ba93b
refactor: misc
james-d-elliott Sep 13, 2024
eb609a6
refactor: misc
james-d-elliott Sep 19, 2024
e00c898
temp
james-d-elliott Sep 19, 2024
38f8bbf
temp
james-d-elliott Sep 22, 2024
17f8056
temp
james-d-elliott Sep 22, 2024
6547ae2
temp
james-d-elliott Sep 22, 2024
de64627
client auth
james-d-elliott Sep 22, 2024
e98f4cf
client auth tests
james-d-elliott Sep 23, 2024
5a202af
client auth tests
james-d-elliott Sep 24, 2024
16ba9fd
client auth tests
james-d-elliott Sep 25, 2024
b4a19f7
client auth tests
james-d-elliott Sep 25, 2024
fbc22db
client auth tests
james-d-elliott Sep 25, 2024
2d195d1
client auth tests
james-d-elliott Sep 25, 2024
ea8db71
client auth tests
james-d-elliott Sep 27, 2024
089cca1
client auth tests
james-d-elliott Sep 27, 2024
5a03150
client auth tests
james-d-elliott Sep 27, 2024
18b4e1b
client auth tests
james-d-elliott Sep 27, 2024
2d8115b
client auth tests
james-d-elliott Sep 27, 2024
33bb1f5
client auth tests
james-d-elliott Sep 27, 2024
bff1f4a
client auth tests
james-d-elliott Sep 27, 2024
95370b6
client auth tests
james-d-elliott Sep 28, 2024
d31ada4
client auth tests
james-d-elliott Sep 28, 2024
d669b0e
client auth tests
james-d-elliott Sep 28, 2024
b43bc14
docs: add docs
james-d-elliott Sep 28, 2024
5df0ecf
fix: lint
james-d-elliott Sep 28, 2024
1438817
feat: claims interface
james-d-elliott Sep 28, 2024
7fac454
feat: claims interface
james-d-elliott Sep 29, 2024
2a7c7fa
feat: claims interface
james-d-elliott Oct 3, 2024
7637fe0
feat: claims interface
james-d-elliott Oct 4, 2024
f157069
refactor: map claims converter
james-d-elliott Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions access_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestWriteAccessError(t *testing.T) {
rw.EXPECT().WriteHeader(http.StatusBadRequest)
rw.EXPECT().Write(gomock.Any())

provider.WriteAccessError(context.Background(), rw, nil, ErrInvalidRequest)
provider.WriteAccessError(context.TODO(), rw, nil, ErrInvalidRequest)
}

func TestWriteAccessError_RFC6749(t *testing.T) {
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestWriteAccessError_RFC6749(t *testing.T) {
config.UseLegacyErrorFormat = c.includeExtraFields

rw := httptest.NewRecorder()
provider.WriteAccessError(context.Background(), rw, nil, c.err)
provider.WriteAccessError(context.TODO(), rw, nil, c.err)

var params struct {
Error string `json:"error"` // specified by RFC, required
Expand Down
2 changes: 1 addition & 1 deletion access_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestWriteAccessResponse(t *testing.T) {
rw.EXPECT().Write(gomock.Any())
resp.EXPECT().ToMap().Return(map[string]any{})

provider.WriteAccessResponse(context.Background(), rw, ar, resp)
provider.WriteAccessResponse(context.TODO(), rw, ar, resp)
assert.Equal(t, consts.ContentTypeApplicationJSON, header.Get(consts.HeaderContentType))
assert.Equal(t, consts.CacheControlNoStore, header.Get(consts.HeaderCacheControl))
assert.Equal(t, consts.PragmaNoCache, header.Get(consts.HeaderPragma))
Expand Down
231 changes: 116 additions & 115 deletions authorize_request_handler.go

Large diffs are not rendered by default.

353 changes: 297 additions & 56 deletions authorize_request_handler_oidc_request_test.go

Large diffs are not rendered by default.

84 changes: 68 additions & 16 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@ type Client interface {
// GetID returns the client ID.
GetID() (id string)

// GetClientSecret returns the ClientSecret.
GetClientSecret() (secret ClientSecret)

// GetClientSecretPlainText returns the ClientSecret as plaintext if available. The semantics of this function
// return values are important.
// If the client is not configured with a secret the return should be:
// - secret with value nil, ok with value false, and err with value of nil
// If the client is configured with a secret but is hashed or otherwise not a plaintext value:
// - secret with value nil, ok with value true, and err with value of nil
// If an error occurs retrieving the secret other than this:
// - secret with value nil, ok with value true, and err with value of the error
// If the plaintext secret is successful:
// - secret with value of the bytes of the plaintext secret, ok with value true, and err with value of nil
GetClientSecretPlainText() (secret []byte, ok bool, err error)

// GetRedirectURIs returns the client's allowed redirect URIs.
GetRedirectURIs() []string

Expand Down Expand Up @@ -230,6 +243,19 @@ type AuthenticationMethodClient interface {
// methods.
GetRevocationEndpointAuthSigningAlg() (alg string)

// GetPushedAuthorizationRequestEndpointAuthMethod is equivalent to the
// 'pushed_authorize_request_endpoint_auth_method' client metadata value which determines the requested Client
// Authentication method for the Pushed Authorization Request Endpoint. The options are client_secret_post,
// client_secret_basic, client_secret_jwt, and private_key_jwt.
GetPushedAuthorizationRequestEndpointAuthMethod() (method string)

// GetPushedAuthorizationRequestEndpointAuthSigningAlg is equivalent to the
// 'pushed_authorization_request_endpoint_auth_signing_alg' client metadata value which determines the JWS [JWS] alg
// algorithm [JWA] that MUST be used for signing the JWT [JWT] used to authenticate the
// Client at the Pushed Authorization Request Endpoint for the private_key_jwt and client_secret_jwt authentication
// methods.
GetPushedAuthorizationRequestEndpointAuthSigningAlg() (alg string)

JSONWebKeysClient
}

Expand Down Expand Up @@ -368,7 +394,7 @@ type RequestedAudienceImplicitClient interface {
type IntrospectionJWTResponseClient interface {
// GetIntrospectionSignedResponseKeyID returns the specific key identifier used to satisfy JWS requirements for
// OAuth 2.0 JWT introspection response specifications. If unspecified the other available parameters will be
// // utilized to select an appropriate key.
// utilized to select an appropriate key.
GetIntrospectionSignedResponseKeyID() (kid string)

// GetIntrospectionSignedResponseAlg is equivalent to the 'introspection_signed_response_alg' client metadata
Expand All @@ -379,7 +405,7 @@ type IntrospectionJWTResponseClient interface {

// GetIntrospectionEncryptedResponseKeyID returns the specific key identifier used to satisfy JWE requirements for
// OAuth 2.0 JWT introspection response specifications. If unspecified the other available parameters will be
// // utilized to select an appropriate key.
// utilized to select an appropriate key.
GetIntrospectionEncryptedResponseKeyID() (kid string)

// GetIntrospectionEncryptedResponseAlg is equivalent to the 'introspection_encrypted_response_alg' client metadata
Expand Down Expand Up @@ -414,20 +440,22 @@ type DefaultClient struct {

type DefaultJARClient struct {
*DefaultClient
JSONWebKeysURI string `json:"jwks_uri"`
JSONWebKeys *jose.JSONWebKeySet `json:"jwks"`
TokenEndpointAuthMethod string `json:"token_endpoint_auth_method"`
IntrospectionEndpointAuthMethod string `json:"introspection_endpoint_auth_method"`
RevocationEndpointAuthMethod string `json:"revocation_endpoint_auth_method"`
RequestURIs []string `json:"request_uris"`
RequestObjectSigningKeyID string `json:"request_object_signing_kid"`
RequestObjectSigningAlg string `json:"request_object_signing_alg"`
RequestObjectEncryptionKeyID string `json:"request_object_encryption_kid"`
RequestObjectEncryptionAlg string `json:"request_object_encryption_alg"`
RequestObjectEncryptionEnc string `json:"request_object_encryption_enc"`
TokenEndpointAuthSigningAlg string `json:"token_endpoint_auth_signing_alg"`
IntrospectionEndpointAuthSigningAlg string `json:"introspection_endpoint_auth_signing_alg"`
RevocationEndpointAuthSigningAlg string `json:"revocation_endpoint_auth_signing_alg"`
JSONWebKeysURI string `json:"jwks_uri"`
JSONWebKeys *jose.JSONWebKeySet `json:"jwks"`
TokenEndpointAuthMethod string `json:"token_endpoint_auth_method"`
IntrospectionEndpointAuthMethod string `json:"introspection_endpoint_auth_method"`
RevocationEndpointAuthMethod string `json:"revocation_endpoint_auth_method"`
PushedAuthorizationRequestEndpointAuthMethod string `json:"pushed_authorization_request_endpoint_auth_method"`
RequestURIs []string `json:"request_uris"`
RequestObjectSigningKeyID string `json:"request_object_signing_kid"`
RequestObjectSigningAlg string `json:"request_object_signing_alg"`
RequestObjectEncryptionKeyID string `json:"request_object_encryption_kid"`
RequestObjectEncryptionAlg string `json:"request_object_encryption_alg"`
RequestObjectEncryptionEnc string `json:"request_object_encryption_enc"`
TokenEndpointAuthSigningAlg string `json:"token_endpoint_auth_signing_alg"`
IntrospectionEndpointAuthSigningAlg string `json:"introspection_endpoint_auth_signing_alg"`
RevocationEndpointAuthSigningAlg string `json:"revocation_endpoint_auth_signing_alg"`
PushedAuthorizationRequestEndpointAuthSigningAlg string `json:"pushed_authorization_request_endpoint_auth_signing_alg"`
}

type DefaultResponseModeClient struct {
Expand Down Expand Up @@ -455,6 +483,22 @@ func (c *DefaultClient) GetClientSecret() (secret ClientSecret) {
return c.ClientSecret
}

func (c *DefaultClient) GetClientSecretPlainText() (secret []byte, ok bool, err error) {
if c.ClientSecret == nil || !c.ClientSecret.Valid() {
return nil, false, nil
}

if !c.ClientSecret.IsPlainText() {
return nil, true, nil
}

if secret, err = c.ClientSecret.GetPlainTextValue(); err != nil {
return nil, true, err
}

return secret, true, nil
}

func (c *DefaultClient) GetRotatedClientSecrets() (secrets []ClientSecret) {
return c.RotatedClientSecrets
}
Expand Down Expand Up @@ -513,6 +557,10 @@ func (c *DefaultJARClient) GetRevocationEndpointAuthSigningAlg() string {
return c.RevocationEndpointAuthSigningAlg
}

func (c *DefaultJARClient) GetPushedAuthorizationRequestEndpointAuthSigningAlg() (alg string) {
return c.PushedAuthorizationRequestEndpointAuthSigningAlg
}

func (c *DefaultJARClient) GetRequestObjectSigningKeyID() string {
return c.RequestObjectSigningKeyID
}
Expand Down Expand Up @@ -545,6 +593,10 @@ func (c *DefaultJARClient) GetRevocationEndpointAuthMethod() string {
return c.RevocationEndpointAuthMethod
}

func (c *DefaultJARClient) GetPushedAuthorizationRequestEndpointAuthMethod() string {
return c.PushedAuthorizationRequestEndpointAuthMethod
}

func (c *DefaultJARClient) GetRequestURIs() []string {
return c.RequestURIs
}
Expand Down
Loading
Loading