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 12, 2024
1 parent 3b274c0 commit 1403708
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions cli/auth/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
)

const (
numerousAuth0Domain string = "numerous.eu.auth0.com"
numerousAuth0Audience string = "https://numerous.eu.auth0.com/api/v2/"
numerousAuth0Domain string = "authentication.numerous.com"
numerousAuth0ClientID string = "h5U41HhtgJ5OXdIvzi2Aw7VNFQMoLzgF"
)

var NumerousTenantAuthenticator = NewTenantAuthenticator(numerousAuth0Domain, numerousAuth0ClientID)
var NumerousTenantAuthenticator = NewTenantAuthenticator(numerousAuth0Domain, numerousAuth0ClientID, numerousAuth0Audience)

type Authenticator interface {
GetDeviceCode(ctx context.Context, client *http.Client) (DeviceCodeState, error)
Expand All @@ -34,13 +35,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
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 1403708

Please sign in to comment.