auth

package
v0.6.304 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const CredentialProviderAuth0 entity.CredentialProvider = "auth0"
View Source
const CredentialProviderKAS entity.CredentialProvider = "kas"
View Source
const (

	// namespace used to set/get values from the keychain.
	SecNamespace = "auth0-cli"
)

Variables

This section is empty.

Functions

func AuthProviderFlagToCredentialProvider added in v0.6.299

func AuthProviderFlagToCredentialProvider(authProviderFlag string) entity.CredentialProvider

func ErrorIfBadHTTP added in v0.6.7

func ErrorIfBadHTTP(r *http.Response, exceptStatus ...int) error

func GetEmailFromToken added in v0.6.296

func GetEmailFromToken(token string) string

func IsError added in v0.6.7

func IsError(statusCode int) bool

IsError method returns true if HTTP status `code >= 400` otherwise false.

func IssuerCheck added in v0.6.296

func IssuerCheck(token string, issuer string) bool

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(authStore AuthStore, oauth OAuth) *Auth

func (Auth) GetFreshAccessTokenOrLogin

func (t Auth) GetFreshAccessTokenOrLogin() (string, error)

Gets fresh access token and prompts for login and saves to store

func (Auth) GetFreshAccessTokenOrNil

func (t Auth) GetFreshAccessTokenOrNil() (string, error)

Gets fresh access token or returns nil and saves to store

func (Auth) Login

func (t Auth) Login(skipBrowser bool) (*LoginTokens, error)

func (Auth) LoginWithToken added in v0.6.63

func (t Auth) LoginWithToken(token string) error

func (Auth) Logout

func (t Auth) Logout() error

func (Auth) PromptForLogin

func (t Auth) PromptForLogin() (*LoginTokens, error)

Prompts for login and returns tokens, and saves to store

func (*Auth) WithAccessTokenValidator added in v0.4.3

func (t *Auth) WithAccessTokenValidator(val func(string) (bool, error)) *Auth

type Auth0Authenticator added in v0.6.296

type Auth0Authenticator struct {
	Issuer             string
	Audience           string
	ClientID           string
	DeviceCodeEndpoint string
	OauthTokenEndpoint string
}

func (Auth0Authenticator) DoDeviceAuthFlow added in v0.6.296

func (a Auth0Authenticator) DoDeviceAuthFlow(onStateRetrieved func(url string, code string)) (*LoginTokens, error)

func (Auth0Authenticator) GetCredentialProvider added in v0.6.296

func (a Auth0Authenticator) GetCredentialProvider() entity.CredentialProvider

func (Auth0Authenticator) IsTokenValid added in v0.6.296

func (a Auth0Authenticator) IsTokenValid(token string) bool

func (*Auth0Authenticator) Start added in v0.6.296

Start kicks-off the device authentication flow by requesting a device code from Auth0, The returned state contains the URI for the next step of the flow.

func (*Auth0Authenticator) Wait added in v0.6.296

Wait waits until the user is logged in on the browser.

type Auth0Result added in v0.6.296

type Auth0Result struct {
	Tenant       string
	Domain       string
	RefreshToken string
	AccessToken  string
	IDToken      string
	ExpiresIn    int64
}

type Auth0State added in v0.6.296

type Auth0State struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURI string `json:"verification_uri_complete"`
	ExpiresIn       int    `json:"expires_in"`
	Interval        int    `json:"interval"`
}

func (*Auth0State) IntervalDuration added in v0.6.296

func (s *Auth0State) IntervalDuration() time.Duration

type AuthError added in v0.6.16

