auth

package
v0.0.0-...-555e775 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashMatchesPassword

func HashMatchesPassword(hash, password string) bool

HashMatchesPassword matches hash with password. Returns true if hash and password match.

func HashPassword

func HashPassword(password string) string

HashPassword hashes the password using bcrypt

Types

type JWT

type JWT interface {
	GenerateToken(*model.User) (string, string, error)
}

JWT represents jwt interface

type Service

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

Service represents auth application service

func New

func New(udb model.UserDB, j JWT) *Service

New creates new auth service

func (*Service) Authenticate

func (s *Service) Authenticate(c context.Context, user, pass string) (*model.AuthToken, error)

Authenticate tries to authenticate the user provided by username and password

func (*Service) Refresh

func (s *Service) Refresh(c context.Context, token string) (*model.RefreshToken, error)

Refresh refreshes jwt token and puts new claims inside

func (*Service) User

func (s *Service) User(c *gin.Context) *model.AuthUser

User returns user data stored in jwt token

Jump to

Keyboard shortcuts

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