Documentation ¶
Overview ¶
Package authentication implements a user passwords layer for a web server, issuing cookies, validating requests via middleware
Index ¶
Constants ¶
View Source
const ( // DefaultCookieName is the default Cookie.BucketName. DefaultCookieName = "todocookie" // DefaultCookieLifetime is the how long a cookie is valid. DefaultCookieLifetime = 24 * time.Hour )
Variables ¶
View Source
var ( // ErrUserNotFound indicates a user was not located. ErrUserNotFound = errors.New("user not found") // ErrUserBanned indicates a user is banned from using the service. ErrUserBanned = errors.New("user is banned") // ErrInvalidCredentials indicates a user provided invalid credentials. ErrInvalidCredentials = errors.New("invalid credentials") )
View Source
var ( // ErrNoSessionContextDataAvailable indicates no SessionContextData was attached to the request. ErrNoSessionContextDataAvailable = errors.New("no SessionContextData attached to session context data") )
View Source
var Providers = wire.NewSet( ProvideService, wire.FieldsOf(new(*Config), "Cookies", "PASETO", ), )
Providers is our collection of what we provide to other services.
Functions ¶
func FetchContextFromRequest ¶
func FetchContextFromRequest(req *http.Request) (*types.SessionContextData, error)
FetchContextFromRequest fetches a SessionContextData from a request.
func ProvideService ¶
func ProvideService( logger logging.Logger, cfg *Config, authenticator authentication.Authenticator, userDataManager types.UserDataManager, apiClientsService types.APIClientDataManager, accountMembershipManager types.AccountUserMembershipDataManager, sessionManager *scs.SessionManager, encoder encoding.ServerEncoderDecoder, ) (types.AuthService, error)
ProvideService builds a new AuthService.
Types ¶
type Config ¶
type Config struct { PASETO PASETOConfig `json:"paseto" mapstructure:"paseto" toml:"paseto,omitempty"` Cookies CookieConfig `json:"cookies" mapstructure:"cookies" toml:"cookies,omitempty"` Debug bool `json:"debug" mapstructure:"debug" toml:"debug,omitempty"` EnableUserSignup bool `json:"enable_user_signup" mapstructure:"enable_user_signup" toml:"enable_user_signup,omitempty"` MinimumUsernameLength uint8 `json:"minimum_username_length" mapstructure:"minimum_username_length" toml:"minimum_username_length,omitempty"` MinimumPasswordLength uint8 `json:"minimum_password_length" mapstructure:"minimum_password_length" toml:"minimum_password_length,omitempty"` // contains filtered or unexported fields }
Config represents our passwords configuration.
type CookieConfig ¶
type CookieConfig struct { Name string `json:"name" mapstructure:"name" toml:"name,omitempty"` Domain string `json:"domain" mapstructure:"domain" toml:"domain,omitempty"` HashKey string `json:"hash_key" mapstructure:"hash_key" toml:"hash_key,omitempty"` SigningKey string `json:"signing_key" mapstructure:"signing_key" toml:"signing_key,omitempty"` Lifetime time.Duration `json:"lifetime" mapstructure:"lifetime" toml:"lifetime,omitempty"` SecureOnly bool `json:"secure_only" mapstructure:"secure_only" toml:"secure_only,omitempty"` // contains filtered or unexported fields }
CookieConfig holds our cookie settings.
func (*CookieConfig) ValidateWithContext ¶
func (cfg *CookieConfig) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a CookieConfig struct.
type PASETOConfig ¶
type PASETOConfig struct { Issuer string `json:"issuer" mapstructure:"issuer" toml:"issuer,omitempty"` LocalModeKey []byte `json:"local_mode_key" mapstructure:"local_mode_key" toml:"local_mode_key,omitempty"` Lifetime time.Duration `json:"lifetime" mapstructure:"lifetime" toml:"lifetime,omitempty"` // contains filtered or unexported fields }
PASETOConfig holds our PASETO settings.
func (*PASETOConfig) ValidateWithContext ¶
func (cfg *PASETOConfig) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a PASETOConfig struct.
Click to show internal directories.
Click to hide internal directories.