Skip to content

Commit e030d83

Browse files
authored
Merge pull request #294 from ory/master
[pull] master from ory:master
2 parents 7ff3051 + 3f86782 commit e030d83

File tree

7 files changed

+38
-11
lines changed

7 files changed

+38
-11
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
55
**Table of Contents**
66

7-
- [0.0.0 (2025-02-21)](#000-2025-02-21)
7+
- [0.0.0 (2025-02-25)](#000-2025-02-25)
88
- [Bug Fixes](#bug-fixes)
99
- [Features](#features)
1010
- [2.3.0 (2025-01-17)](#230-2025-01-17)
@@ -719,11 +719,16 @@
719719

720720
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
721721

722-
# [0.0.0](https://github.com/ory/hydra/compare/v2.3.0...v0.0.0) (2025-02-21)
722+
# [0.0.0](https://github.com/ory/hydra/compare/v2.3.0...v0.0.0) (2025-02-25)
723723

724724

725725
### Bug Fixes
726726

727+
* Allow updating when JWKS URI is set ([#3935](https://github.com/ory/hydra/issues/3935)) ([#3946](https://github.com/ory/hydra/issues/3946)) ([fb1655b](https://github.com/ory/hydra/commit/fb1655ba86077b10141132ed332ba8d6f8c70582)):
728+
729+
The client validator no longer rejects PATCH and PUT updates when `JSONWebKeysURI` is non-empty and `JSONWebKeys` is not nil.
730+
731+
* CLI usage help examples ([#3943](https://github.com/ory/hydra/issues/3943)) ([e24f9a7](https://github.com/ory/hydra/commit/e24f9a704c22c72690bc20c498439865181d9239))
727732
* Correct multiple instances of 'stragegy' typo ([#3906](https://github.com/ory/hydra/issues/3906)) ([50eefbc](https://github.com/ory/hydra/commit/50eefbc21c2c43d221b6079bbd78a33ef8c754c4)):
728733

729734
This commit addresses several occurrences where 'strategy' was

client/sdk_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,20 @@ func TestClientSDK(t *testing.T) {
233233
// secret hashes shouldn't change between these PUT calls
234234
require.Equal(t, result1.ClientSecret, result2.ClientSecret)
235235
})
236+
237+
t.Run("case=patch client that has JSONWebKeysURI", func(t *testing.T) {
238+
op := "replace"
239+
path := "/client_name"
240+
value := "test"
241+
242+
client := createTestClient("")
243+
client.SetJwksUri("https://example.org/.well-known/jwks.json")
244+
created, _, err := c.OAuth2API.CreateOAuth2Client(context.Background()).OAuth2Client(client).Execute()
245+
require.NoError(t, err)
246+
client.ClientId = created.ClientId
247+
248+
result, _, err := c.OAuth2API.PatchOAuth2Client(context.Background(), *client.ClientId).JsonPatch([]hydra.JsonPatch{{Op: op, Path: path, Value: value}}).Execute()
249+
require.NoError(t, err)
250+
require.Equal(t, value, pointerx.Deref(result.ClientName))
251+
})
236252
}

client/validator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ func (v *Validator) Validate(ctx context.Context, c *Client) error {
5454
if c.TokenEndpointAuthMethod == "" {
5555
c.TokenEndpointAuthMethod = "client_secret_basic"
5656
} else if c.TokenEndpointAuthMethod == "private_key_jwt" {
57-
if len(c.JSONWebKeysURI) == 0 && c.JSONWebKeys == nil {
57+
if len(c.JSONWebKeysURI) == 0 && c.GetJSONWebKeys() == nil {
5858
return errorsx.WithStack(ErrInvalidClientMetadata.WithHint("When token_endpoint_auth_method is 'private_key_jwt', either jwks or jwks_uri must be set."))
5959
}
6060
if c.TokenEndpointAuthSigningAlgorithm != "" && !isSupportedAuthTokenSigningAlg(c.TokenEndpointAuthSigningAlgorithm) {
6161
return errorsx.WithStack(ErrInvalidClientMetadata.WithHint("Only RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384 and ES512 are supported as algorithms for private key authentication."))
6262
}
6363
}
6464

65-
if len(c.JSONWebKeysURI) > 0 && c.JSONWebKeys != nil {
65+
if len(c.JSONWebKeysURI) > 0 && c.GetJSONWebKeys() != nil {
6666
return errorsx.WithStack(ErrInvalidClientMetadata.WithHint("Fields jwks and jwks_uri can not both be set, you must choose one."))
6767
}
6868

69-
if c.JSONWebKeys != nil && c.JSONWebKeys.JSONWebKeySet != nil {
70-
for _, k := range c.JSONWebKeys.Keys {
69+
if jsonWebKeys := c.GetJSONWebKeys(); jsonWebKeys != nil {
70+
for _, k := range jsonWebKeys.Keys {
7171
if !k.Valid() {
7272
return errorsx.WithStack(ErrInvalidClientMetadata.WithHint("Invalid JSON web key in set."))
7373
}

client/validator_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ func TestValidate(t *testing.T) {
110110
return true
111111
},
112112
},
113+
{
114+
in: &Client{ID: "foo", JSONWebKeys: new(x.JoseJSONWebKeySet), JSONWebKeysURI: "https://example.org/jwks.json"},
115+
check: func(t *testing.T, c *Client) {
116+
assert.Nil(t, c.GetJSONWebKeys())
117+
},
118+
},
113119
{
114120
in: &Client{ID: "foo", PostLogoutRedirectURIs: []string{"https://bar/"}, RedirectURIs: []string{"https://foo/"}},
115121
assertErr: assert.Error,

cmd/cmd_create_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func NewCreateClientsCommand() *cobra.Command {
5757
Short: "Create an OAuth 2.0 Client",
5858
Aliases: []string{"client"},
5959
Args: cobra.NoArgs,
60-
Example: `{{ .CommandPath }} -n "my app" -c http://localhost/cb -g authorization_code -r code -a core,foobar
60+
Example: `{{ .CommandPath }} --name "my app" --redirect-uri http://localhost/cb --grant-type authorization_code --response-type code --scope core,foobar
6161
6262
Use the tool jq (or any other JSON tool) to get the OAuth2 Client ID and Secret:
6363
@@ -74,7 +74,7 @@ the Authorize Code, Implicit, Refresh flow. This command allows settings all fie
7474
7575
To encrypt an auto-generated OAuth2 Client Secret, use flags ` + "`--pgp-key`" + `, ` + "`--pgp-key-url`" + ` or ` + "`--keybase`" + ` flag, for example:
7676
77-
{{ .CommandPath }} -n "my app" -g client_credentials -r token -a core,foobar --keybase keybase_username
77+
{{ .CommandPath }} --name "my app" --grant-type client_credentials --response-type token --scope core,foobar --keybase keybase_username
7878
`,
7979
RunE: func(cmd *cobra.Command, args []string) error {
8080
m, _, err := cliclient.NewClient(cmd)

cmd/cmd_import_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Alternatively:
4747
4848
To encrypt an auto-generated OAuth2 Client Secret, use flags ` + "`--pgp-key`" + `, ` + "`--pgp-key-url`" + ` or ` + "`--keybase`" + ` flag, for example:
4949
50-
{{ .CommandPath }} -n "my app" -g client_credentials -r token -a core,foobar --keybase keybase_username
50+
{{ .CommandPath }} --name "my app" --grant-type client_credentials --response-type token --scope core,foobar --keybase keybase_username
5151
`,
5252
Long: `This command reads in each listed JSON file and imports their contents as a list of OAuth 2.0 Clients.
5353

cmd/cmd_update_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ func NewUpdateClientCmd() *cobra.Command {
2222
Aliases: []string{"client"},
2323
Short: "Update an OAuth 2.0 Client",
2424
Args: cobra.ExactArgs(1),
25-
Example: `{{ .CommandPath }} <client-id-here> -c http://localhost/cb -g authorization_code -r code -a core,foobar
25+
Example: `{{ .CommandPath }} <client-id-here> --redirect-uri http://localhost/cb --grant-type authorization_code --response-type code --scope core,foobar
2626
2727
To encrypt an auto-generated OAuth2 Client Secret, use flags ` + "`--pgp-key`" + `, ` + "`--pgp-key-url`" + ` or ` + "`--keybase`" + ` flag, for example:
2828
29-
{{ .CommandPath }} e6e96aa5-9cd2-4a70-bf56-ad6434c8aaa2 -n "my app" -g client_credentials -r token -a core,foobar --keybase keybase_username
29+
{{ .CommandPath }} e6e96aa5-9cd2-4a70-bf56-ad6434c8aaa2 --name "my app" --grant-type client_credentials --response-type token --scope core,foobar --keybase keybase_username
3030
`,
3131
Long: `This command replaces an OAuth 2.0 Client by its ID. Please be aware that this command replaces the entire client. If only the name flag (-n "my updated app") is provided, the all other fields are updated to their default values.`,
3232
RunE: func(cmd *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)