auth

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 12 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 NewBasicAuthStrategy added in v1.2.0

func NewBasicAuthStrategy(
	uow repository.UnitOfWork,
	logger *slog.Logger,
) *BasicAuthStrategy

func (*BasicAuthStrategy) GenerateToken

func (s *BasicAuthStrategy) GenerateToken(ctx context.Context, u *dto.UserRead) (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,
) (u *dto.UserRead, err error)

type JWTStrategy added in v1.2.0

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

JWTStrategy implements AuthStrategy for JWT-based authentication

func NewJWTStrategy added in v1.2.0

func NewJWTStrategy(
	uow repository.UnitOfWork,
	cfg *config.Jwt,
	logger *slog.Logger,
) *JWTStrategy

func (*JWTStrategy) GenerateToken added in v1.2.0

func (s *JWTStrategy) GenerateToken(
	ctx context.Context,
	u *dto.UserRead) (string, error)

func (*JWTStrategy) GetCurrentUserID added in v1.2.0

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

func (*JWTStrategy) Login added in v1.2.0

func (s *JWTStrategy) Login(
	ctx context.Context,
	identity, password string,
) (
	u *dto.UserRead,
	err error,
)

type Service

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

func New added in v1.2.0

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

func NewWithBasic added in v1.2.0

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

func NewWithJWT added in v1.2.0

func NewWithJWT(
	uow repository.UnitOfWork,
	cfg *config.Jwt,
	logger *slog.Logger,
) *Service

func (*Service) CheckPasswordHash

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

func (*Service) GenerateToken

func (s *Service) GenerateToken(
	ctx context.Context,
	u *dto.UserRead,
) (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 *dto.UserRead, err error)

func (*Service) ValidEmail

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

type Strategy

type Strategy interface {
	Login(ctx context.Context, identity, password string) (*dto.UserRead, error)
	GetCurrentUserID(ctx context.Context) (uuid.UUID, error)
	GenerateToken(ctx context.Context, u *dto.UserRead) (string, error)
}

Jump to

Keyboard shortcuts

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