auth

package module
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: GPL-3.0 Imports: 11 Imported by: 1

README

auth

Authentification Middleware for IRIS using gorm as a backend

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(user models.User, ctx iris.Context) bool

Check verifies the provided user against the DB

func CreateUser

func CreateUser(user models.User) (token string, id uuid.UUID)

CreateUser allow to store a user in the DB

func HasRole

func HasRole(ctx iris.Context, role string) bool

HasRole verify if the user has the requested Role

func Init

func Init(config Config) iris.Handler

Init exports the middleware function to initialize DB if needed, and populate the ctx.User() object at each run.

func IsAuth

func IsAuth(ctx iris.Context) bool

IsAuth returns true if User has been authenticated

func MiddleAuth

func MiddleAuth(ctx iris.Context)

MiddleAuth exports the middleware function to check authentification

func MiddleRole

func MiddleRole(role string) iris.Handler

MiddleRole check if the user has the required Role

Types

type Config

type Config struct {
	DataStore     *gorm.DB
	LoginRoute    string
	ReturnOnError bool
}

Config struct allows the configuration to be passed to the function at init

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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