Skip to content

Commit

Permalink
fix: github login
Browse files Browse the repository at this point in the history
  * seperate domain and audience and authenticator constructor
  * use custom auth0 domain for authenticator
  • Loading branch information
moroderNumerous committed Jun 13, 2024
1 parent 54b5dea commit e9e4cc0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cli/auth/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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/",
Expand Down
2 changes: 1 addition & 1 deletion cli/auth/device_code_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion cli/auth/revoke_refresh_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 2 additions & 1 deletion cli/auth/settings.go
Original file line number Diff line number Diff line change
@@ -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"
)
1 change: 0 additions & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func bindCommands() {

func Execute() {
err := rootCmd.Execute()
// fmt.Println(auth.NumerousTenantAuthenticator.GetLoggedInUserFromKeyring().AccessToken)
if err != nil {
os.Exit(1)
}
Expand Down

0 comments on commit e9e4cc0

Please sign in to comment.