Skip to content

Commit

Permalink
feat: add id parameter to create oauth2-client cli
Browse files Browse the repository at this point in the history
fixes #3724
  • Loading branch information
inigohu committed Feb 28, 2024
1 parent 0421fda commit cf75dcc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/cmd_create_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
flagClientAllowedCORSOrigin = "allowed-cors-origin"
flagClientAudience = "audience"
flagClientBackchannelLogoutCallback = "backchannel-logout-callback"
flagClientId = "id"
flagClientName = "name"
flagClientClientURI = "client-uri"
flagClientContact = "contact"
Expand Down
2 changes: 2 additions & 0 deletions cmd/cmd_helper_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func clientFromFlags(cmd *cobra.Command) hydra.OAuth2Client {
Audience: flagx.MustGetStringSlice(cmd, flagClientAudience),
BackchannelLogoutSessionRequired: pointerx.Bool(flagx.MustGetBool(cmd, flagClientBackChannelLogoutSessionRequired)),
BackchannelLogoutUri: pointerx.String(flagx.MustGetString(cmd, flagClientBackchannelLogoutCallback)),
ClientId: pointerx.String(flagx.MustGetString(cmd, flagClientId)),
ClientName: pointerx.String(flagx.MustGetString(cmd, flagClientName)),
ClientSecret: pointerx.String(flagx.MustGetString(cmd, flagClientSecret)),
ClientUri: pointerx.String(flagx.MustGetString(cmd, flagClientClientURI)),
Expand Down Expand Up @@ -76,6 +77,7 @@ func registerClientFlags(flags *pflag.FlagSet) {
flags.String(flagClientLogoURI, "", "A URL string that references a logo for the client")
flags.StringSlice(flagClientAllowedCORSOrigin, []string{}, "The list of URLs allowed to make CORS requests. Requires CORS_ENABLED.")
flags.String(flagClientSubjectType, "public", "A identifier algorithm. Valid values are `public` and `pairwise`.")
flags.String(flagClientId, "", "Provide the client's id.")
flags.String(flagClientSecret, "", "Provide the client's secret.")
flags.String(flagClientName, "", "The client's name.")
flags.StringSlice(flagClientPostLogoutCallback, []string{}, "List of allowed URLs to be redirected to after a logout.")
Expand Down
3 changes: 3 additions & 0 deletions cmd/cmd_update_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ To encrypt an auto-generated OAuth2 Client Secret, use flags ` + "`--pgp-key`" +
}

id := args[0]
if f := cmd.Flag(flagClientId); f.Changed {
return fmt.Errorf("client id cannot be updated")

Check warning on line 46 in cmd/cmd_update_client.go

View check run for this annotation

Codecov / codecov/patch

cmd/cmd_update_client.go#L46

Added line #L46 was not covered by tests
}
cc := clientFromFlags(cmd)

client, _, err := m.OAuth2Api.SetOAuth2Client(context.Background(), id).OAuth2Client(cc).Execute() //nolint:bodyclose
Expand Down

0 comments on commit cf75dcc

Please sign in to comment.