Skip to content

Commit 0434074

Browse files
committed
add query param to auth redirect URI
1 parent 021c27b commit 0434074

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

cmd/login.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package cmd
33
import (
44
"fmt"
55

6+
"rules-cli/internal/auth"
7+
68
"github.com/fatih/color"
79
"github.com/spf13/cobra"
8-
"rules-cli/internal/auth"
910
)
1011

1112
// loginCmd represents the login command
@@ -17,7 +18,7 @@ var loginCmd = &cobra.Command{
1718
fmt.Println("Starting login process...")
1819

1920
// Call the login function from the auth package
20-
authConfig, err := auth.Login(false)
21+
authConfig, err := auth.Login()
2122
if err != nil {
2223
color.Red("Login failed: %v", err)
2324
return

internal/auth/ensure_auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func EnsureAuthenticated(requireAuth bool) (bool, error) {
1616

1717
color.Yellow("Authentication required.")
1818

19-
_, err := Login(false)
19+
_, err := Login()
2020
if err != nil {
2121
color.Red("Failed to authenticate: %v", err)
2222
return false, err

internal/auth/workos.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,13 @@ func Prompt(question string) (string, error) {
119119
}
120120

121121
// GetAuthUrlForTokenPage returns the auth URL for the token page
122-
func GetAuthUrlForTokenPage(useOnboarding bool) string {
122+
func GetAuthUrlForTokenPage() string {
123123
baseURL := "https://api.workos.com/user_management/authorize"
124124
params := url.Values{}
125125
params.Add("response_type", "code")
126126
params.Add("client_id", viper.GetString("workos_client_id"))
127127

128-
redirectPath := "tokens/callback"
129-
if useOnboarding {
130-
redirectPath = "tokens/onboarding-callback"
131-
}
128+
redirectPath := "tokens/callback?clientName=rules"
132129
params.Add("redirect_uri", fmt.Sprintf("%s%s", viper.GetString("app_url"), redirectPath))
133130

134131
params.Add("state", uuid.New().String())
@@ -198,7 +195,7 @@ func RefreshToken(refreshToken string) (AuthConfig, error) {
198195
}
199196

200197
// Login authenticates using the Continue web flow
201-
func Login(useOnboarding bool) (AuthConfig, error) {
198+
func Login() (AuthConfig, error) {
202199
// If CONTINUE_API_KEY environment variable exists, use that instead
203200
if apiKey := os.Getenv("CONTINUE_API_KEY"); apiKey != "" {
204201
color.Green("Using CONTINUE_API_KEY from environment variables")
@@ -210,7 +207,7 @@ func Login(useOnboarding bool) (AuthConfig, error) {
210207
color.Cyan("\nStarting authentication with Continue...")
211208

212209
// Get auth URL
213-
authURL := GetAuthUrlForTokenPage(useOnboarding)
210+
authURL := GetAuthUrlForTokenPage()
214211
color.Green("Opening browser to sign in at: %s", authURL)
215212
if err := browser.OpenURL(authURL); err != nil {
216213
fmt.Printf("Failed to open browser: %v\n", err)

internal/registry/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func EnsureClientAuth(client *Client, requireAuth bool) (bool, error) {
3737

3838
// Start login flow
3939
color.Yellow("Authentication required to perform this operation.")
40-
authConfig, err := auth.Login(false)
40+
authConfig, err := auth.Login()
4141
if err != nil {
4242
color.Red("Authentication failed: %v", err)
4343
return false, err

0 commit comments

Comments
 (0)