Skip to content

Commit

Permalink
more explo
Browse files Browse the repository at this point in the history
  • Loading branch information
theFong committed Nov 13, 2024
1 parent 02a9931 commit 824d8d2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
19 changes: 19 additions & 0 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ import (
"github.com/pkg/browser"
)

type AuthChecker interface {
GetCredentialProvider() entity.CredentialProvider
}

func GetAuthenticator(ac AuthChecker) OAuth {
switch ac.GetCredentialProvider() {
case entity.CredentialProviderKAS:
return KasAuthenticator{}

Check failure on line 25 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

cannot use KasAuthenticator{} (value of type KasAuthenticator) as OAuth value in return statement: KasAuthenticator does not implement OAuth (missing method DoDeviceAuthFlow)

Check failure on line 25 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04)

cannot use KasAuthenticator{} (value of type KasAuthenticator) as OAuth value in return statement: KasAuthenticator does not implement OAuth (missing method DoDeviceAuthFlow)

Check failure on line 25 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / release-test

cannot use KasAuthenticator{} (value of type KasAuthenticator) as OAuth value in return statement: KasAuthenticator does not implement OAuth (missing method DoDeviceAuthFlow)
case entity.CredentialProviderAuth0:
return Auth0Authenticator{
Audience: "https://brevdev.us.auth0.com/api/v2/",
ClientID: "JaqJRLEsdat5w7Tb0WqmTxzIeqwqepmk",
DeviceCodeEndpoint: "https://brevdev.us.auth0.com/oauth/device/code",
OauthTokenEndpoint: "https://brevdev.us.auth0.com/oauth/token",
}
}
return nil
}

type LoginAuth struct {
Auth
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/auth/kas.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package auth

var _ OAuth = KasAuthenticator{}

Check failure on line 3 in pkg/auth/kas.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

cannot use KasAuthenticator{} (value of type KasAuthenticator) as OAuth value in variable declaration: KasAuthenticator does not implement OAuth (missing method DoDeviceAuthFlow)

Check failure on line 3 in pkg/auth/kas.go

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04)

cannot use KasAuthenticator{} (value of type KasAuthenticator) as OAuth value in variable declaration: KasAuthenticator does not implement OAuth (missing method DoDeviceAuthFlow)

Check failure on line 3 in pkg/auth/kas.go

View workflow job for this annotation

GitHub Actions / release-test

cannot use KasAuthenticator{} (value of type KasAuthenticator) as OAuth value in variable declaration: KasAuthenticator does not implement OAuth (missing method DoDeviceAuthFlow)

type KasAuthenticator struct {
Audience string
ClientID string
DeviceCodeEndpoint string
OauthTokenEndpoint string
}
16 changes: 5 additions & 11 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,15 @@ func NewBrevCommand() *cobra.Command { //nolint:funlen,gocognit,gocyclo // defin
conf := config.NewConstants()
fs := files.AppFs

// TODO: this is inappropriately tightly bound to auth0, we should bifurcate our path near here.
// auth.Multi.. auth.Dynamic.. ?
var authenticator auth.OAuth = auth.Auth0Authenticator{
Audience: "https://brevdev.us.auth0.com/api/v2/",
ClientID: "JaqJRLEsdat5w7Tb0WqmTxzIeqwqepmk",
DeviceCodeEndpoint: "https://brevdev.us.auth0.com/oauth/device/code",
OauthTokenEndpoint: "https://brevdev.us.auth0.com/oauth/token",
}
fsStore := store.
NewBasicStore().
WithFileSystem(fs)

authenticator := auth.GetAuthenticator(nil) // todo

// super annoying. this is needed to make the import stay
_ = color.New(color.FgYellow, color.Bold).SprintFunc()

fsStore := store.
NewBasicStore().
WithFileSystem(fs)
loginAuth := auth.NewLoginAuth(fsStore, authenticator)
noLoginAuth := auth.NewNoLoginAuth(fsStore, authenticator)

Expand Down

0 comments on commit 824d8d2

Please sign in to comment.