verification

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

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(StorePQ), "*"),
	wire.Bind(new(ClaimStore), new(*StorePQ)),
	wire.Struct(new(Service), "*"),
)
View Source
var ErrClaimUnverified = errors.New("claim is unverified")
View Source
var ErrCodeNotFound = InvalidVerificationCode.NewWithCause("verification code is expired or invalid", apierrors.StringCause("CodeNotFound"))
View Source
var ErrInvalidVerificationCode = InvalidVerificationCode.NewWithCause("invalid verification code", apierrors.StringCause("InvalidVerificationCode"))
View Source
var ErrUnsupportedClaim = errors.New("unsupported claim")
View Source
var InvalidVerificationCode = apierrors.Forbidden.WithReason("InvalidVerificationCode")

Functions

This section is empty.

Types

type AuthenticatorStatus

type AuthenticatorStatus string
const (
	AuthenticatorStatusUnverified AuthenticatorStatus = "unverified"
	AuthenticatorStatusVerified   AuthenticatorStatus = "verified"
)

type Claim

type Claim struct {
	ID        string
	UserID    string
	Name      string
	Value     string
	CreatedAt time.Time
}

type ClaimStatus

type ClaimStatus struct {
	Name                       string
	Value                      string
	Verified                   bool
	RequiredToVerifyOnCreation bool
	EndUserTriggerable         bool
}

func (ClaimStatus) IsVerifiable

func (s ClaimStatus) IsVerifiable() bool

type ClaimStore

type ClaimStore interface {
	ListByUser(ctx context.Context, userID string) ([]*Claim, error)
	ListByUserIDs(ctx context.Context, userIDs []string) ([]*Claim, error)
	ListByClaimName(ctx context.Context, userID string, claimName string) ([]*Claim, error)
	Get(ctx context.Context, userID string, claimName string, claimValue string) (*Claim, error)
	Create(ctx context.Context, claim *Claim) error
	Delete(ctx context.Context, id string) error
	DeleteAll(ctx context.Context, userID string) error
}

type Service

type Service struct {
	Config            *config.VerificationConfig
	UserProfileConfig *config.UserProfileConfig

	Clock      clock.Clock
	ClaimStore ClaimStore
}

func (*Service) AreUsersVerified

func (s *Service) AreUsersVerified(ctx context.Context, identitiesByUserIDs map[string][]*identity.Info) (map[string]bool, error)

func (*Service) DeleteClaim

func (s *Service) DeleteClaim(ctx context.Context, claim *Claim) error

func (*Service) GetAuthenticatorVerificationStatus

func (s *Service) GetAuthenticatorVerificationStatus(ctx context.Context, a *authenticator.Info) (AuthenticatorStatus, error)

func (*Service) GetClaimStatus

func (s *Service) GetClaimStatus(ctx context.Context, userID string, claimName model.ClaimName, claimValue string) (*ClaimStatus, error)

func (*Service) GetClaims

func (s *Service) GetClaims(ctx context.Context, userID string) ([]*Claim, error)

func (*Service) GetIdentityVerificationStatus

func (s *Service) GetIdentityVerificationStatus(ctx context.Context, i *identity.Info) ([]ClaimStatus, error)

func (*Service) GetVerificationStatuses

func (s *Service) GetVerificationStatuses(ctx context.Context, is []*identity.Info) (map[string][]ClaimStatus, error)

func (*Service) IsUserVerified

func (s *Service) IsUserVerified(ctx context.Context, identities []*identity.Info) (bool, error)

func (*Service) MarkClaimVerified

func (s *Service) MarkClaimVerified(ctx context.Context, claim *Claim) error

func (*Service) NewVerifiedClaim

func (s *Service) NewVerifiedClaim(ctx context.Context, userID string, claimName string, claimValue string) *Claim

func (*Service) RemoveOrphanedClaims

func (s *Service) RemoveOrphanedClaims(ctx context.Context, userID string, identities []*identity.Info, authenticators []*authenticator.Info) error

func (*Service) ResetVerificationStatus

func (s *Service) ResetVerificationStatus(ctx context.Context, userID string) error

type StorePQ

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

func (*StorePQ) Create

func (s *StorePQ) Create(ctx context.Context, claim *Claim) error

func (*StorePQ) Delete

func (s *StorePQ) Delete(ctx context.Context, id string) error

func (*StorePQ) DeleteAll

func (s *StorePQ) DeleteAll(ctx context.Context, userID string) error

func (*StorePQ) Get

func (s *StorePQ) Get(ctx context.Context, userID string, claimName string, claimValue string) (*Claim, error)

func (*StorePQ) ListByClaimName

func (s *StorePQ) ListByClaimName(ctx context.Context, userID string, claimName string) ([]*Claim, error)

func (*StorePQ) ListByUser

func (s *StorePQ) ListByUser(ctx context.Context, userID string) ([]*Claim, error)

func (*StorePQ) ListByUserIDs

func (s *StorePQ) ListByUserIDs(ctx context.Context, userIDs []string) ([]*Claim, error)

func (*StorePQ) ListByUserIDsAndClaimNames

func (s *StorePQ) ListByUserIDsAndClaimNames(ctx context.Context, userIDs []string, claimNames []string) ([]*Claim, error)

Jump to

Keyboard shortcuts

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