security

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Protect

func Protect(config *config.Config, handlerFunc func(w http.ResponseWriter, r *http.Request, token *JwtToken), allowedScopes []string, requireAdmin bool) func(w http.ResponseWriter, r *http.Request)

Protect authenticates and makes sure that caller is authorized to make the call before before invoking actual handler

Types

type JwtToken

type JwtToken struct {
	// UserID is id of user matchimg the token
	UserID   uuid.UUID `json:"user,omitempty"`
	UserName string    `json:"name,omitempty"`
	TenantID uuid.UUID `json:"tenant,omitempty"`
	Scopes   []string  `json:"scope,omitempty"`
	Admin    bool      `json:"admin,omitempty"`
	jwt.StandardClaims
}

JwtToken represents the parsed Token from Authentication Header

func (*JwtToken) GetScopes

func (token *JwtToken) GetScopes() []string

GetScopes returns the scopes associated with the Token

func (*JwtToken) GetTenantID

func (token *JwtToken) GetTenantID() uuid.UUID

GetTenantID returns the tenantId associated with the Token

func (*JwtToken) GetUserID

func (token *JwtToken) GetUserID() uuid.UUID

GetUserID returns the userId associated with the Token

func (*JwtToken) GetUserName

func (token *JwtToken) GetUserName() string

GetUserName returns the userName associated with the Token

Jump to

Keyboard shortcuts

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