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

Prompt for allowed origins on SPA creation/update [CLI-105] #203

Merged
merged 1 commit into from
Mar 27, 2021
Merged
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions internal/cli/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var (
ShortForm: "o",
Help: "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.",
IsRequired: false,
AlwaysPrompt: true,
}
appWebOrigins = Flag{
Name: "Allowed Web Origin URLs",
Expand Down Expand Up @@ -305,6 +306,15 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m]
}
}

// Prompt for allowed origins URLs if app is SPA
if appIsSPA {
defaultValue := appDefaultURL

if err := appOrigins.AskMany(cmd, &inputs.AllowedOrigins, &defaultValue); err != nil {
return err
}
}

// Prompt for allowed web origins URLs if app is SPA
if appIsSPA {
defaultValue := appDefaultURL
Expand Down Expand Up @@ -458,6 +468,19 @@ auth0 apps update <id> --name myapp --type [native|spa|regular|m2m]
}
}

// Prompt for allowed origins URLs if app is SPA
if appIsSPA {
defaultValue := appDefaultURL

if len(current.AllowedOrigins) > 0 {
defaultValue = stringSliceToCommaSeparatedString(interfaceToStringSlice(current.AllowedOrigins))
}

if err := appOrigins.AskManyU(cmd, &inputs.AllowedOrigins, &defaultValue); err != nil {
return err
}
}

// Prompt for allowed web origins URLs if app is SPA
if appIsSPA {
defaultValue := appDefaultURL
Expand Down