Skip to content

Commit 56ac07d

Browse files
authored
MRRT (#1192)
* MRRT * updated go sum * updated go auth0 version * fixed lint
1 parent 28146e8 commit 56ac07d

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

docs/auth0_apps_create.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ auth0 apps create [flags]
4343
--metadata stringToString Arbitrary keys-value pairs (max 255 characters each), that can be assigned to each application. More about application metadata: https://auth0.com/docs/get-started/applications/configure-application-metadata (default [])
4444
-n, --name string Name of the application.
4545
-o, --origins strings Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level (e.g., https://*.contoso.com). Query strings and hash information are not taken into account when validating these URLs.
46+
-z, --refresh-token string Refresh Token Config for the application, formatted as JSON.
4647
-r, --reveal-secrets Display the application secrets ('signing_keys', 'client_secret') as part of the command output.
4748
-t, --type string Type of application:
4849
- native: mobile, desktop, CLI and smart device apps running natively.

docs/auth0_apps_update.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ auth0 apps update [flags]
4343
--metadata stringToString Arbitrary keys-value pairs (max 255 characters each), that can be assigned to each application. More about application metadata: https://auth0.com/docs/get-started/applications/configure-application-metadata (default [])
4444
-n, --name string Name of the application.
4545
-o, --origins strings Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level (e.g., https://*.contoso.com). Query strings and hash information are not taken into account when validating these URLs.
46+
-z, --refresh-token string Refresh Token Config for the application, formatted as JSON.
4647
-r, --reveal-secrets Display the application secrets ('signing_keys', 'client_secret') as part of the command output.
4748
-t, --type string Type of application:
4849
- native: mobile, desktop, CLI and smart device apps running natively.

go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/AlecAivazis/survey/v2 v2.3.7
1010
github.com/PuerkitoBio/rehttp v1.4.0
1111
github.com/atotto/clipboard v0.1.4
12-
github.com/auth0/go-auth0 v1.19.0
12+
github.com/auth0/go-auth0 v1.20.0
1313
github.com/briandowns/spinner v1.23.2
1414
github.com/charmbracelet/glamour v0.10.0
1515
github.com/fsnotify/fsnotify v1.9.0
@@ -78,9 +78,11 @@ require (
7878
github.com/klauspost/pgzip v1.2.5 // indirect
7979
github.com/kr/text v0.2.0 // indirect
8080
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
81-
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
81+
github.com/lestrrat-go/blackmagic v1.0.3 // indirect
8282
github.com/lestrrat-go/httpcc v1.0.1 // indirect
83+
github.com/lestrrat-go/httprc v1.0.6 // indirect
8384
github.com/lestrrat-go/iter v1.0.2 // indirect
85+
github.com/lestrrat-go/jwx/v2 v2.1.6 // indirect
8486
github.com/lestrrat-go/option v1.0.1 // indirect
8587
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
8688
github.com/mattn/go-colorable v0.1.13 // indirect
@@ -94,6 +96,7 @@ require (
9496
github.com/pierrec/lz4/v4 v4.1.3 // indirect
9597
github.com/pmezard/go-difflib v1.0.0 // indirect
9698
github.com/rivo/uniseg v0.4.7 // indirect
99+
github.com/segmentio/asm v1.2.0 // indirect
97100
github.com/ulikunitz/xz v0.5.10 // indirect
98101
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
99102
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect

go.sum

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew
2727
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
2828
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
2929
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
30-
github.com/auth0/go-auth0 v1.19.0 h1:LZAVZCiZsENm0wX/PvRwN+mLbyCb4PPCfyKww8b7KR4=
31-
github.com/auth0/go-auth0 v1.19.0/go.mod h1:6g0NRYWA+rzTLG5AohwCJ0YCEqbzphKcdjt+PWrgcPk=
30+
github.com/auth0/go-auth0 v1.20.0 h1:qCp5e2Jyeo7Z6vSTAgZqT8kYI6fVFzvT7rUBOtgSrIM=
31+
github.com/auth0/go-auth0 v1.20.0/go.mod h1:inNY8nV/wANajcJ8B/93CLlmXgyMgyuyPXXI4kgd2qY=
3232
github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48=
3333
github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0/go.mod h1:6L7zgvqo0idzI7IO8de6ZC051AfXb5ipkIJ7bIA2tGA=
3434
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
@@ -159,14 +159,18 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
159159
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
160160
github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A=
161161
github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y=
162-
github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k=
163-
github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
162+
github.com/lestrrat-go/blackmagic v1.0.3 h1:94HXkVLxkZO9vJI/w2u1T0DAoprShFd13xtnSINtDWs=
163+
github.com/lestrrat-go/blackmagic v1.0.3/go.mod h1:6AWFyKNNj0zEXQYfTMPfZrAXUWUfTIZ5ECEUEJaijtw=
164164
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
165165
github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E=
166+
github.com/lestrrat-go/httprc v1.0.6 h1:qgmgIRhpvBqexMJjA/PmwSvhNk679oqD1RbovdCGW8k=
167+
github.com/lestrrat-go/httprc v1.0.6/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo=
166168
github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=
167169
github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4=
168170
github.com/lestrrat-go/jwx v1.2.30 h1:VKIFrmjYn0z2J51iLPadqoHIVLzvWNa1kCsTqNDHYPA=
169171
github.com/lestrrat-go/jwx v1.2.30/go.mod h1:vMxrwFhunGZ3qddmfmEm2+uced8MSI6QFWGTKygjSzQ=
172+
github.com/lestrrat-go/jwx/v2 v2.1.6 h1:hxM1gfDILk/l5ylers6BX/Eq1m/pnxe9NBwW6lVfecA=
173+
github.com/lestrrat-go/jwx/v2 v2.1.6/go.mod h1:Y722kU5r/8mV7fYDifjug0r8FK8mZdw0K0GpJw/l8pU=
170174
github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
171175
github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU=
172176
github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
@@ -222,6 +226,8 @@ github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6po
222226
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
223227
github.com/schollz/progressbar/v3 v3.17.1 h1:bI1MTaoQO+v5kzklBjYNRQLoVpe0zbyRZNK6DFkVC5U=
224228
github.com/schollz/progressbar/v3 v3.17.1/go.mod h1:RzqpnsPQNjUyIgdglUjRLgD7sVnxN1wpmBMV+UiEbL4=
229+
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
230+
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
225231
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
226232
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
227233
github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY=

internal/cli/apps.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"context"
5+
"encoding/json"
56
"errors"
67
"fmt"
78
"slices"
@@ -134,6 +135,12 @@ var (
134135
ShortForm: "n",
135136
Help: "Number of apps to retrieve. Minimum 1, maximum 1000.",
136137
}
138+
refreshToken = Flag{
139+
Name: "Refresh Token",
140+
LongForm: "refresh-token",
141+
ShortForm: "z",
142+
Help: "Refresh Token Config for the application, formatted as JSON.",
143+
}
137144
)
138145

139146
func appsCmd(cli *cli) *cobra.Command {
@@ -384,6 +391,7 @@ func createAppCmd(cli *cli) *cobra.Command {
384391
Grants []string
385392
RevealSecrets bool
386393
Metadata map[string]string
394+
RefreshToken string
387395
}
388396
var oidcConformant = true
389397
var algorithm = "RS256"
@@ -484,6 +492,12 @@ func createAppCmd(cli *cli) *cobra.Command {
484492
ClientMetadata: &clientMetadata,
485493
}
486494

495+
if len(inputs.RefreshToken) != 0 {
496+
if err := json.Unmarshal([]byte(inputs.RefreshToken), &a.RefreshToken); err != nil {
497+
return fmt.Errorf("apps: %s refreshToken invalid JSON", err)
498+
}
499+
}
500+
487501
// Set token endpoint auth method.
488502
if len(inputs.AuthMethod) == 0 {
489503
a.TokenEndpointAuthMethod = apiDefaultAuthMethodFor(inputs.Type)
@@ -527,6 +541,7 @@ func createAppCmd(cli *cli) *cobra.Command {
527541
appAuthMethod.RegisterString(cmd, &inputs.AuthMethod, "")
528542
appGrants.RegisterStringSlice(cmd, &inputs.Grants, nil)
529543
revealSecrets.RegisterBool(cmd, &inputs.RevealSecrets, false)
544+
refreshToken.RegisterString(cmd, &inputs.RefreshToken, "")
530545

531546
return cmd
532547
}
@@ -545,6 +560,7 @@ func updateAppCmd(cli *cli) *cobra.Command {
545560
Grants []string
546561
RevealSecrets bool
547562
Metadata map[string]string
563+
RefreshToken string
548564
}
549565

550566
cmd := &cobra.Command{
@@ -722,6 +738,14 @@ func updateAppCmd(cli *cli) *cobra.Command {
722738
a.ClientMetadata = &clientMetadata
723739
}
724740

741+
if len(inputs.RefreshToken) == 0 {
742+
a.RefreshToken = current.RefreshToken
743+
} else {
744+
if err := json.Unmarshal([]byte(inputs.RefreshToken), &a.RefreshToken); err != nil {
745+
return fmt.Errorf("apps: %s refreshToken invalid JSON", err)
746+
}
747+
}
748+
725749
if err := ansi.Waiting(func() error {
726750
return cli.api.Client.Update(cmd.Context(), inputs.ID, a)
727751
}); err != nil {
@@ -746,6 +770,7 @@ func updateAppCmd(cli *cli) *cobra.Command {
746770
appAuthMethod.RegisterStringU(cmd, &inputs.AuthMethod, "")
747771
appGrants.RegisterStringSliceU(cmd, &inputs.Grants, nil)
748772
revealSecrets.RegisterBool(cmd, &inputs.RevealSecrets, false)
773+
refreshToken.RegisterString(cmd, &inputs.RefreshToken, "")
749774

750775
return cmd
751776
}

internal/display/apps.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package display
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"strings"
67

@@ -35,6 +36,7 @@ type applicationView struct {
3536
AuthMethod string
3637
Grants []string
3738
Metadata []string
39+
RefreshToken string
3840
revealSecret bool
3941

4042
raw interface{}
@@ -85,6 +87,7 @@ func (v *applicationView) KeyValues() [][]string {
8587
{"TOKEN ENDPOINT AUTH", v.AuthMethod},
8688
{"GRANTS", grants},
8789
{"METADATA", metadata},
90+
{"REFRESH TOKEN", v.RefreshToken},
8891
}
8992
}
9093

@@ -100,6 +103,7 @@ func (v *applicationView) KeyValues() [][]string {
100103
{"TOKEN ENDPOINT AUTH", v.AuthMethod},
101104
{"GRANTS", grants},
102105
{"METADATA", metadata},
106+
{"REFRESH TOKEN", v.RefreshToken},
103107
}
104108
}
105109

@@ -167,6 +171,8 @@ func (r *Renderer) ApplicationUpdate(client *management.Client, revealSecrets bo
167171
}
168172

169173
func makeApplicationView(client *management.Client, revealSecrets bool) *applicationView {
174+
jsonRefreshToken, _ := json.Marshal(client.GetRefreshToken())
175+
170176
return &applicationView{
171177
revealSecret: revealSecrets,
172178
Name: client.GetName(),
@@ -182,6 +188,7 @@ func makeApplicationView(client *management.Client, revealSecrets bool) *applica
182188
Grants: client.GetGrantTypes(),
183189
Metadata: mapPointerToArray(client.ClientMetadata),
184190
raw: client,
191+
RefreshToken: string(jsonRefreshToken),
185192
}
186193
}
187194

0 commit comments

Comments
 (0)