auth

package
v0.0.0-...-fd49861 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
}

func (*Auth) CreateToken

func (a *Auth) CreateToken(user model.User) (string, error)

CreateToken generates a signed JWT string based on user info.

func (*Auth) ReadAndSetKeys

func (a *Auth) ReadAndSetKeys()

ReadAndSetKeys will read public and private RSA keys and create a key for signing JWTs.

func (*Auth) UserIsInRole

func (a *Auth) UserIsInRole(d database.IDatabase, roles []constants.Role) gin.HandlerFunc

UserIsInRole accepts a list of roles and determines whether a user's role in a JWT is in that list.

func (*Auth) UserIsLoggedIn

func (a *Auth) UserIsLoggedIn() gin.HandlerFunc

UserIsLoggedIn will read the JWT in the request header and verify that it is legitimate.

type IAuth

type IAuth interface {
	ReadAndSetKeys()
	UserIsLoggedIn() gin.HandlerFunc
	UserIsInRole(d database.IDatabase, roles []constants.Role) gin.HandlerFunc
	CreateToken(user model.User) (string, error)
}

IAuth defines an interface for auth related functionality.

Jump to

Keyboard shortcuts

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