type AuthError struct {
	// https://auth0.com/docs/api/authentication#standard-error-responses
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

type AuthStore

type AuthStore interface {
	SaveAuthTokens(tokens entity.AuthTokens) error
	GetAuthTokens() (*entity.AuthTokens, error)
	DeleteAuthTokens() error
}

type KasAuthenticator added in v0.6.296

type KasAuthenticator struct {
	Email             string
	ShouldPromptEmail bool
	BaseURL           string
	PollTimeout       time.Duration
	Issuer            string
	RedirectURI       string
}

func NewKasAuthenticator added in v0.6.296

func NewKasAuthenticator(email, baseURL, issuer string, shouldPromptEmail bool, redirectURI string) KasAuthenticator

func (KasAuthenticator) DoDeviceAuthFlow added in v0.6.296

func (a KasAuthenticator) DoDeviceAuthFlow(userLoginFlow func(url string, code string)) (*LoginTokens, error)

func (KasAuthenticator) GetCredentialProvider added in v0.6.296

func (a KasAuthenticator) GetCredentialProvider() entity.CredentialProvider

func (KasAuthenticator) GetNewAuthTokensWithRefresh added in v0.6.296

func (a KasAuthenticator) GetNewAuthTokensWithRefresh(refreshToken string) (*entity.AuthTokens, error)

func (KasAuthenticator) IsTokenValid added in v0.6.296

func (a KasAuthenticator) IsTokenValid(token string) bool

func (KasAuthenticator) MakeLoginCall added in v0.6.296

func (a KasAuthenticator) MakeLoginCall(id, email string) (LoginCallResponse, error)

type LoginAuth

type LoginAuth struct {
	Auth
}

func NewLoginAuth

func NewLoginAuth(authStore AuthStore, oauth OAuth) *LoginAuth

func (LoginAuth) GetAccessToken

func (l LoginAuth) GetAccessToken() (string, error)

type LoginCallResponse added in v0.6.296

type LoginCallResponse struct {
	LoginURL   string `json:"loginUrl"`
	SessionKey string `json:"sessionKey"`
}

type LoginTokens

type LoginTokens struct {
	entity.AuthTokens
	IDToken string
}

type NoLoginAuth

type NoLoginAuth struct {
	Auth
}

func NewNoLoginAuth

func NewNoLoginAuth(authStore AuthStore, oauth OAuth) *NoLoginAuth

func (NoLoginAuth) GetAccessToken

func (l NoLoginAuth) GetAccessToken() (string, error)

type OAuth

type OAuth interface {
	DoDeviceAuthFlow(onStateRetrieved func(url string, code string)) (*LoginTokens, error)
	GetNewAuthTokensWithRefresh(refreshToken string) (*entity.AuthTokens, error)
	GetCredentialProvider() entity.CredentialProvider
	IsTokenValid(token string) bool
}

func StandardLogin added in v0.6.299

func StandardLogin(authProvider string, email string, tokens *entity.AuthTokens) OAuth

type OAuthRetriever added in v0.6.296

type OAuthRetriever struct {
	// contains filtered or unexported fields
}

func NewOAuthRetriever added in v0.6.296

func NewOAuthRetriever(oauths []OAuth) *OAuthRetriever

func (*OAuthRetriever) GetByProvider added in v0.6.296

func (o *OAuthRetriever) GetByProvider(provider entity.CredentialProvider) (OAuth, error)

func (*OAuthRetriever) GetByToken added in v0.6.296

func (o *OAuthRetriever) GetByToken(token string) (OAuth, error)

type RetrieveIDTokenResponse added in v0.6.296

type RetrieveIDTokenResponse struct {
	IDToken       string `json:"token"`
	RequestStatus struct {
		StatusCode        string `json:"statusCode"`
		StatusDescription string `json:"statusDescription"`
		RequestID         string `json:"requestId"`
	} `json:"requestStatus"`
}

type StdHTTPResponseError added in v0.6.16

type StdHTTPResponseError struct {
	// contains filtered or unexported fields
}

func NewHTTPResponseError added in v0.6.16

func NewHTTPResponseError(response *http.Response) *StdHTTPResponseError

func (StdHTTPResponseError) Error added in v0.6.16

func (e StdHTTPResponseError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL