auth

package
v0.0.0-...-7f74711 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCredentials = echo.NewHTTPError(http.StatusUnauthorized, "Username or password does not exist")
)

Custom errors

Functions

This section is empty.

Types

type Auth

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

Auth represents auth application service

func Initialize

func Initialize(db *pg.DB, j TokenGenerator, sec Securer, rbac RBAC) Auth

Initialize initializes auth application service

func New

func New(db *pg.DB, udb UserDB, j TokenGenerator, sec Securer, rbac RBAC) Auth

New creates new iam service

func (Auth) Authenticate

func (a Auth) Authenticate(c echo.Context, user, pass string) (homeschooling.AuthToken, error)

Authenticate tries to authenticate the user provided by username and password

func (Auth) Me

func (a Auth) Me(c echo.Context) (homeschooling.User, error)

Me returns info about currently logged user

func (Auth) Refresh

func (a Auth) Refresh(c echo.Context, refreshToken string) (string, error)

Refresh refreshes jwt token and puts new claims inside

type RBAC

type RBAC interface {
	User(echo.Context) homeschooling.AuthUser
}

RBAC represents role-based-access-control interface

type Securer

type Securer interface {
	HashMatchesPassword(string, string) bool
	Token(string) string
}

Securer represents security interface

type Service

type Service interface {
	Authenticate(echo.Context, string, string) (homeschooling.AuthToken, error)
	Refresh(echo.Context, string) (string, error)
	Me(echo.Context) (homeschooling.User, error)
}

Service represents auth service interface

type TokenGenerator

type TokenGenerator interface {
	GenerateToken(homeschooling.User) (string, error)
}

TokenGenerator represents token generator (jwt) interface

type UserDB

type UserDB interface {
	View(orm.DB, int) (homeschooling.User, error)
	FindByUsername(orm.DB, string) (homeschooling.User, error)
	FindByToken(orm.DB, string) (homeschooling.User, error)
	Update(orm.DB, homeschooling.User) error
}

UserDB represents user repository interface

Directories

Path Synopsis
platform

Jump to

Keyboard shortcuts

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