From e9e4cc090223efb2b900ffcc9981f89d7c45b1ef Mon Sep 17 00:00:00 2001 From: Frederik Date: Wed, 12 Jun 2024 16:06:37 +0200 Subject: [PATCH] fix: github login * seperate domain and audience and authenticator constructor * use custom auth0 domain for authenticator --- Makefile | 6 ++++-- cli/auth/authenticator.go | 6 +++--- cli/auth/device_code_state_test.go | 2 +- cli/auth/revoke_refresh_token_test.go | 2 +- cli/auth/settings.go | 3 ++- cli/cmd/root.go | 1 - 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 58e645e..3b963f2 100644 --- a/Makefile +++ b/Makefile @@ -19,13 +19,15 @@ getarch = $(word 4,$(subst _, ,$(subst /, ,$@))) GQL_HTTP_URL = https://api.numerous.com/query GQL_WS_URL = wss://api.numerous.com/query -AUTH0_DOMAIN = numerous.eu.auth0.com +AUTH0_DOMAIN = auth.numerous.com AUTH0_CLIENT_ID = h5U41HhtgJ5OXdIvzi2Aw7VNFQMoLzgF +AUTH0_AUDIENCE = https://numerous.eu.auth0.com/api/v2/ LDFLAGS = -s -w \ -X "numerous/cli/internal/gql.httpURL=$(GQL_HTTP_URL)" \ -X "numerous/cli/internal/gql.wsURL=$(GQL_WS_URL)" \ -X "numerous/cli/auth.auth0Domain=$(AUTH0_DOMAIN)" \ - -X "numerous/cli/auth.auth0ClientID=$(AUTH0_CLIENT_ID)" + -X "numerous/cli/auth.auth0ClientID=$(AUTH0_CLIENT_ID)" \ + -X "numerous/cli/auth.auth0Audience=$(AUTH0_AUDIENCE)" # Python SDK related variables diff --git a/cli/auth/authenticator.go b/cli/auth/authenticator.go index a8400e6..fb94011 100644 --- a/cli/auth/authenticator.go +++ b/cli/auth/authenticator.go @@ -10,7 +10,7 @@ import ( "github.com/pkg/browser" ) -var NumerousTenantAuthenticator = NewTenantAuthenticator(auth0Domain, auth0ClientID) +var NumerousTenantAuthenticator = NewTenantAuthenticator(auth0Domain, auth0ClientID, auth0Audience) type Authenticator interface { GetDeviceCode(ctx context.Context, client *http.Client) (DeviceCodeState, error) @@ -29,13 +29,13 @@ type TenantAuthenticator struct { credentials Credentials } -func NewTenantAuthenticator(tenant string, clientID string) *TenantAuthenticator { +func NewTenantAuthenticator(tenant string, clientID string, audience string) *TenantAuthenticator { baseURL := "https://" + tenant return &TenantAuthenticator{ tenant: tenant, credentials: Credentials{ ClientID: clientID, - Audience: baseURL + "/api/v2/", + Audience: audience, DeviceCodeEndpoint: baseURL + "/oauth/device/code/", OauthTokenEndpoint: baseURL + "/oauth/token/", RevokeTokenEndpoint: baseURL + "/oauth/revoke/", diff --git a/cli/auth/device_code_state_test.go b/cli/auth/device_code_state_test.go index 5916428..fe58b46 100644 --- a/cli/auth/device_code_state_test.go +++ b/cli/auth/device_code_state_test.go @@ -15,7 +15,7 @@ import ( ) func TestGetDeviceCode(t *testing.T) { - testTenant := NewTenantAuthenticator("numerous-test.com", "test-client-id") + testTenant := NewTenantAuthenticator("numerous-test.com", "test-client-id", "numerous-test.com/api/v2/") t.Run("successfully retrieve state from response", func(t *testing.T) { transport := &test.TestTransport{ WithResponse: &http.Response{ diff --git a/cli/auth/revoke_refresh_token_test.go b/cli/auth/revoke_refresh_token_test.go index dd615a5..56dc8ab 100644 --- a/cli/auth/revoke_refresh_token_test.go +++ b/cli/auth/revoke_refresh_token_test.go @@ -13,7 +13,7 @@ import ( ) func TestRevokeRefreshToken(t *testing.T) { - testTenant := NewTenantAuthenticator("numerous-test.com", "test-client-id") + testTenant := NewTenantAuthenticator("numerous-test.com", "test-client-id", "numerous-test.com/api/v2/") t.Run("successfully revoke token", func(t *testing.T) { transport := &test.TestTransport{ WithResponse: &http.Response{ diff --git a/cli/auth/settings.go b/cli/auth/settings.go index c4f9bdb..62eb5d3 100644 --- a/cli/auth/settings.go +++ b/cli/auth/settings.go @@ -1,6 +1,7 @@ package auth var ( - auth0Domain string = "numerous-dev.eu.auth0.com" + auth0Domain string = "dev-auth.numerous.com" + auth0Audience string = "https://numerous-dev.eu.auth0.com/api/v2/" auth0ClientID string = "fzPy9It2ERYZUi4AG5U0vmDSKC7oOxHe" ) diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 4507071..e69089d 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -125,7 +125,6 @@ func bindCommands() { func Execute() { err := rootCmd.Execute() - // fmt.Println(auth.NumerousTenantAuthenticator.GetLoggedInUserFromKeyring().AccessToken) if err != nil { os.Exit(1) }