auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuthStrategy

type BasicAuthStrategy struct {
	// contains filtered or unexported fields
}

BasicAuthStrategy implements AuthStrategy for CLI (no JWT, just password check)

func (*BasicAuthStrategy) GenerateToken

func (s *BasicAuthStrategy) GenerateToken(user *domain.User) (string, error)

func (*BasicAuthStrategy) GetCurrentUserID

func (s *BasicAuthStrategy) GetCurrentUserID(ctx context.Context) (uuid.UUID, error)

func (*BasicAuthStrategy) Login

func (s *BasicAuthStrategy) Login(
	ctx context.Context,
	identity, password string,
) (
	user *domain.User,
	err error,
)

type JWTAuthStrategy

type JWTAuthStrategy struct {
	// contains filtered or unexported fields
}

JWTAuthStrategy implements AuthStrategy for JWT-based authentication

func NewJWTAuthStrategy

func NewJWTAuthStrategy(
	uow repository.UnitOfWork,
	cfg config.JwtConfig,
	logger *slog.Logger,
) *JWTAuthStrategy

func (*JWTAuthStrategy) GenerateToken

func (s *JWTAuthStrategy) GenerateToken(user *domain.User) (string, error)

func (*JWTAuthStrategy) GetCurrentUserID

func (s *JWTAuthStrategy) GetCurrentUserID(
	ctx context.Context,
) (userID uuid.UUID, err error)

func (*JWTAuthStrategy) Login

func (s *JWTAuthStrategy) Login(
	ctx context.Context,
	identity, password string,
) (
	u *domain.User,
	err error,
)

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewBasicAuthService

func NewBasicAuthService(uow repository.UnitOfWork, logger *slog.Logger) *Service

func NewService

func NewService(
	uow repository.UnitOfWork,
	strategy Strategy,
	logger *slog.Logger,
) *Service

func (*Service) CheckPasswordHash

func (s *Service) CheckPasswordHash(
	password, hash string,
) bool

func (*Service) GenerateToken

func (s *Service) GenerateToken(user *domain.User) (string, error)

func (*Service) GetCurrentUserId

func (s *Service) GetCurrentUserId(
	token *jwt.Token,
) (userID uuid.UUID, err error)

func (*Service) Login

func (s *Service) Login(
	ctx context.Context,
	identity, password string,
) (u *domain.User, err error)

func (*Service) ValidEmail

func (s *Service) ValidEmail(email string) bool

type Strategy

type Strategy interface {
	Login(ctx context.Context, identity, password string) (*domain.User, error)
	GetCurrentUserID(ctx context.Context) (uuid.UUID, error)
	GenerateToken(user *domain.User) (string, error)
}

Jump to

Keyboard shortcuts

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