Documentation
¶
Index ¶
- Variables
- func GenerateDeviceToken() string
- type CookieDef
- type DeviceToken
- type Lockout
- type LockoutProvider
- type RateLimiter
- type ReadOnlyService
- type RecoveryCode
- type Service
- func (s *Service) ConsumeRecoveryCode(ctx context.Context, rc *RecoveryCode) error
- func (s *Service) CountDeviceTokens(ctx context.Context, userID string) (int, error)
- func (s *Service) CreateDeviceToken(ctx context.Context, userID string, token string) (*DeviceToken, error)
- func (s *Service) GenerateDeviceToken(ctx context.Context) string
- func (s *Service) GenerateRecoveryCodes(ctx context.Context) []string
- func (s *Service) HasDeviceTokens(ctx context.Context, userID string) (bool, error)
- func (s *Service) InvalidateAllDeviceTokens(ctx context.Context, userID string) error
- func (s *Service) InvalidateAllRecoveryCode(ctx context.Context, userID string) error
- func (s *Service) ReplaceRecoveryCodes(ctx context.Context, userID string, codes []string) ([]*RecoveryCode, error)
- func (s *Service) VerifyDeviceToken(ctx context.Context, userID string, token string) error
- func (s *Service) VerifyRecoveryCode(ctx context.Context, userID string, code string) (*RecoveryCode, error)
- type StoreDeviceToken
- type StoreDeviceTokenRedis
- func (s *StoreDeviceTokenRedis) Count(ctx context.Context, userID string) (int, error)
- func (s *StoreDeviceTokenRedis) Create(ctx context.Context, token *DeviceToken) error
- func (s *StoreDeviceTokenRedis) DeleteAll(ctx context.Context, userID string) error
- func (s *StoreDeviceTokenRedis) Get(ctx context.Context, userID string, token string) (*DeviceToken, error)
- func (s *StoreDeviceTokenRedis) HasTokens(ctx context.Context, userID string) (bool, error)
- type StoreRecoveryCode
- type StoreRecoveryCodePQ
- func (s *StoreRecoveryCodePQ) CreateAll(ctx context.Context, codes []*RecoveryCode) error
- func (s *StoreRecoveryCodePQ) DeleteAll(ctx context.Context, userID string) error
- func (s *StoreRecoveryCodePQ) Get(ctx context.Context, userID string, code string) (*RecoveryCode, error)
- func (s *StoreRecoveryCodePQ) List(ctx context.Context, userID string) ([]*RecoveryCode, error)
- func (s *StoreRecoveryCodePQ) UpdateConsumed(ctx context.Context, code *RecoveryCode) error
Constants ¶
This section is empty.
Variables ¶
View Source
var DependencySet = wire.NewSet( NewDeviceTokenCookieDef, wire.Struct(new(StoreDeviceTokenRedis), "*"), wire.Bind(new(StoreDeviceToken), new(*StoreDeviceTokenRedis)), wire.Struct(new(StoreRecoveryCodePQ), "*"), wire.Bind(new(StoreRecoveryCode), new(*StoreRecoveryCodePQ)), wire.Struct(new(ReadOnlyService), "*"), wire.Struct(new(Service), "*"), wire.Struct(new(Lockout), "*"), )
View Source
var ErrDeviceTokenNotFound = errors.New("bearer token not found")
View Source
var ErrRecoveryCodeConsumed = errors.New("recovery code consumed")
View Source
var ErrRecoveryCodeNotFound = errors.New("recovery code not found")
Functions ¶
func GenerateDeviceToken ¶
func GenerateDeviceToken() string
Types ¶
type CookieDef ¶
func NewDeviceTokenCookieDef ¶
func NewDeviceTokenCookieDef(cfg *config.AuthenticationConfig) CookieDef
type DeviceToken ¶
type Lockout ¶
type Lockout struct {
Config *config.AuthenticationLockoutConfig
RemoteIP httputil.RemoteIP
Provider LockoutProvider
}
type LockoutProvider ¶
type LockoutProvider interface {
MakeAttempts(ctx context.Context, spec lockout.LockoutSpec, contributor string, attempts int) (result *lockout.MakeAttemptResult, err error)
}
type RateLimiter ¶
type RateLimiter interface {
Reserve(ctx context.Context, spec ratelimit.BucketSpec) (*ratelimit.Reservation, *ratelimit.FailedReservation, error)
Cancel(ctx context.Context, r *ratelimit.Reservation)
}
type ReadOnlyService ¶
type ReadOnlyService struct {
RecoveryCodes StoreRecoveryCode
}
RateLimiter depends on EventService EventService depends on UserInfoService So finally depends on mfa.Service causing circular dependency This service was created for read only methods and do not depends on RateLimiter to break this circular dependency
func (*ReadOnlyService) ListRecoveryCodes ¶
func (s *ReadOnlyService) ListRecoveryCodes(ctx context.Context, userID string) ([]*RecoveryCode, error)
type RecoveryCode ¶
type Service ¶
type Service struct {
ReadOnlyService
IP httputil.RemoteIP
DeviceTokens StoreDeviceToken
RecoveryCodes StoreRecoveryCode
Clock clock.Clock
Config *config.AppConfig
FeatureConfig *config.FeatureConfig
EnvConfig *config.RateLimitsEnvironmentConfig
RateLimiter RateLimiter
Lockout Lockout
}
func (*Service) ConsumeRecoveryCode ¶
func (s *Service) ConsumeRecoveryCode(ctx context.Context, rc *RecoveryCode) error
func (*Service) CountDeviceTokens ¶
func (*Service) CreateDeviceToken ¶
func (*Service) GenerateDeviceToken ¶
func (*Service) GenerateRecoveryCodes ¶
func (*Service) HasDeviceTokens ¶
func (*Service) InvalidateAllDeviceTokens ¶
func (*Service) InvalidateAllRecoveryCode ¶
func (*Service) ReplaceRecoveryCodes ¶
func (*Service) VerifyDeviceToken ¶
func (*Service) VerifyRecoveryCode ¶
type StoreDeviceToken ¶
type StoreDeviceToken interface {
Get(ctx context.Context, userID string, token string) (*DeviceToken, error)
Create(ctx context.Context, token *DeviceToken) error
DeleteAll(ctx context.Context, userID string) error
HasTokens(ctx context.Context, userID string) (bool, error)
Count(ctx context.Context, userID string) (int, error)
}
type StoreDeviceTokenRedis ¶
func (*StoreDeviceTokenRedis) Create ¶
func (s *StoreDeviceTokenRedis) Create(ctx context.Context, token *DeviceToken) error
func (*StoreDeviceTokenRedis) DeleteAll ¶
func (s *StoreDeviceTokenRedis) DeleteAll(ctx context.Context, userID string) error
func (*StoreDeviceTokenRedis) Get ¶
func (s *StoreDeviceTokenRedis) Get(ctx context.Context, userID string, token string) (*DeviceToken, error)
type StoreRecoveryCode ¶
type StoreRecoveryCode interface {
List(ctx context.Context, userID string) ([]*RecoveryCode, error)
Get(ctx context.Context, userID string, code string) (*RecoveryCode, error)
DeleteAll(ctx context.Context, userID string) error
CreateAll(ctx context.Context, codes []*RecoveryCode) error
UpdateConsumed(ctx context.Context, code *RecoveryCode) error
}
type StoreRecoveryCodePQ ¶
type StoreRecoveryCodePQ struct {
SQLBuilder *appdb.SQLBuilderApp
SQLExecutor *appdb.SQLExecutor
}
func (*StoreRecoveryCodePQ) CreateAll ¶
func (s *StoreRecoveryCodePQ) CreateAll(ctx context.Context, codes []*RecoveryCode) error
func (*StoreRecoveryCodePQ) DeleteAll ¶
func (s *StoreRecoveryCodePQ) DeleteAll(ctx context.Context, userID string) error
func (*StoreRecoveryCodePQ) Get ¶
func (s *StoreRecoveryCodePQ) Get(ctx context.Context, userID string, code string) (*RecoveryCode, error)
func (*StoreRecoveryCodePQ) List ¶
func (s *StoreRecoveryCodePQ) List(ctx context.Context, userID string) ([]*RecoveryCode, error)
func (*StoreRecoveryCodePQ) UpdateConsumed ¶
func (s *StoreRecoveryCodePQ) UpdateConsumed(ctx context.Context, code *RecoveryCode) error
Click to show internal directories.
Click to hide internal directories.