Documentation ¶
Overview ¶
Package auth provides the authentication logic for the application
Index ¶
- Constants
- type APIKeyAuthenticator
- func (a *APIKeyAuthenticator) Authenticate(_ context.Context, _ store.Store) error
- func (a *APIKeyAuthenticator) GetAuthValue() *pb.Auth
- func (a *APIKeyAuthenticator) IsExpired(_ context.Context, _ store.Store) bool
- func (a *APIKeyAuthenticator) Refresh(_ context.Context, _ store.Store) error
- func (a *APIKeyAuthenticator) SetOnRequest(_ context.Context, r *http.Request)
- type Authenticator
- func NewAPIKeyAuthenticator(conf config.ValidAuthAPIKeyConfig) (Authenticator, error)
- func NewBasicAuthenticator(conf config.ValidAuthBasicConfig) (Authenticator, error)
- func NewJWTAuthenticator(conf config.ValidAuthJWTConfig) (Authenticator, error)
- func NewOAuthAuthenticator(str store.Store, redirectPort int, conf config.ValidAuthOAuth2Config) (Authenticator, error)
- type AuthenticatorContainer
- type BasicAuthenticator
- func (a *BasicAuthenticator) Authenticate(_ context.Context, _ store.Store) error
- func (a *BasicAuthenticator) GetAuthValue() *pb.Auth
- func (a *BasicAuthenticator) IsExpired(_ context.Context, _ store.Store) bool
- func (a *BasicAuthenticator) Refresh(_ context.Context, _ store.Store) error
- func (a *BasicAuthenticator) SetOnRequest(_ context.Context, r *http.Request)
- type JWTAuthenticator
- func (a *JWTAuthenticator) Authenticate(_ context.Context, _ store.Store) error
- func (a *JWTAuthenticator) GetAuthValue() *pb.Auth
- func (a *JWTAuthenticator) IsExpired(_ context.Context, _ store.Store) bool
- func (a *JWTAuthenticator) Refresh(_ context.Context, _ store.Store) error
- func (a *JWTAuthenticator) SetOnRequest(_ context.Context, _ *http.Request)
- type OAuthAuthenticator
- func (a *OAuthAuthenticator) Authenticate(ctx context.Context, str store.Store) error
- func (a *OAuthAuthenticator) GetAuthValue() *pb.Auth
- func (a *OAuthAuthenticator) IsExpired(_ context.Context, _ store.Store) bool
- func (a *OAuthAuthenticator) Refresh(ctx context.Context, str store.Store) error
- func (a *OAuthAuthenticator) SetOnRequest(ctx context.Context, r *http.Request)
- type OAuthToken
- type SetAuthor
Constants ¶
const ( // AuthOAuth2GrantTypeAuthorizationCode is the OAuth2 grant type Authorization Code AuthOAuth2GrantTypeAuthorizationCode oauthGrantType // AuthOAuth2GrantTypeClientCredentials is the OAuth2 grant type Client Credentials AuthOAuth2GrantTypeClientCredentials // AuthOAuth2GrantTypePassword is the OAuth2 grant type Password AuthOAuth2GrantTypePassword )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyAuthenticator ¶
APIKeyAuthenticator is an Authenticator that uses API Key
func (*APIKeyAuthenticator) Authenticate ¶
Authenticate authenticates the user
func (*APIKeyAuthenticator) GetAuthValue ¶
func (a *APIKeyAuthenticator) GetAuthValue() *pb.Auth
GetAuthValue returns the authentication value
func (*APIKeyAuthenticator) IsExpired ¶
IsExpired checks if the authentication information is expired
func (*APIKeyAuthenticator) SetOnRequest ¶
func (a *APIKeyAuthenticator) SetOnRequest(_ context.Context, r *http.Request)
SetOnRequest sets the authentication information on the request
type Authenticator ¶
type Authenticator interface { SetAuthor // Authenticate authenticates the user Authenticate(ctx context.Context, str store.Store) error // IsExpired checks if the authentication information is expired IsExpired(ctx context.Context, str store.Store) bool // Refresh refreshes the authentication information Refresh(ctx context.Context, str store.Store) error }
Authenticator is an interface for authenticating
func NewAPIKeyAuthenticator ¶
func NewAPIKeyAuthenticator(conf config.ValidAuthAPIKeyConfig) (Authenticator, error)
NewAPIKeyAuthenticator creates a new APIKeyAuthenticator
func NewBasicAuthenticator ¶
func NewBasicAuthenticator(conf config.ValidAuthBasicConfig) (Authenticator, error)
NewBasicAuthenticator creates a new BasicAuthenticator
func NewJWTAuthenticator ¶
func NewJWTAuthenticator(conf config.ValidAuthJWTConfig) (Authenticator, error)
NewJWTAuthenticator creates a new JWTAuthenticator
func NewOAuthAuthenticator ¶
func NewOAuthAuthenticator( str store.Store, redirectPort int, conf config.ValidAuthOAuth2Config, ) (Authenticator, error)
NewOAuthAuthenticator creates a new OAuthAuthenticator
type AuthenticatorContainer ¶
type AuthenticatorContainer struct { DefaultAuthenticator string Container map[string]*Authenticator }
AuthenticatorContainer holds the dependencies for the Authenticator
func NewAuthenticatorContainerFromConfig ¶
func NewAuthenticatorContainerFromConfig(str store.Store, conf config.ValidConfig) (AuthenticatorContainer, error)
NewAuthenticatorContainerFromConfig creates a new AuthenticatorContainer from the configuration
type BasicAuthenticator ¶
BasicAuthenticator is an Authenticator that uses Basic Auth
func (*BasicAuthenticator) Authenticate ¶
Authenticate authenticates the user
func (*BasicAuthenticator) GetAuthValue ¶
func (a *BasicAuthenticator) GetAuthValue() *pb.Auth
GetAuthValue returns the authentication value
func (*BasicAuthenticator) IsExpired ¶
IsExpired checks if the authentication information is expired
func (*BasicAuthenticator) SetOnRequest ¶
func (a *BasicAuthenticator) SetOnRequest(_ context.Context, r *http.Request)
SetOnRequest sets the authentication information on the request
type JWTAuthenticator ¶
type JWTAuthenticator struct {
// contains filtered or unexported fields
}
JWTAuthenticator is an Authenticator that uses Private Key
func (*JWTAuthenticator) Authenticate ¶
Authenticate authenticates the user
func (*JWTAuthenticator) GetAuthValue ¶
func (a *JWTAuthenticator) GetAuthValue() *pb.Auth
GetAuthValue returns the authentication value
func (*JWTAuthenticator) SetOnRequest ¶
func (a *JWTAuthenticator) SetOnRequest(_ context.Context, _ *http.Request)
SetOnRequest sets the authentication information on the request
type OAuthAuthenticator ¶
type OAuthAuthenticator struct {
// contains filtered or unexported fields
}
OAuthAuthenticator is an Authenticator that uses OAuth
func (*OAuthAuthenticator) Authenticate ¶
Authenticate authenticates the user
func (*OAuthAuthenticator) GetAuthValue ¶
func (a *OAuthAuthenticator) GetAuthValue() *pb.Auth
GetAuthValue returns the authentication value
func (*OAuthAuthenticator) IsExpired ¶
IsExpired checks if the authentication information is expired
func (*OAuthAuthenticator) SetOnRequest ¶
func (a *OAuthAuthenticator) SetOnRequest(ctx context.Context, r *http.Request)
SetOnRequest sets the authentication information on the request
type OAuthToken ¶
type OAuthToken struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` TokenType string `json:"token_type"` Expiry time.Time `json:"expiry"` }
OAuthToken is the OAuth token
func (*OAuthToken) GetAuthValue ¶
func (t *OAuthToken) GetAuthValue() *pb.Auth
GetAuthValue returns the authentication value
func (*OAuthToken) SetOnRequest ¶
func (t *OAuthToken) SetOnRequest(_ context.Context, r *http.Request)
SetOnRequest sets the authentication information on the request