auth

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: MIT Imports: 6 Imported by: 27

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) (*gorsk.AuthToken, error)

Authenticate tries to authenticate the user provided by username and password

func (*Auth) Me

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

Me returns info about currently logged user

func (*Auth) Refresh

func (a *Auth) Refresh(c echo.Context, token string) (*gorsk.RefreshToken, error)

Refresh refreshes jwt token and puts new claims inside

type RBAC

type RBAC interface {
	User(echo.Context) *gorsk.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) (*gorsk.AuthToken, error)
	Refresh(echo.Context, string) (*gorsk.RefreshToken, error)
	Me(echo.Context) (*gorsk.User, error)
}

Service represents auth service interface

type TokenGenerator

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

TokenGenerator represents token generator (jwt) interface

type UserDB

type UserDB interface {
	View(orm.DB, int) (*gorsk.User, error)
	FindByUsername(orm.DB, string) (*gorsk.User, error)
	FindByToken(orm.DB, string) (*gorsk.User, error)
	Update(orm.DB, *gorsk.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