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

auth

package
v0.9.82 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 23 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 WithLoginAccountRequests added in v0.9.79

func WithLoginAccountRequests(requests int) Option

func WithLoginIPRequests added in v0.9.79

func WithLoginIPRequests(requests int) Option

func WithLoginWindow added in v0.9.79

func WithLoginWindow(window time.Duration) Option

func WithMinPasswordEntropyBits

func WithMinPasswordEntropyBits(bits int) Option

func WithRateLimiterEnabled added in v0.9.79

func WithRateLimiterEnabled(enabled bool) Option

func WithRefreshSessionRequests added in v0.9.79

func WithRefreshSessionRequests(requests int) Option

func WithRefreshWindow added in v0.9.79

func WithRefreshWindow(window time.Duration) Option

func WithSignupIPRequests added in v0.9.79

func WithSignupIPRequests(requests int) Option

func WithSignupWindow added in v0.9.79

func WithSignupWindow(window time.Duration) 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) CheckIPLimit added in v0.9.79

func (s *Service) CheckIPLimit(ctx context.Context, action domain.AuthenticationAction, ip string) error

CheckIPLimit is called before decoding HTTP credentials. The transport uses its configured trusted-proxy policy to supply the client IP.

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) 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, 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) UpdateSelf added in v0.9.79

func (s *Service) UpdateSelf(ctx context.Context, uuid string, data *domain.UpdateSelfData) 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