service

package
v0.0.0-...-79dbf9b Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Access

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

Access is a service that verifies access tokens

func NewAccess

func NewAccess(log *zerolog.Logger, userRepository UserRepository, jws string) *Access

NewAccess creates and configures an Access service

func (*Access) ValidateToken

func (a *Access) ValidateToken(IDToken string) (string, error)

ValidateToken decodes the user info in an ID token and checks its iss, sub and exp claims

type BcryptHasher

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

BcryptHasher implements the Hasher and HashComparer interfaces and uses Provos and Mazières's bcrypt adaptive hashing algorithm

func (*BcryptHasher) Compare

func (bh *BcryptHasher) Compare(hash, password string) error

Compare compares a hashed password to a clear password

func (*BcryptHasher) Hash

func (bh *BcryptHasher) Hash(password string) (string, error)

Hash hashes a password

type HashComparer

type HashComparer interface {
	Compare(hash, password string) error
}

HashComparer describes something that can compare hashed passwords with clear passwords

type Hasher

type Hasher interface {
	Hash(password string) (string, error)
}

Hasher describes something that can hash passwords

type HasherComparer

type HasherComparer interface {
	Hasher
	HashComparer
}

HasherComparer describes something that can hash passwords and compare them with clear passwords

func NewBcryptHasher

func NewBcryptHasher(runs int) HasherComparer

NewBcryptHasher instanciates a BcryptHasher and sets its number of runs

type Token

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

Token is a service that generates JWT tokens

func NewToken

func NewToken(log *zerolog.Logger, user UserRepository, hash HashComparer, jws string) *Token

NewToken creates and configures an Token service

func (*Token) GenerateID

func (t *Token) GenerateID() string

GenerateID generate a unique ID

func (*Token) Login

func (t *Token) Login(userInfo *model.User) (string, error)

Login generates a signed JWT from the user information if it's valid

type UserRepository

type UserRepository interface {
	Retrieve(user *model.User) (*model.User, error)
}

UserRepository reprensents a user repository to get users from their ids

Jump to

Keyboard shortcuts

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