service

package
v0.0.0-...-2b8ec9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(Store), "*"),
	wire.Struct(new(Service), "*"),
)

Functions

func AntiBruteForceAuthenticateBucket

func AntiBruteForceAuthenticateBucket(userID string, authType model.AuthenticatorType) ratelimit.Bucket

Types

type OOBOTPAuthenticatorProvider

type OOBOTPAuthenticatorProvider interface {
	Get(userID, id string) (*authenticator.OOBOTP, error)
	GetMany(ids []string) ([]*authenticator.OOBOTP, error)
	List(userID string) ([]*authenticator.OOBOTP, error)
	New(id string, userID string, oobAuthenticatorType model.AuthenticatorType, target string, isDefault bool, kind string) *authenticator.OOBOTP
	Create(*authenticator.OOBOTP) error
	Delete(*authenticator.OOBOTP) error
}

type OTPCodeService

type OTPCodeService interface {
	VerifyCode(target string, code string) error
}

type PasskeyAuthenticatorProvider

type PasskeyAuthenticatorProvider interface {
	Get(userID, id string) (*authenticator.Passkey, error)
	GetMany(ids []string) ([]*authenticator.Passkey, error)
	List(userID string) ([]*authenticator.Passkey, error)
	New(
		id string,
		userID string,
		attestationResponse []byte,
		isDefault bool,
		kind string,
	) (*authenticator.Passkey, error)
	Create(*authenticator.Passkey) error
	Update(*authenticator.Passkey) error
	Delete(*authenticator.Passkey) error
	Authenticate(a *authenticator.Passkey, assertionResponse []byte) (requireUpdate bool, err error)
}

type PasswordAuthenticatorProvider

type PasswordAuthenticatorProvider interface {
	Get(userID, id string) (*authenticator.Password, error)
	GetMany(ids []string) ([]*authenticator.Password, error)
	List(userID string) ([]*authenticator.Password, error)
	New(id string, userID string, password string, isDefault bool, kind string) (*authenticator.Password, error)
	// WithPassword returns new authenticator pointer if password is changed
	// Otherwise original authenticator will be returned
	WithPassword(a *authenticator.Password, password string) (*authenticator.Password, error)
	Create(*authenticator.Password) error
	UpdatePassword(*authenticator.Password) error
	Delete(*authenticator.Password) error
	Authenticate(a *authenticator.Password, password string) (requireUpdate bool, err error)
}

type RateLimiter

type RateLimiter interface {
	TakeToken(bucket ratelimit.Bucket) error
}

type Service

type Service struct {
	Store          *Store
	Password       PasswordAuthenticatorProvider
	Passkey        PasskeyAuthenticatorProvider
	TOTP           TOTPAuthenticatorProvider
	OOBOTP         OOBOTPAuthenticatorProvider
	OTPCodeService OTPCodeService
	RateLimiter    RateLimiter
}

func (*Service) Count

func (s *Service) Count(userID string) (uint64, error)

func (*Service) Create

func (s *Service) Create(info *authenticator.Info) error

func (*Service) Delete

func (s *Service) Delete(info *authenticator.Info) error

func (*Service) Get

func (s *Service) Get(id string) (*authenticator.Info, error)

func (*Service) GetMany

func (s *Service) GetMany(ids []string) ([]*authenticator.Info, error)

func (*Service) List

func (s *Service) List(userID string, filters ...authenticator.Filter) ([]*authenticator.Info, error)

func (*Service) ListRefsByUsers

func (s *Service) ListRefsByUsers(userIDs []string, authenticatorType *model.AuthenticatorType, authenticatorKind *authenticator.Kind) ([]*authenticator.Ref, error)

func (*Service) New

func (s *Service) New(spec *authenticator.Spec) (*authenticator.Info, error)

func (*Service) NewWithAuthenticatorID

func (s *Service) NewWithAuthenticatorID(authenticatorID string, spec *authenticator.Spec) (*authenticator.Info, error)

func (*Service) RemoveOrphans

func (s *Service) RemoveOrphans(identities []*identity.Info) error

func (*Service) Update

func (s *Service) Update(info *authenticator.Info) error

func (*Service) VerifyWithSpec

func (s *Service) VerifyWithSpec(info *authenticator.Info, spec *authenticator.Spec) (requireUpdate bool, err error)

func (*Service) WithSpec

func (s *Service) WithSpec(ai *authenticator.Info, spec *authenticator.Spec) (bool, *authenticator.Info, error)

type Store

type Store struct {
	SQLBuilder  *appdb.SQLBuilderApp
	SQLExecutor *appdb.SQLExecutor
}

func (*Store) Count

func (s *Store) Count(userID string) (uint64, error)

func (*Store) GetRefByID

func (s *Store) GetRefByID(id string) (*authenticator.Ref, error)

func (*Store) ListRefsByIDs

func (s *Store) ListRefsByIDs(ids []string) ([]*authenticator.Ref, error)

func (*Store) ListRefsByUsers

func (s *Store) ListRefsByUsers(userIDs []string, authenticatorType *model.AuthenticatorType, authenticatorKind *authenticator.Kind) ([]*authenticator.Ref, error)

type TOTPAuthenticatorProvider

type TOTPAuthenticatorProvider interface {
	Get(userID, id string) (*authenticator.TOTP, error)
	GetMany(ids []string) ([]*authenticator.TOTP, error)
	List(userID string) ([]*authenticator.TOTP, error)
	New(id string, userID string, displayName string, isDefault bool, kind string) *authenticator.TOTP
	Create(*authenticator.TOTP) error
	Delete(*authenticator.TOTP) error
	Authenticate(a *authenticator.TOTP, code string) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL