Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAPIKey = errors.New("realm: invalid API key") ErrInvalidPublicAPIKey = errors.New("realm: invalid username or public API key") ErrInvalidPassword = errors.New("realm: invalid password") )
Errors related to auth
var (
ErrInvalidToken = errors.New("the provided authentication token is invalid")
)
JWT related errors
Functions ¶
func ValidAPIKey ¶
ValidAPIKey locally checks if the given API key is valid
func ValidAccessToken ¶
ValidAccessToken locally checks if the given access token is valid
Types ¶
type APIKeyProvider ¶
type APIKeyProvider struct {
// contains filtered or unexported fields
}
APIKeyProvider is an AuthenticationProvider using a cloud API Key
func NewAPIKeyProvider ¶
func NewAPIKeyProvider(username, apiKey string) *APIKeyProvider
NewAPIKeyProvider returns a new APIKeyProvider given an API Key and Username
func (*APIKeyProvider) Payload ¶
func (p *APIKeyProvider) Payload() map[string]string
Payload returns the provider's auth payload
func (*APIKeyProvider) Type ¶
func (p *APIKeyProvider) Type() ProviderType
Type returns the auth provider type
func (*APIKeyProvider) Validate ¶
func (p *APIKeyProvider) Validate() error
Validate will determine if a given provider is valid
type AuthenticationProvider ¶
type AuthenticationProvider interface { Type() ProviderType Payload() map[string]string Validate() error }
AuthenticationProvider represents an authentication method
type JWT ¶
type JWT struct {
Exp int64 `json:"exp,omitempty"`
}
JWT represents a basic auth token
type ProviderType ¶
type ProviderType string
ProviderType represents available types of auth providers
const ( ProviderTypeAPIKey ProviderType = "mongodb-cloud" ProviderTypeUsernamePassword ProviderType = "local-userpass" )
Available ProviderTypes
type Response ¶
type Response struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` }
Response represents the response payload from the API containing an access token and refresh token
type UsernamePasswordProvider ¶
type UsernamePasswordProvider struct {
// contains filtered or unexported fields
}
UsernamePasswordProvider is an AuthenticationProvider using an email and password
func NewUsernamePasswordProvider ¶
func NewUsernamePasswordProvider(username, password string) *UsernamePasswordProvider
NewUsernamePasswordProvider returns a new UsernamePasswordProvider given a username and password
func (*UsernamePasswordProvider) Payload ¶
func (p *UsernamePasswordProvider) Payload() map[string]string
Payload returns the provider's auth payload
func (*UsernamePasswordProvider) Type ¶
func (p *UsernamePasswordProvider) Type() ProviderType
Type returns the auth provider type
func (*UsernamePasswordProvider) Validate ¶
func (p *UsernamePasswordProvider) Validate() error
Validate will determine if a given provider is valid