Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v0.9.78 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RetrieveAuthFromContext

func RetrieveAuthFromContext(ctx context.Context) *domain.ContextAuthInfo

RetrieveAuthFromContext retrieve auth state from context. Returns pointer to copy of data, which can be mutated without side effects.

func SetAuthToContext

func SetAuthToContext(ctx context.Context, authInfo domain.ContextAuthInfo) context.Context

SetAuthToContext sets auth state to context.

Types

type Option

type Option func(*Service)

func WithJWTAccessTokenTTL

func WithJWTAccessTokenTTL(ttl time.Duration) Option

func WithJWTAudience

func WithJWTAudience(audience []string) Option

func WithJWTIssuer

func WithJWTIssuer(issuer string) Option

func WithJWTRefreshTokenTTL

func WithJWTRefreshTokenTTL(ttl time.Duration) Option

func WithJWTSecrets

func WithJWTSecrets(secret []string) Option

func WithLogger

func WithLogger(logger *slog.Logger) Option

func WithMinPasswordEntropyBits

func WithMinPasswordEntropyBits(bits int) Option

type Service

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

func NewService

func NewService(
	repository repository,
	outboxService outboxService,
	cache cache,
	opts ...Option,
) *Service

func (*Service) CheckPasswordStrength

func (s *Service) CheckPasswordStrength(password string) error

func (*Service) CreateUser

func (s *Service) CreateUser(ctx context.Context, data *domain.CreateUserData) (*models.User, error)

func (*Service) DeleteUser

func (s *Service) DeleteUser(ctx context.Context, uuid string) error

func (*Service) GetUserByID

func (s *Service) GetUserByID(ctx context.Context, id int) (*models.User, error)

func (*Service) GetUserByUUID

func (s *Service) GetUserByUUID(ctx context.Context, uuid string) (*models.User, error)

func (*Service) InvalidateJWTToken

func (s *Service) InvalidateJWTToken(ctx context.Context, token string, until time.Time) error

func (*Service) ListUsers

func (s *Service) ListUsers(ctx context.Context, limit, offset int) ([]*models.User, error)

func (*Service) Login

func (s *Service) Login(ctx context.Context, email string, password string) (*domain.Tokens, error)

func (*Service) Logout

func (s *Service) Logout(ctx context.Context, accessToken, refreshToken string) error

func (*Service) RecentlyUsedTokensChan

func (s *Service) RecentlyUsedTokensChan() <-chan domain.TokenWasUsed

func (*Service) Refresh

func (s *Service) Refresh(ctx context.Context, token string) (*domain.Tokens, error)

func (*Service) SignUp

func (s *Service) SignUp(ctx context.Context, email string, password string) (*models.User, error)

func (*Service) UpdateUser

func (s *Service) UpdateUser(ctx context.Context, uuid string, data *domain.UpdateUserData) error

func (*Service) ValidateAPIToken

func (s *Service) ValidateAPIToken(ctx context.Context, token string) (*models.Token, error)

func (*Service) ValidateJWTToken

func (s *Service) ValidateJWTToken(
	ctx context.Context,
	token string,
	expectedPurpose domain.JWTTokenPurpose,
) (*domain.JWTClaims, error)

Directories

Path Synopsis
adapters
grpc/v1/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
http/v1/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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