From 84663e3f52d4afa47deb9a3902fa7c92ad42e103 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Fri, 27 Feb 2026 11:46:11 +0530 Subject: [PATCH 1/9] refactor(quickstarts): streamline environment variable setup - Simplified the setup of environment variables in the setupQuickstartCmd function. - Replaced multiple calls to WriteString with fmt.Fprintf for better readability and performance. - Consolidated variable declarations to improve code clarity and reduce redundancy. --- internal/cli/quickstarts.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index 9f585896e..ce05c7edb 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -487,9 +487,7 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { return err } - var appType, baseURL, envFileName string - var callbacks, logoutURLs, origins, webOrigins []string - var defaultPort string + var appType, defaultPort, envFileName string switch inputs.Type { case "vite": @@ -524,7 +522,8 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { return fmt.Errorf("invalid port number: %d (must be between 1024 and 65535)", inputs.Port) } - baseURL = fmt.Sprintf("http://localhost:%d", inputs.Port) + baseURL := fmt.Sprintf("http://localhost:%d", inputs.Port) + var callbacks, logoutURLs, origins, webOrigins []string // Configure URLs based on app type. switch inputs.Type { @@ -585,8 +584,8 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { switch inputs.Type { case "vite": - envContent.WriteString(fmt.Sprintf("VITE_AUTH0_DOMAIN=%s\n", tenant.Domain)) - envContent.WriteString(fmt.Sprintf("VITE_AUTH0_CLIENT_ID=%s\n", a.GetClientID())) + fmt.Fprintf(&envContent, "VITE_AUTH0_DOMAIN=%s\n", tenant.Domain) + fmt.Fprintf(&envContent, "VITE_AUTH0_CLIENT_ID=%s\n", a.GetClientID()) case "nextjs": secret, err := generateState(32) @@ -594,11 +593,11 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { return fmt.Errorf("failed to generate AUTH0_SECRET: %w", err) } - envContent.WriteString(fmt.Sprintf("AUTH0_DOMAIN=%s\n", tenant.Domain)) - envContent.WriteString(fmt.Sprintf("AUTH0_CLIENT_ID=%s\n", a.GetClientID())) - envContent.WriteString(fmt.Sprintf("AUTH0_CLIENT_SECRET=%s\n", a.GetClientSecret())) - envContent.WriteString(fmt.Sprintf("AUTH0_SECRET=%s\n", secret)) - envContent.WriteString(fmt.Sprintf("APP_BASE_URL=%s\n", baseURL)) + fmt.Fprintf(&envContent, "AUTH0_DOMAIN=%s\n", tenant.Domain) + fmt.Fprintf(&envContent, "AUTH0_CLIENT_ID=%s\n", a.GetClientID()) + fmt.Fprintf(&envContent, "AUTH0_CLIENT_SECRET=%s\n", a.GetClientSecret()) + fmt.Fprintf(&envContent, "AUTH0_SECRET=%s\n", secret) + fmt.Fprintf(&envContent, "APP_BASE_URL=%s\n", baseURL) case "fastify": sessionSecret, err := generateState(64) @@ -606,11 +605,11 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { return fmt.Errorf("failed to generate SESSION_SECRET: %w", err) } - envContent.WriteString(fmt.Sprintf("AUTH0_DOMAIN=%s\n", tenant.Domain)) - envContent.WriteString(fmt.Sprintf("AUTH0_CLIENT_ID=%s\n", a.GetClientID())) - envContent.WriteString(fmt.Sprintf("AUTH0_CLIENT_SECRET=%s\n", a.GetClientSecret())) - envContent.WriteString(fmt.Sprintf("SESSION_SECRET=%s\n", sessionSecret)) - envContent.WriteString(fmt.Sprintf("APP_BASE_URL=%s\n", baseURL)) + fmt.Fprintf(&envContent, "AUTH0_DOMAIN=%s\n", tenant.Domain) + fmt.Fprintf(&envContent, "AUTH0_CLIENT_ID=%s\n", a.GetClientID()) + fmt.Fprintf(&envContent, "AUTH0_CLIENT_SECRET=%s\n", a.GetClientSecret()) + fmt.Fprintf(&envContent, "SESSION_SECRET=%s\n", sessionSecret) + fmt.Fprintf(&envContent, "APP_BASE_URL=%s\n", baseURL) } message := fmt.Sprintf(" Proceed to overwrite '%s' file? : ", envFileName) From 0b44f944e99c7c63b3237a9fb1531bfa7f9fa4ec Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Fri, 27 Feb 2026 12:46:08 +0530 Subject: [PATCH 2/9] feat(quickstarts): add JHipster RWA support to quickstart setup - Updated the quickstart setup command to support JHipster Regular Web App. - Enhanced the help text to include "jhipster-rwa" as a valid quickstart type. - Added default port 8080 for JHipster applications. - Modified the application name prompt to default to "JHipster" for JHipster RWA. - Adjusted environment variable setup for JHipster applications. - Updated error messages to reflect the new supported quickstart types. --- internal/cli/quickstarts.go | 84 ++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index ce05c7edb..3ad279aa5 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -8,6 +8,7 @@ import ( "path" "path/filepath" "regexp" + "strconv" "strings" "github.com/auth0/go-auth0/management" @@ -420,7 +421,7 @@ var ( Name: "Type", LongForm: "type", ShortForm: "t", - Help: "Type of quickstart (vite, nextjs)", + Help: "Type of quickstart (vite, nextjs, fastify, jhipster-rwa)", IsRequired: true, } qsAppName = Flag{ @@ -433,7 +434,7 @@ var ( Name: "Port", LongForm: "port", ShortForm: "p", - Help: "Port number for the application (default: 5173 for vite, 3000 for nextjs/fastify)", + Help: "Port number for the application (default: 5173 for vite, 3000 for nextjs/fastify, 8080 for jhipster-rwa)", } ) @@ -456,24 +457,26 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { "Supported types:\n" + " - vite: For client-side SPAs (React, Vue, Svelte, etc.)\n" + " - nextjs: For Next.js server-side applications\n" + - " - fastify: For Fastify web applications", + " - fastify: For Fastify web applications\n" + + " - jhipster-rwa: For JHipster regular web applications", Example: ` auth0 quickstarts setup --type vite auth0 quickstarts setup --type nextjs auth0 quickstarts setup --type fastify auth0 quickstarts setup --type vite --name "My App" auth0 quickstarts setup --type nextjs --port 8080 + auth0 quickstarts setup --type jhipster-rwa auth0 qs setup --type fastify -n "My App" -p 3000`, RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() if inputs.Type != "" { normalizedType := strings.ToLower(inputs.Type) - if normalizedType != "vite" && normalizedType != "nextjs" && normalizedType != "fastify" { - return fmt.Errorf("unsupported quickstart type: %s (supported types: vite, nextjs, fastify)", inputs.Type) + if normalizedType != "vite" && normalizedType != "nextjs" && normalizedType != "fastify" && normalizedType != "jhipster-rwa" { + return fmt.Errorf("unsupported quickstart type: %s (supported types: vite, nextjs, fastify, jhipster-rwa)", inputs.Type) } } - if err := qsType.Select(cmd, &inputs.Type, []string{"vite", "nextjs", "fastify"}, nil); err != nil { + if err := qsType.Select(cmd, &inputs.Type, []string{"vite", "nextjs", "fastify", "jhipster-rwa"}, nil); err != nil { return err } @@ -481,40 +484,35 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { return fmt.Errorf("authentication required: %w", err) } - defaultName := "My App" - - if err := qsAppName.Ask(cmd, &inputs.Name, &defaultName); err != nil { - return err - } - - var appType, defaultPort, envFileName string + var defaultName string + var defaultPort int switch inputs.Type { case "vite": - appType = appTypeSPA - defaultPort = "5173" - envFileName = ".env" - + defaultName = "My App" + defaultPort = 5173 case "nextjs", "fastify": - appType = appTypeRegularWeb - defaultPort = "3000" - envFileName = ".env" + defaultName = "My App" + defaultPort = 3000 + case "jhipster-rwa": + defaultName = "JHipster" + defaultPort = 8080 } - // If port is not explicitly set (is 0), ask for it or use default. - if inputs.Port == 0 { - if err := qsPort.Ask(cmd, &inputs.Port, &defaultPort); err != nil { + // If name is not explicitly set, ask for it or use default. + if inputs.Name == "" { + inputs.Name = defaultName + if err := qsAppName.Ask(cmd, &inputs.Name, &defaultName); err != nil { return err } } - // If port is still 0 after asking (e.g., in non-interactive mode), use the default. + // If port is not explicitly set (is 0), ask for it or use default. if inputs.Port == 0 { - switch inputs.Type { - case "vite": - inputs.Port = 5173 - case "nextjs", "fastify": - inputs.Port = 3000 + inputs.Port = defaultPort + defaultPortStr := strconv.Itoa(defaultPort) + if err := qsPort.Ask(cmd, &inputs.Port, &defaultPortStr); err != nil { + return err } } @@ -523,23 +521,32 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { } baseURL := fmt.Sprintf("http://localhost:%d", inputs.Port) + var appType string var callbacks, logoutURLs, origins, webOrigins []string // Configure URLs based on app type. switch inputs.Type { case "vite": + appType = appTypeSPA callbacks = []string{baseURL} logoutURLs = []string{baseURL} origins = []string{baseURL} webOrigins = []string{baseURL} case "nextjs": + appType = appTypeRegularWeb callbackURL := fmt.Sprintf("%s/api/auth/callback", baseURL) callbacks = []string{callbackURL} logoutURLs = []string{baseURL} case "fastify": + appType = appTypeRegularWeb callbackURL := fmt.Sprintf("%s/auth/callback", baseURL) callbacks = []string{callbackURL} logoutURLs = []string{baseURL} + case "jhipster-rwa": + appType = appTypeRegularWeb + callbackURL := fmt.Sprintf("%s/login/oauth2/code/oidc", baseURL) + callbacks = []string{callbackURL} + logoutURLs = []string{baseURL} } cli.renderer.Infof("Creating Auth0 application '%s'...", inputs.Name) @@ -610,8 +617,14 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { fmt.Fprintf(&envContent, "AUTH0_CLIENT_SECRET=%s\n", a.GetClientSecret()) fmt.Fprintf(&envContent, "SESSION_SECRET=%s\n", sessionSecret) fmt.Fprintf(&envContent, "APP_BASE_URL=%s\n", baseURL) + + case "jhipster-rwa": + fmt.Fprintf(&envContent, "AUTH0_DOMAIN=%s\n", tenant.Domain) + fmt.Fprintf(&envContent, "AUTH0_CLIENT_ID=%s\n", a.GetClientID()) + fmt.Fprintf(&envContent, "AUTH0_CLIENT_SECRET=%s\n", a.GetClientSecret()) } + envFileName := ".env" message := fmt.Sprintf(" Proceed to overwrite '%s' file? : ", envFileName) if shouldCancelOverwrite(cli, cmd, envFileName, message) { cli.renderer.Warnf("Aborted creating %s file. Please create it manually using the following content:\n\n"+ @@ -625,10 +638,15 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { cli.renderer.Infof("%s file created successfully with your Auth0 configuration\n", envFileName) } - cli.renderer.Infof("Next steps: \n"+ - " 1. Install dependencies: npm install \n"+ - " 2. Start your application: npm run dev\n"+ - " 3. Open your browser at %s", baseURL) + switch inputs.Type { + case "jhipster-rwa": + cli.renderer.Infof("Created Jhipster RWA application") + default: + cli.renderer.Infof("Next steps: \n"+ + " 1. Install dependencies: npm install \n"+ + " 2. Start your application: npm run dev\n"+ + " 3. Open your browser at %s", baseURL) + } return nil }, From d5612aabc22c2c74d40b0ceb6049830d16613206 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Fri, 27 Feb 2026 18:04:59 +0530 Subject: [PATCH 3/9] feat(quickstarts): updated the output message for JHipster RWA application creation to provide detailed next steps - Included commands for configuring OAUTH2 parameters and managing connections, roles, and actions. - This change improves user guidance for integrating JHipster with Auth0, ensuring a smoother setup process. --- internal/cli/quickstarts.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index 3ad279aa5..ff702f1ee 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -640,7 +640,19 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { switch inputs.Type { case "jhipster-rwa": - cli.renderer.Infof("Created Jhipster RWA application") + cli.renderer.Infof("Next steps: \n" + + " Utilize generated envs to set JHipster OAUTH2 params\n" + + " Refer to the JHipster documentation https://www.jhipster.tech/security/#auth0 to configure additional resources required for integration.\n" + + " Here are some commands that might be helpful :\n\n" + + " `auth0 api connections` to list available connections. Look for connection-id of the required connection by name (eg:Username-Password-Authentication).\n" + + " `auth0 api patch \"connections//clients\" --data '[{\"client_id\": \"\",\"status\": true}]'` to enable connection for the application.\n" + + " `auth0 roles create --name --description ` to create new role.\n" + + " `auth0 users create --email --password --connection-name ` to create a user.\n" + + " `auth0 users roles add --roles ` to assign roles to a user.\n" + + " `auth0 actions create --name --trigger --code ` to create a new action.\n" + + " `auth0 actions deploy ` to deploy the action.\n" + + " `auth0 api patch \"actions/triggers//bindings\" --data '{\"bindings\":[{\"ref\":{\"type\":\"action_id\",\"value\":\"\"}}]}'` to bind the action to post-login trigger.\n") + return nil default: cli.renderer.Infof("Next steps: \n"+ " 1. Install dependencies: npm install \n"+ From ff961694f257d52c4d3c0feb5501f0d5c4ec7c1a Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Fri, 27 Feb 2026 18:05:28 +0530 Subject: [PATCH 4/9] Revert "feat(quickstarts): updated the output message for JHipster RWA application creation to provide detailed next steps" This reverts commit d5612aabc22c2c74d40b0ceb6049830d16613206. --- internal/cli/quickstarts.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index ff702f1ee..3ad279aa5 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -640,19 +640,7 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { switch inputs.Type { case "jhipster-rwa": - cli.renderer.Infof("Next steps: \n" + - " Utilize generated envs to set JHipster OAUTH2 params\n" + - " Refer to the JHipster documentation https://www.jhipster.tech/security/#auth0 to configure additional resources required for integration.\n" + - " Here are some commands that might be helpful :\n\n" + - " `auth0 api connections` to list available connections. Look for connection-id of the required connection by name (eg:Username-Password-Authentication).\n" + - " `auth0 api patch \"connections//clients\" --data '[{\"client_id\": \"\",\"status\": true}]'` to enable connection for the application.\n" + - " `auth0 roles create --name --description ` to create new role.\n" + - " `auth0 users create --email --password --connection-name ` to create a user.\n" + - " `auth0 users roles add --roles ` to assign roles to a user.\n" + - " `auth0 actions create --name --trigger --code ` to create a new action.\n" + - " `auth0 actions deploy ` to deploy the action.\n" + - " `auth0 api patch \"actions/triggers//bindings\" --data '{\"bindings\":[{\"ref\":{\"type\":\"action_id\",\"value\":\"\"}}]}'` to bind the action to post-login trigger.\n") - return nil + cli.renderer.Infof("Created Jhipster RWA application") default: cli.renderer.Infof("Next steps: \n"+ " 1. Install dependencies: npm install \n"+ From e34e9753528484d62a7848ef7ff9e11420bdee59 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Fri, 27 Feb 2026 18:06:40 +0530 Subject: [PATCH 5/9] feat(quickstarts): change environment variable names for JHipster RWA support to align with Jhipster OAuth2 standards. --- internal/cli/quickstarts.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index 3ad279aa5..9792e9563 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -619,9 +619,10 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { fmt.Fprintf(&envContent, "APP_BASE_URL=%s\n", baseURL) case "jhipster-rwa": - fmt.Fprintf(&envContent, "AUTH0_DOMAIN=%s\n", tenant.Domain) - fmt.Fprintf(&envContent, "AUTH0_CLIENT_ID=%s\n", a.GetClientID()) - fmt.Fprintf(&envContent, "AUTH0_CLIENT_SECRET=%s\n", a.GetClientSecret()) + fmt.Fprintf(&envContent, "SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=https://%s/\n", tenant.Domain) + fmt.Fprintf(&envContent, "SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=%s\n", a.GetClientID()) + fmt.Fprintf(&envContent, "SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=%s\n", a.GetClientSecret()) + fmt.Fprintf(&envContent, "JHIPSTER_SECURITY_OAUTH2_AUDIENCE=https://%s/api/v2/\n", tenant.Domain) } envFileName := ".env" From cb56faffce56b5ef5c315b071b3c032538856af5 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Fri, 27 Feb 2026 18:11:45 +0530 Subject: [PATCH 6/9] feat(quickstarts): change the output message for JHipster RWA application creation to direct users to the JHipster documentation for completing the setup. --- internal/cli/quickstarts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index 9792e9563..1eb8cfadb 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -641,7 +641,7 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { switch inputs.Type { case "jhipster-rwa": - cli.renderer.Infof("Created Jhipster RWA application") + cli.renderer.Infof("Please refer to the JHipster documentation https://www.jhipster.tech/security/#auth0 to complete the setup") default: cli.renderer.Infof("Next steps: \n"+ " 1. Install dependencies: npm install \n"+ From 679c4ef2eea15e527f5fd8b320295317b4fb6730 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Fri, 27 Feb 2026 18:28:49 +0530 Subject: [PATCH 7/9] feat(quickstarts): update help text for application name flag - Changed the help message for the "Name" flag in the quickstarts command. - The new message specifies default names for specific frameworks: - 'My App' for vite, nextjs, and fastify - 'JHipster' for jhipster-rwa - This enhancement provides clearer guidance to users on expected input. --- internal/cli/quickstarts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index 1eb8cfadb..60ec69756 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -428,7 +428,7 @@ var ( Name: "Name", LongForm: "name", ShortForm: "n", - Help: "Name of the Auth0 application (defaults to current directory name)", + Help: "Name of the Auth0 application (default: 'My App' for vite, nextjs and fastify, 'JHipster' for jhipster-rwa)", } qsPort = Flag{ Name: "Port", From 6355b8b3633fbf95f6e018f6872c9bdf46e677cc Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Fri, 27 Feb 2026 18:53:32 +0530 Subject: [PATCH 8/9] feat(quickstarts): add jhipster-rwa support to setup documentation --- docs/auth0_quickstarts_setup.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/auth0_quickstarts_setup.md b/docs/auth0_quickstarts_setup.md index bb286329d..c7a158fb1 100644 --- a/docs/auth0_quickstarts_setup.md +++ b/docs/auth0_quickstarts_setup.md @@ -16,6 +16,7 @@ Supported types: - vite: For client-side SPAs (React, Vue, Svelte, etc.) - nextjs: For Next.js server-side applications - fastify: For Fastify web applications + - jhipster-rwa: For JHipster regular web applications ## Usage ``` @@ -30,6 +31,7 @@ auth0 quickstarts setup [flags] auth0 quickstarts setup --type fastify auth0 quickstarts setup --type vite --name "My App" auth0 quickstarts setup --type nextjs --port 8080 + auth0 quickstarts setup --type jhipster-rwa auth0 qs setup --type fastify -n "My App" -p 3000 ``` @@ -38,9 +40,9 @@ auth0 quickstarts setup [flags] ``` --json Output in json format. - -n, --name string Name of the Auth0 application (defaults to current directory name) - -p, --port int Port number for the application (default: 5173 for vite, 3000 for nextjs/fastify) - -t, --type string Type of quickstart (vite, nextjs) + -n, --name string Name of the Auth0 application (default: 'My App' for vite, nextjs and fastify, 'JHipster' for jhipster-rwa) + -p, --port int Port number for the application (default: 5173 for vite, 3000 for nextjs/fastify, 8080 for jhipster-rwa) + -t, --type string Type of quickstart (vite, nextjs, fastify, jhipster-rwa) ``` From 422c5663551b103af5ba4f6fb849aa591aea2b41 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Date: Tue, 3 Mar 2026 09:11:06 +0530 Subject: [PATCH 9/9] feat(quickstarts): update environment file naming for JHipster RWA to ".auth0.env". --- internal/cli/quickstarts.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index 60ec69756..d9978fc24 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -484,22 +484,20 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { return fmt.Errorf("authentication required: %w", err) } - var defaultName string + defaultName := "My App" var defaultPort int switch inputs.Type { case "vite": - defaultName = "My App" defaultPort = 5173 case "nextjs", "fastify": - defaultName = "My App" defaultPort = 3000 case "jhipster-rwa": defaultName = "JHipster" defaultPort = 8080 } - // If name is not explicitly set, ask for it or use default. + // If name is not explicitly set (is empty), ask for it or use default. if inputs.Name == "" { inputs.Name = defaultName if err := qsAppName.Ask(cmd, &inputs.Name, &defaultName); err != nil { @@ -521,7 +519,7 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { } baseURL := fmt.Sprintf("http://localhost:%d", inputs.Port) - var appType string + appType := appTypeRegularWeb var callbacks, logoutURLs, origins, webOrigins []string // Configure URLs based on app type. @@ -533,17 +531,14 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { origins = []string{baseURL} webOrigins = []string{baseURL} case "nextjs": - appType = appTypeRegularWeb callbackURL := fmt.Sprintf("%s/api/auth/callback", baseURL) callbacks = []string{callbackURL} logoutURLs = []string{baseURL} case "fastify": - appType = appTypeRegularWeb callbackURL := fmt.Sprintf("%s/auth/callback", baseURL) callbacks = []string{callbackURL} logoutURLs = []string{baseURL} case "jhipster-rwa": - appType = appTypeRegularWeb callbackURL := fmt.Sprintf("%s/login/oauth2/code/oidc", baseURL) callbacks = []string{callbackURL} logoutURLs = []string{baseURL} @@ -587,6 +582,7 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { return fmt.Errorf("failed to get tenant: %w", err) } + envFileName := ".env" var envContent strings.Builder switch inputs.Type { @@ -619,13 +615,13 @@ func setupQuickstartCmd(cli *cli) *cobra.Command { fmt.Fprintf(&envContent, "APP_BASE_URL=%s\n", baseURL) case "jhipster-rwa": + envFileName = ".auth0.env" fmt.Fprintf(&envContent, "SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=https://%s/\n", tenant.Domain) fmt.Fprintf(&envContent, "SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=%s\n", a.GetClientID()) fmt.Fprintf(&envContent, "SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=%s\n", a.GetClientSecret()) fmt.Fprintf(&envContent, "JHIPSTER_SECURITY_OAUTH2_AUDIENCE=https://%s/api/v2/\n", tenant.Domain) } - envFileName := ".env" message := fmt.Sprintf(" Proceed to overwrite '%s' file? : ", envFileName) if shouldCancelOverwrite(cli, cmd, envFileName, message) { cli.renderer.Warnf("Aborted creating %s file. Please create it manually using the following content:\n\n"+