auth

package
v0.0.0-...-264fe26 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CstmSessionValidatorKey = "custom_session_format"
	CstmTokenValidatorKey   = "custom_token_format"
	DfltEmailKey            = "email"
	DfltRequiredKey         = "required"
)
View Source
const (
	SesKeyLogin string = "login"
)

Variables

This section is empty.

Functions

func NewAuthRouter

func NewAuthRouter(
	cookieName string,
	loginURL string, logoutURL, verifyURL string, resendURL string,
	sservice session.Service,
	tservice token.Service,
	aus AuthUserService,
	cc session.CookieConf, sc session.Conf,
	logger logr.Logger,
	resendAttempts int, resendTimeout time.Duration,
) (http.Handler, error)

func RegistrateCustomVldtrs

func RegistrateCustomVldtrs() (*validator.Validate, ut.Translator, error)

func RegistrateVldtrs

func RegistrateVldtrs(validatorsList map[string]validatorCfg) (*validator.Validate, ut.Translator, error)

func SessionValidator

func SessionValidator() func(fl validator.FieldLevel) bool

func TokenValidator

func TokenValidator() func(fl validator.FieldLevel) bool

Types

type AuthMW

type AuthMW struct {
	CookieName        string
	SessionContextKey string
	SService          gs.Service
	Logger            logr.Logger
	Vld               *validator.Validate

	CtxRqIDKey interface{}
}

func (*AuthMW) Auth

func (mw *AuthMW) Auth() func(next http.Handler) http.Handler

type AuthUser

type AuthUser interface {
	GetID() string
}

type AuthUserService

type AuthUserService interface {
	GetUserByKey(key string) (AuthUser, error)
}

type ErrorResponse

type ErrorResponse struct {
	Code        int    `json:"code"`
	Message     string `json:"message"`
	Description string `json:"description"`
}

type ErrorValidationResponse

type ErrorValidationResponse struct {
	Code        int               `json:"code"`
	Message     string            `json:"message"`
	Description string            `json:"description"`
	Details     []ValidationError `json:"details"`
}

type LoginRequest

type LoginRequest struct {
	Login string `json:"login" validate:"required,email"`
}

type ProcessLoginData

type ProcessLoginData struct {
	Login       string
	Attempts    int
	CanResendAt time.Time
}

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

type VerifyRequest

type VerifyRequest struct {
	Token string `json:"token" validate:"required,custom_token_format"`
}

type VerifyResponse

type VerifyResponse struct {
	Valid    bool `json:"valid"`
	CanRetry bool `json:"canRetry,omitempty"`
}

Directories

Path Synopsis
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