Documentation ¶
Index ¶
- Constants
- func GetAuthHeader(config configuration.Configuration) string
- func GetOAuthToken(config configuration.Configuration) (*oauth2.Token, error)
- func IsKnownOAuthEndpoint(endpoint string) bool
- func OpenBrowser(authUrl string)
- func RefreshToken(ctx context.Context, oauthConfig *oauth2.Config, token *oauth2.Token) (*oauth2.Token, error)
- func ShutdownServer(server *http.Server)
- type Authenticator
- func CreateAuthenticator(config configuration.Configuration, httpClient *http.Client) Authenticator
- func NewOAuth2Authenticator(config configuration.Configuration, httpClient *http.Client) Authenticator
- func NewOAuth2AuthenticatorWithCustomFuncs(config configuration.Configuration, httpClient *http.Client, ...) Authenticatordeprecated
- func NewOAuth2AuthenticatorWithOpts(config configuration.Configuration, opts ...OAuth2AuthenticatorOption) Authenticator
- func NewTokenAuthenticator(tokenFunc func() string) Authenticator
- type OAuth2AuthenticatorOption
- func WithHttpClient(httpClient *http.Client) OAuth2AuthenticatorOption
- func WithOpenBrowserFunc(openBrowserFunc func(string)) OAuth2AuthenticatorOption
- func WithShutdownServerFunc(shutdownServerFunc func(server *http.Server)) OAuth2AuthenticatorOption
- func WithTokenRefresherFunc(...) OAuth2AuthenticatorOption
Constants ¶
View Source
const ( CONFIG_KEY_OAUTH_TOKEN string = "INTERNAL_OAUTH_TOKEN_STORAGE" OAUTH_CLIENT_ID string = "b56d4c2e-b9e1-4d27-8773-ad47eafb0956" CALLBACK_HOSTNAME string = "127.0.0.1" CALLBACK_PATH string = "/authorization-code/callback" TIMEOUT_SECONDS time.Duration = 120 * time.Second AUTHENTICATED_MESSAGE = "Your account has been authenticated." )
Variables ¶
This section is empty.
Functions ¶
func GetAuthHeader ¶
func GetAuthHeader(config configuration.Configuration) string
GetAuthHeader returns the authentication header value based on the configuration.
func GetOAuthToken ¶
func GetOAuthToken(config configuration.Configuration) (*oauth2.Token, error)
GetOAuthToken extracts an oauth2.Token from the given configuration instance if available
func IsKnownOAuthEndpoint ¶
func OpenBrowser ¶
func OpenBrowser(authUrl string)
func RefreshToken ¶
func ShutdownServer ¶
Types ¶
type Authenticator ¶
type Authenticator interface { // Authenticate authenticates the user and returns an error if the authentication failed. Authenticate() error // AddAuthenticationHeader adds the authentication header to the request. AddAuthenticationHeader(request *http.Request) error // IsSupported returns true if the authenticator is ready for use. // If false is returned, it is not possible to add authentication headers/env vars. IsSupported() bool }
func CreateAuthenticator ¶
func CreateAuthenticator(config configuration.Configuration, httpClient *http.Client) Authenticator
func NewOAuth2Authenticator ¶
func NewOAuth2Authenticator(config configuration.Configuration, httpClient *http.Client) Authenticator
func NewOAuth2AuthenticatorWithCustomFuncs
deprecated
func NewOAuth2AuthenticatorWithCustomFuncs( config configuration.Configuration, httpClient *http.Client, openBrowserFunc func(url string), shutdownServerFunc func(server *http.Server), ) Authenticator
Deprecated: use NewOAuth2AuthenticatorWithOpts instead
func NewOAuth2AuthenticatorWithOpts ¶
func NewOAuth2AuthenticatorWithOpts(config configuration.Configuration, opts ...OAuth2AuthenticatorOption) Authenticator
func NewTokenAuthenticator ¶
func NewTokenAuthenticator(tokenFunc func() string) Authenticator
type OAuth2AuthenticatorOption ¶
type OAuth2AuthenticatorOption func(authenticator *oAuth2Authenticator)
func WithHttpClient ¶
func WithHttpClient(httpClient *http.Client) OAuth2AuthenticatorOption
func WithOpenBrowserFunc ¶
func WithOpenBrowserFunc(openBrowserFunc func(string)) OAuth2AuthenticatorOption
func WithShutdownServerFunc ¶
func WithShutdownServerFunc(shutdownServerFunc func(server *http.Server)) OAuth2AuthenticatorOption
Click to show internal directories.
Click to hide internal directories.