authenticating

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidLoginErr = errors.New("it seems your login credentials are invalid, verify them and try again")
View Source
var ProtectedRouteErr = errors.New("it seems you don't have or didn't pass valid credentials to this route")

Functions

This section is empty.

Types

type Gatekeeper

type Gatekeeper interface {
	Sign(clientID string) (Token, error)
	Verify(tokenDigest string) (Token, error)
}

type Login

type Login struct {
	CPF    string `json:"cpf"`
	Secret string `json:"secret"`
}

type Repository

type Repository interface {
	AddToken(ctx context.Context, token Token) error
	GetTokenByID(ctx context.Context, id primitive.ObjectID) (Token, error)
}

type Service

type Service interface {
	Sign(ctx context.Context, login Login, secretDigest string, clientID string) (Token, error)
	Verify(ctx context.Context, tokenDigest string) (Token, error)
}

func NewService

func NewService(repository Repository, gatekeeper Gatekeeper) Service

type Token

type Token struct {
	ID       *primitive.ObjectID `json:"id,omitempty" bson:"_id"`
	ClientID string              `json:"client_id,omitempty" bson:"client_id"`
	Digest   string              `json:"token,omitempty" bson:"token"`
}

Jump to

Keyboard shortcuts

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