diff --git a/internal/cli/apps.go b/internal/cli/apps.go index dc6d4e82d..fcdd0899b 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -266,7 +266,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] cmd.Flags().StringVarP(&flags.Description, "description", "d", "", "Description of the application. Max character count is 140.") cmd.Flags().StringSliceVarP(&flags.Callbacks, "callbacks", "c", nil, "After the user authenticates we will only call back to any of these URLs. You can specify multiple valid URLs by comma-separating them (typically to handle different environments like QA or testing). Make sure to specify the protocol (https://) otherwise the callback may fail in some cases. With the exception of custom URI schemes for native apps, all callbacks should use protocol https://.") cmd.Flags().StringSliceVarP(&flags.AllowedOrigins, "origins", "o", nil, "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.") - cmd.Flags().StringSliceVarP(&flags.AllowedOrigins, "web-origins", "w", nil, "Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode.") + cmd.Flags().StringSliceVarP(&flags.AllowedWebOrigins, "web-origins", "w", nil, "Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode.") cmd.Flags().StringSliceVarP(&flags.AllowedLogoutURLs, "logout-urls", "l", nil, "Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains.") cmd.Flags().StringVarP(&flags.AuthMethod, "auth-method", "a", "", "Defines the requested authentication method for the token endpoint. Possible values are 'None' (public application without a client secret), 'Post' (application uses HTTP POST parameters) or 'Basic' (application uses HTTP Basic).") cmd.Flags().StringSliceVarP(&flags.Grants, "grants", "g", nil, "List of grant types supported for this application. Can include code, implicit, refresh-token, credentials, password, password-realm, mfa-oob, mfa-otp, mfa-recovery-code, and device-code.") @@ -446,7 +446,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] cmd.Flags().StringVarP(&inputs.Description, "description", "d", "", "Description of the application. Max character count is 140.") cmd.Flags().StringSliceVarP(&inputs.Callbacks, "callbacks", "c", nil, "After the user authenticates we will only call back to any of these URLs. You can specify multiple valid URLs by comma-separating them (typically to handle different environments like QA or testing). Make sure to specify the protocol (https://) otherwise the callback may fail in some cases. With the exception of custom URI schemes for native apps, all callbacks should use protocol https://.") cmd.Flags().StringSliceVarP(&inputs.AllowedOrigins, "origins", "o", nil, "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.") - cmd.Flags().StringSliceVarP(&inputs.AllowedOrigins, "web-origins", "w", nil, "Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode.") + cmd.Flags().StringSliceVarP(&inputs.AllowedWebOrigins, "web-origins", "w", nil, "Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode.") cmd.Flags().StringSliceVarP(&inputs.AllowedLogoutURLs, "logout-urls", "l", nil, "Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains.") cmd.Flags().StringVarP(&inputs.AuthMethod, "auth-method", "a", "", "Defines the requested authentication method for the token endpoint. Possible values are 'None' (public application without a client secret), 'Post' (application uses HTTP POST parameters) or 'Basic' (application uses HTTP Basic).") cmd.Flags().StringSliceVarP(&inputs.Grants, "grants", "g", nil, "List of grant types supported for this application. Can include code, implicit, refresh-token, credentials, password, password-realm, mfa-oob, mfa-otp, mfa-recovery-code, and device-code.") diff --git a/internal/cli/apps_test.go b/internal/cli/apps_test.go index e998c6dd7..300c07c5f 100644 --- a/internal/cli/apps_test.go +++ b/internal/cli/apps_test.go @@ -49,7 +49,7 @@ func TestClientsListCmd(t *testing.T) { } expectTable(t, stdout.String(), - []string{"NAME", "TYPE", "CLIENT ID"}, + []string{"CLIENT ID", "NAME", "TYPE"}, [][]string{ {"some-name", "generic", "some-id"}, }, diff --git a/internal/display/apps.go b/internal/display/apps.go index 797a13242..b291acfe2 100644 --- a/internal/display/apps.go +++ b/internal/display/apps.go @@ -18,21 +18,50 @@ const ( ) type applicationView struct { - Name string - Type string - ClientID string - ClientSecret string - Callbacks []string - revealSecret bool + Name string + Description string + Type string + ClientID string + ClientSecret string + Callbacks []string + AllowedOrigins []string + AllowedWebOrigins []string + AllowedLogoutURLs []string + AuthMethod string + Grants []string + revealSecret bool raw interface{} } func (v *applicationView) AsTableHeader() []string { if v.revealSecret { - return []string{"Name", "Type", "ClientID", "Client Secret", "Callbacks"} + return []string{ + "ClientID", + "Description", + "Name", + "Type", + "Client Secret", + "Callbacks", + "Allowed Origins", + "Allowed Web Origins", + "Allowed Logout URLs", + "Token Endpoint Auth", + "Grants", + } + } + return []string{ + "Client ID", + "Description", + "Name", + "Type", + "Callbacks", + "Allowed Origins", + "Allowed Web Origins", + "Allowed Logout URLs", + "Token Endpoint Auth", + "Grants", } - return []string{"Name", "Type", "Client ID", "Callbacks"} } func (v *applicationView) AsTableRow() []string { @@ -55,23 +84,37 @@ func (v *applicationView) AsTableRow() []string { func (v *applicationView) KeyValues() [][]string { callbacks := strings.Join(v.Callbacks, ", ") + allowedOrigins := strings.Join(v.AllowedOrigins, ", ") + allowedWebOrigins := strings.Join(v.AllowedWebOrigins, ", ") + allowedLogoutURLs := strings.Join(v.AllowedLogoutURLs, ", ") + grants := strings.Join(v.Grants, ", ") if v.revealSecret { return [][]string{ + []string{"CLIENT ID", ansi.Faint(v.ClientID)}, []string{"NAME", v.Name}, + []string{"DESCRIPTION", v.Description}, []string{"TYPE", v.Type}, - []string{"CLIENT ID", ansi.Faint(v.ClientID)}, []string{"CLIENT SECRET", ansi.Italic(v.ClientSecret)}, []string{"CALLBACKS", callbacks}, + []string{"ALLOWED WEB ORIGINS", allowedWebOrigins}, + []string{"ALLOWED LOGOUT URLS", allowedLogoutURLs}, + []string{"TOKEN ENDPOINT AUTH", v.AuthMethod}, + []string{"GRANTS", grants}, } - } return [][]string{ + []string{"CLIENT ID", ansi.Faint(v.ClientID)}, []string{"NAME", v.Name}, + []string{"DESCRIPTION", v.Description}, []string{"TYPE", v.Type}, - []string{"CLIENT ID", ansi.Faint(v.ClientID)}, []string{"CALLBACKS", callbacks}, + []string{"ALLOWED ORIGINS", allowedOrigins}, + []string{"ALLOWED WEB ORIGINS", allowedWebOrigins}, + []string{"ALLOWED LOGOUT URLS", allowedLogoutURLs}, + []string{"TOKEN ENDPOINT AUTH", v.AuthMethod}, + []string{"GRANTS", grants}, } } @@ -91,10 +134,9 @@ type applicationListView struct { func (v *applicationListView) AsTableHeader() []string { if v.revealSecret { - return []string{"Name", "Type", "ClientID", "Client Secret"} + return []string{"ClientID", "Name", "Type", "Client Secret"} } - return []string{"Name", "Type", "Client ID"} - + return []string{"Client ID", "Name", "Type"} } func (v *applicationListView) AsTableRow() []string { @@ -135,13 +177,19 @@ func (r *Renderer) ApplicationShow(client *management.Client, revealSecrets bool r.Heading(ansi.Bold(r.Tenant), "application\n") v := &applicationView{ - revealSecret: revealSecrets, - Name: auth0.StringValue(client.Name), - Type: appTypeFor(client.AppType), - ClientID: auth0.StringValue(client.ClientID), - ClientSecret: auth0.StringValue(client.ClientSecret), - Callbacks: callbacksFor(client.Callbacks), - raw: client, + revealSecret: revealSecrets, + Name: auth0.StringValue(client.Name), + Description: auth0.StringValue(client.Description), + Type: appTypeFor(client.AppType), + ClientID: auth0.StringValue(client.ClientID), + ClientSecret: auth0.StringValue(client.ClientSecret), + Callbacks: interfaceSliceToString(client.Callbacks), + AllowedOrigins: interfaceSliceToString(client.AllowedOrigins), + AllowedWebOrigins: interfaceSliceToString(client.WebOrigins), + AllowedLogoutURLs: interfaceSliceToString(client.AllowedLogoutURLs), + AuthMethod: auth0.StringValue(client.TokenEndpointAuthMethod), + Grants: interfaceSliceToString(client.GrantTypes), + raw: client, } r.Result(v) @@ -151,16 +199,22 @@ func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bo r.Heading(ansi.Bold(r.Tenant), "application created\n") v := &applicationView{ - revealSecret: revealSecrets, - Name: auth0.StringValue(client.Name), - Type: appTypeFor(client.AppType), - ClientID: auth0.StringValue(client.ClientID), - ClientSecret: auth0.StringValue(client.ClientSecret), - Callbacks: callbacksFor(client.Callbacks), - raw: client, + revealSecret: revealSecrets, + Name: auth0.StringValue(client.Name), + Description: auth0.StringValue(client.Description), + Type: appTypeFor(client.AppType), + ClientID: auth0.StringValue(client.ClientID), + ClientSecret: auth0.StringValue(client.ClientSecret), + Callbacks: interfaceSliceToString(client.Callbacks), + AllowedOrigins: interfaceSliceToString(client.AllowedOrigins), + AllowedWebOrigins: interfaceSliceToString(client.WebOrigins), + AllowedLogoutURLs: interfaceSliceToString(client.AllowedLogoutURLs), + AuthMethod: auth0.StringValue(client.TokenEndpointAuthMethod), + Grants: interfaceSliceToString(client.GrantTypes), + raw: client, } - r.Results([]View{v}) + r.Result(v) r.Infof("\nQuickstarts: %s", quickstartsURIFor(client.AppType)) } @@ -169,16 +223,22 @@ func (r *Renderer) ApplicationUpdate(client *management.Client, revealSecrets bo r.Heading(ansi.Bold(r.Tenant), "application updated\n") v := &applicationView{ - revealSecret: revealSecrets, - Name: auth0.StringValue(client.Name), - Type: appTypeFor(client.AppType), - ClientID: auth0.StringValue(client.ClientID), - ClientSecret: auth0.StringValue(client.ClientSecret), - Callbacks: callbacksFor(client.Callbacks), - raw: client, + revealSecret: revealSecrets, + Name: auth0.StringValue(client.Name), + Description: auth0.StringValue(client.Description), + Type: appTypeFor(client.AppType), + ClientID: auth0.StringValue(client.ClientID), + ClientSecret: auth0.StringValue(client.ClientSecret), + Callbacks: interfaceSliceToString(client.Callbacks), + AllowedOrigins: interfaceSliceToString(client.AllowedOrigins), + AllowedWebOrigins: interfaceSliceToString(client.WebOrigins), + AllowedLogoutURLs: interfaceSliceToString(client.AllowedLogoutURLs), + AuthMethod: auth0.StringValue(client.TokenEndpointAuthMethod), + Grants: interfaceSliceToString(client.GrantTypes), + raw: client, } - r.Results([]View{v}) + r.Result(v) } // TODO(cyx): determine if there's a better way to filter this out. @@ -221,7 +281,7 @@ func quickstartsURIFor(v *string) string { } } -func callbacksFor(s []interface{}) []string { +func interfaceSliceToString(s []interface{}) []string { res := make([]string, len(s)) for i, v := range s { res[i] = fmt.Sprintf("%s", v)