usecases

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DisableUseCase

type DisableUseCase struct {
	Logger   models.Logger
	EventBus models.EventBus
	TOTPRepo TOTPRepository
}

func NewDisableUseCase

func NewDisableUseCase(
	logger models.Logger,
	eventBus models.EventBus,
	totpRepo TOTPRepository,
) *DisableUseCase

func (*DisableUseCase) Disable

func (uc *DisableUseCase) Disable(ctx context.Context, userID string) error

type EnableUseCase

type EnableUseCase struct {
	Config            *types.TOTPPluginConfig
	Logger            models.Logger
	EventBus          models.EventBus
	UserService       rootservices.UserService
	TokenService      rootservices.TokenService
	Verification      rootservices.VerificationService
	TOTPService       *services.TOTPService
	BackupCodeService *services.BackupCodeService
	TOTPRepo          TOTPRepository
}

func NewEnableUseCase

func NewEnableUseCase(
	config *types.TOTPPluginConfig,
	logger models.Logger,
	eventBus models.EventBus,
	userService rootservices.UserService,
	tokenService rootservices.TokenService,
	verificationService rootservices.VerificationService,
	totpService *services.TOTPService,
	backupCodeService *services.BackupCodeService,
	totpRepo TOTPRepository,
) *EnableUseCase

func (*EnableUseCase) Enable

func (uc *EnableUseCase) Enable(ctx context.Context, userID string, issuer string) (*types.EnableResult, error)

type GenerateBackupCodesUseCase

type GenerateBackupCodesUseCase struct {
	BackupCodeService *services.BackupCodeService
	TOTPRepo          TOTPRepository
}

func NewGenerateBackupCodesUseCase

func NewGenerateBackupCodesUseCase(
	backupCodeService *services.BackupCodeService,
	totpRepo TOTPRepository,
) *GenerateBackupCodesUseCase

func (*GenerateBackupCodesUseCase) Generate

func (uc *GenerateBackupCodesUseCase) Generate(ctx context.Context, userID string) ([]string, error)

type GetTOTPURIUseCase

type GetTOTPURIUseCase struct {
	Config       *types.TOTPPluginConfig
	UserService  rootservices.UserService
	TokenService rootservices.TokenService
	TOTPService  *services.TOTPService
	TOTPRepo     TOTPReadRepository
}

func NewGetTOTPURIUseCase

func NewGetTOTPURIUseCase(
	config *types.TOTPPluginConfig,
	userService rootservices.UserService,
	tokenService rootservices.TokenService,
	totpService *services.TOTPService,
	totpRepo TOTPReadRepository,
) *GetTOTPURIUseCase

func (*GetTOTPURIUseCase) GetTOTPURI

func (uc *GetTOTPURIUseCase) GetTOTPURI(ctx context.Context, userID string, issuer string) (string, error)

type TOTPCreateRepository

type TOTPCreateRepository interface {
	Create(ctx context.Context, userID, secret, backupCodes string) (*types.TOTPRecord, error)
	CreateTrustedDevice(ctx context.Context, userID, token, userAgent string, expiresAt time.Time) (*types.TrustedDevice, error)
}

type TOTPReadRepository

type TOTPReadRepository interface {
	GetByUserID(ctx context.Context, userID string) (*types.TOTPRecord, error)
}

type TOTPTrustedDeviceRepository

type TOTPTrustedDeviceRepository interface {
	DeleteTrustedDevicesByUserID(ctx context.Context, userID string) error
}

type TOTPWriteRepository

type TOTPWriteRepository interface {
	DeleteByUserID(ctx context.Context, userID string) error
	SetEnabled(ctx context.Context, userID string, enabled bool) error
	UpdateBackupCodes(ctx context.Context, userID, backupCodes string) error
	CompareAndSwapBackupCodes(ctx context.Context, userID, expectedBackupCodes, newBackupCodes string) (bool, error)
}

type UseCases

type UseCases struct {
	Enable              *EnableUseCase
	Disable             *DisableUseCase
	GetTOTPURI          *GetTOTPURIUseCase
	VerifyTOTP          *VerifyTOTPUseCase
	GenerateBackupCodes *GenerateBackupCodesUseCase
	VerifyBackupCode    *VerifyBackupCodeUseCase
}

type VerifyBackupCodeUseCase

type VerifyBackupCodeUseCase struct {
	GlobalConfig        *models.Config
	Config              *types.TOTPPluginConfig
	Logger              models.Logger
	EventBus            models.EventBus
	TokenService        rootservices.TokenService
	SessionService      rootservices.SessionService
	UserService         rootservices.UserService
	VerificationService rootservices.VerificationService
	BackupCodeService   *services.BackupCodeService
	TOTPRepo            TOTPRepository
}

func NewVerifyBackupCodeUseCase

func NewVerifyBackupCodeUseCase(
	globalConfig *models.Config,
	config *types.TOTPPluginConfig,
	logger models.Logger,
	eventBus models.EventBus,
	tokenService rootservices.TokenService,
	sessionService rootservices.SessionService,
	userService rootservices.UserService,
	verificationService rootservices.VerificationService,
	backupCodeService *services.BackupCodeService,
	totpRepo TOTPRepository,
) *VerifyBackupCodeUseCase

func (*VerifyBackupCodeUseCase) Verify

func (uc *VerifyBackupCodeUseCase) Verify(ctx context.Context, pendingToken, code string, trustDevice bool, ipAddress, userAgent *string) (*types.VerifyResult, error)

type VerifyTOTPUseCase

type VerifyTOTPUseCase struct {
	GlobalConfig        *models.Config
	Config              *types.TOTPPluginConfig
	Logger              models.Logger
	EventBus            models.EventBus
	TokenService        rootservices.TokenService
	SessionService      rootservices.SessionService
	UserService         rootservices.UserService
	VerificationService rootservices.VerificationService
	TOTPService         *services.TOTPService
	TOTPRepo            TOTPRepository
}

func NewVerifyTOTPUseCase

func NewVerifyTOTPUseCase(
	globalConfig *models.Config,
	config *types.TOTPPluginConfig,
	logger models.Logger,
	eventBus models.EventBus,
	tokenService rootservices.TokenService,
	sessionService rootservices.SessionService,
	userService rootservices.UserService,
	verificationService rootservices.VerificationService,
	totpService *services.TOTPService,
	totpRepo TOTPRepository,
) *VerifyTOTPUseCase

func (*VerifyTOTPUseCase) Verify

func (uc *VerifyTOTPUseCase) Verify(ctx context.Context, pendingToken, code string, trustDevice bool, ipAddress, userAgent *string) (*types.VerifyResult, error)

Jump to

Keyboard shortcuts

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