auth

package
v0.0.0-...-4bd9efa Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeDay = time.Hour * 24
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationResponse

type AuthenticationResponse struct {
	ID          uuid.UUID        `json:"id,omitempty"`
	AccessToken *jwt.AccessToken `json:"accessToken"`
}

type AuthenticationResult

type AuthenticationResult struct {
	ID           uuid.UUID                `json:"id,omitempty"`
	AccessToken  *jwt.AccessToken         `json:"accessToken"`
	RefreshToken *repository.RefreshToken `json:"refreshToken"`
}

func (*AuthenticationResult) ToAuthenticationResponse

func (a *AuthenticationResult) ToAuthenticationResponse() *AuthenticationResponse

type Handler

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

func NewHandler

func NewHandler(cfg *config.Jwt, db *pgxpool.Pool, queries *repository.Queries) *Handler

func (*Handler) LoginHandler

func (h *Handler) LoginHandler(w http.ResponseWriter, r *http.Request) error

func (*Handler) RefreshTokenHandler

func (h *Handler) RefreshTokenHandler(w http.ResponseWriter, r *http.Request) error

func (*Handler) RegisterHandler

func (h *Handler) RegisterHandler(w http.ResponseWriter, r *http.Request) error

func (*Handler) RevokeTokenHandler

func (h *Handler) RevokeTokenHandler(w http.ResponseWriter, r *http.Request) error

type LoginRequest

type LoginRequest struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

type RegisterRequest

type RegisterRequest struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

func (*RegisterRequest) ToRegisterParams

func (r *RegisterRequest) ToRegisterParams() (*repository.RegisterParams, error)

type Service

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

func NewService

func NewService(cfg *config.Jwt, db *pgxpool.Pool, queries *repository.Queries) *Service

func (*Service) Login

func (*Service) RefreshToken

func (s *Service) RefreshToken(ctx context.Context, token string) (*AuthenticationResult, error)

func (*Service) Register

func (*Service) RevokeToken

func (s *Service) RevokeToken(ctx context.Context, token string) error

Jump to

Keyboard shortcuts

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