auth

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectMatch = errors.New("Auth: The two fields do not match")

ErrIncorrectMatch is thrown when the field type of a rule is of incorrect type

View Source
var ErrIncorrectRuleFieldType = errors.New("Auth: Incorrect rule field type")

ErrIncorrectRuleFieldType is thrown when the field type of a rule is of incorrect type

View Source
var ErrRuleNotFound = errors.New("Auth: No rule has been provided")

ErrRuleNotFound is thrown when an error is not present in the auth object

Functions

This section is empty.

Types

type Module

type Module struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Module is responsible for authentication and authorisation

func Init

func Init(crud *crud.Module, functions *functions.Module) *Module

Init creates a new instance of the auth object

func (*Module) CreateToken

func (m *Module) CreateToken(tokenClaims TokenClaims) (string, error)

CreateToken generates a new JWT Token with the token claims

func (*Module) IsAggregateOpAuthorised

func (m *Module) IsAggregateOpAuthorised(project, dbType, col, token string, req *model.AggregateRequest) (int, error)

IsAggregateOpAuthorised checks if the crud operation is authorised

func (*Module) IsCreateOpAuthorised

func (m *Module) IsCreateOpAuthorised(project, dbType, col, token string, req *model.CreateRequest) (int, error)

IsCreateOpAuthorised checks if the crud operation is authorised

func (*Module) IsDeleteOpAuthorised

func (m *Module) IsDeleteOpAuthorised(project, dbType, col, token string, req *model.DeleteRequest) (int, error)

IsDeleteOpAuthorised checks if the crud operation is authorised

func (*Module) IsFileOpAuthorised

func (m *Module) IsFileOpAuthorised(project, token, path string, op utils.FileOpType, args map[string]interface{}) error

IsFileOpAuthorised checks if the caller is authorized to make the request

func (*Module) IsFuncCallAuthorised

func (m *Module) IsFuncCallAuthorised(project, service, function, token string, params interface{}) (TokenClaims, error)

IsFuncCallAuthorised checks if the func call is authorised

func (*Module) IsReadOpAuthorised

func (m *Module) IsReadOpAuthorised(project, dbType, col, token string, req *model.ReadRequest) (int, error)

IsReadOpAuthorised checks if the crud operation is authorised

func (*Module) IsUpdateOpAuthorised

func (m *Module) IsUpdateOpAuthorised(project, dbType, col, token string, req *model.UpdateRequest) (int, error)

IsUpdateOpAuthorised checks if the crud operation is authorised

func (*Module) SetConfig

func (m *Module) SetConfig(project string, secret string, rules config.Crud, fileStore *config.FileStore, functions *config.Functions)

SetConfig set the rules and secret key required by the auth block

func (*Module) SetSecret

func (m *Module) SetSecret(secret string)

SetSecret sets the secret key to be used for JWT authentication

type TokenClaims

type TokenClaims map[string]interface{}

TokenClaims holds the JWT token claims

Jump to

Keyboard shortcuts

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