authcore

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadRequest = errors.New("bad request")
View Source
var ErrInternalServerError = errors.New("internal server error")
View Source
var ErrInvalidPID = errors.New("invalid PID")
View Source
var ErrInvalidToken = errors.New("invalid token")
View Source
var ErrMissingUsernameOrPassword = errors.New("missing username or password")
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

This section is empty.

Types

type AuthCore

type AuthCore struct {
	DS           AuthDatasource
	TokenEncoder AuthEncoder
	Store        AuthStore
	Notifier     AuthNotifier
}

func (*AuthCore) AssertConfigured

func (ac *AuthCore) AssertConfigured()

type AuthCredentials

type AuthCredentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type AuthDatasource

type AuthDatasource interface {
	FindPIDByValidCredentials(username string, password string) (PID, error)
	FindPIDByEmail(email string) (PID, error)
	ResetPassword(pid PID, password string) error
}

type AuthEncoder

type AuthEncoder interface {
	GenerateTokenFromPID(pid PID) (*Token, error)
}

type AuthNotifier

type AuthNotifier interface {
	NotifyResetPasswordToken(email string, token *Token, pid PID) error
	NotifyPasswordReseted(email string, pid PID) error
}

type AuthRecoveryPasswordRequest

type AuthRecoveryPasswordRequest struct {
	Email string `json:"email"`
}

type AuthRecoveryPasswordResponse

type AuthRecoveryPasswordResponse struct {
	Status bool    `json:"status"`
	Error  *string `json:"error,omitempty"`
}

type AuthResetPasswordRequest

type AuthResetPasswordRequest struct {
	Token    string `json:"token"`
	Password string `json:"password"`
}

type AuthResetPasswordResponse

type AuthResetPasswordResponse struct {
	Status bool    `json:"status"`
	Error  *string `json:"error,omitempty"`
}

type AuthStore

type AuthStore interface {
	StoreAuthToken(token *Token, pid PID) error
	GetAuthTokenPID(token string) (PID, error)
	DeleteAuthToken(token string) error
	StoreResetPasswordToken(token *Token, pid PID) error
	GetResetPasswordTokenPID(token string) (PID, error)
	DeleteResetPasswordToken(token string) error
}

type AuthTokenErrorResponse

type AuthTokenErrorResponse struct {
	Error string `json:"error"`
}

type AuthTokenResponse

type AuthTokenResponse struct {
	Token *Token `json:"token"`
}

type PID

type PID interface{}

type Token

type Token struct {
	Value      string     `json:"value"`
	Expiration *time.Time `json:"expiration"`
}

Jump to

Keyboard shortcuts

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