auth

package
v0.0.0-...-20f649f Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPassword = errors.New("password provided did not match hash")
	ErrUserNotFound    = errors.New("failed to find user")
	ErrUserConflict    = errors.New("failed to register new user as email already used")
	ErrTokenRevoked    = errors.New("token is revoked")
	ErrInvalidInvite   = errors.New("invalid invite code provided")
)

Functions

func NewHTTPHandler

func NewHTTPHandler(u UseCase, c *config.Config, j *jwtauth.JWTAuth) chi.Router

Types

type Reader

type Reader interface {
	FindUserByEmailWithInstitution(ctx context.Context, email string) (*entity.User, error)
	FindInstitutionInviteLinkWithInstitution(ctx context.Context, code string) (*entity.InstitutionInviteLink, error)
	FindJWTRevocation(ctx context.Context, jti string) (*entity.JWTRevocation, error)
}

type Repository

type Repository interface {
	Reader
	Writer
}

func NewEntRepository

func NewEntRepository(ent *ent.Client) Repository

type UseCase

type UseCase interface {
	WhoAmI(ctx context.Context, token jwt.Token) (*entity.User, error)
	Login(ctx context.Context, email, password string) (*entity.Session, error)
	Register(ctx context.Context, inviteCode, firstName, lastName, email, password string) (*entity.Session, error)

	// CheckInviteCode retrieves an invite code and the associated institution from the repository
	CheckInviteCode(ctx context.Context, inviteCode string) (*entity.InstitutionInviteLink, error)
}

func NewUseCase

func NewUseCase(r Repository, c *config.Config, publicKey jwk.Key, privateKey jwk.Key) UseCase

type Writer

type Writer interface {
	CreateUser(ctx context.Context, instID int, instRole institution.Role, firstName, lastName, email string, password hash.Encoded, opts ...user.Option) (*entity.User, error)
	CreateJWTRevocation(ctx context.Context, jti string, expiry time.Time) (*entity.JWTRevocation, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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