service

package
v0.0.0-...-2a01338 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JWTBearerFormat = 2

	Access  jwtType = "access"
	Refresh jwtType = "refresh"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTCustomClaims

type JWTCustomClaims struct {
	UserName string `json:"username"`
	jwt.RegisteredClaims
}

type LoginRequest

type LoginRequest struct {
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

http request struct.

type RedisKey

type RedisKey string

type RefreshTokenRequest

type RefreshTokenRequest struct {
	RefreshToken string `json:"refresh_token" validate:"required"`
	AccessToken  string
}

type Service

type Service interface {
	// authenticate authenticates a user using username and password.
	// It returns a JWT token if authentication succeeds. Otherwise, an error is returned.
	Login(ctx context.Context, req LoginRequest) (loginResponse, error)
	Refresh(ctx context.Context, req RefreshTokenRequest) (refreshResponse, error)
}

Service encapsulates the authentication logic.

func New

func New(
	cfg *config.Config,
	rds redis.Client,
	repo repository.Repository,
	logger log.Logger,
	timeout time.Duration,
) Service

New creates a new authentication service.

Jump to

Keyboard shortcuts

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