auth

package
v0.0.0-...-9d12082 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PublicPath = []string{"/", "/healthz", "/api/user/register", "/api/user/login", "/api/dealership/template"}

PublicPath is a slice contain all paths that we don't use JWT middleware

View Source
var RBAC = struct {
	AllRBAC       []string `role:"ALL"`
	SuperRBAC     []string `role:"SUPER"`
	AdminRBAC     []string `role:"ADMIN"`
	UserRBAC      []string `role:"USER"`
	DeveloperRBAC []string `role:"DEVELOPER"`
}{
	AllRBAC:       []string{"SUPER", "ADMIN", "DEVELOPER", "USER"},
	SuperRBAC:     []string{"SUPER", "ADMIN", "DEVELOPER", "USER"},
	AdminRBAC:     []string{"ADMIN", "USER"},
	UserRBAC:      []string{"USER"},
	DeveloperRBAC: []string{"DEVELOPER"},
}
View Source
var StartBy = []string{"/api/inspection-result"}

Functions

func Admin

func Admin() echo.MiddlewareFunc

func CheckPermission

func CheckPermission(role, object string) bool

func Developer

func Developer() echo.MiddlewareFunc

func DeveloperToken

func DeveloperToken(id int, username string, role string) (string, error)

func GetRBACByRole

func GetRBACByRole(role string) ([]string, bool)

func GetUserID

func GetUserID(c echo.Context) (uint, bool)

func JWT

func JWT() echo.MiddlewareFunc

JWT provides a JSON Web Token (JWT) authentication middleware.

For valid token, it sets the user in context and calls next handler. For invalid token, it sends 401 - Unauthorized response. For missing or invalid Authorization header, it sends 400 - Bad Request.

func MuvitToken

func MuvitToken(authToken, authSecret string) (string, error)

func NewToken

func NewToken(id int, username string, role string) (string, error)

func Super

func Super() echo.MiddlewareFunc

func User

func User() echo.MiddlewareFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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