http

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLoginFailed         = httputil.Error{Code: "AU0001", Message: "login failed", StatusCode: http.StatusUnauthorized}
	ErrInvalidRefreshToken = httputil.Error{Code: "AU0002", Message: "invalid refresh token", StatusCode: http.StatusBadRequest}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	PrefixPath       string
	RTCookieSettings RTCookieSettings
}

type Controller

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

func NewController

func NewController(srv Service, v validator.Validator, opts ...Option) *Controller

func (*Controller) Register

func (c *Controller) Register(mux *httprouter.Router)

type Credentials

type Credentials struct {
	Username string `json:"username" validate:"required,max=50"`
	Password string `json:"password" validate:"required,min=8,max=27"`
}

type Option

type Option func(c *Config)

func WithPrefixPath

func WithPrefixPath(s string) Option

func WithRTCookieDomain

func WithRTCookieDomain(s string) Option

func WithRTCookieName

func WithRTCookieName(s string) Option

func WithRTCookieTTL

func WithRTCookieTTL(d time.Duration) Option

type RTCookieSettings

type RTCookieSettings struct {
	Name   string
	Domain string
	TTL    time.Duration
}

type RefreshToken

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

type Service

type Service interface {
	Login(ctx context.Context, cred core.Credentials, opts ...core.MetaOption) (core.TokenPair, error)
	RefreshSession(ctx context.Context, rs core.RefreshSession, opts ...core.MetaOption) (core.TokenPair, error)
	Logout(ctx context.Context, refreshToken string) error
}

type TokenPair

type TokenPair struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

Jump to

Keyboard shortcuts

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