Documentation
¶
Index ¶
- Variables
- type Module
- func (m *Module) CreateToken(tokenClaims TokenClaims) (string, error)
- func (m *Module) IsAggregateOpAuthorised(project, dbType, col, token string, req *model.AggregateRequest) (int, error)
- func (m *Module) IsCreateOpAuthorised(project, dbType, col, token string, req *model.CreateRequest) (int, error)
- func (m *Module) IsDeleteOpAuthorised(project, dbType, col, token string, req *model.DeleteRequest) (int, error)
- func (m *Module) IsFileOpAuthorised(project, token, path string, op utils.FileOpType, args map[string]interface{}) error
- func (m *Module) IsFuncCallAuthorised(project, service, function, token string, params interface{}) (TokenClaims, error)
- func (m *Module) IsReadOpAuthorised(project, dbType, col, token string, req *model.ReadRequest) (int, error)
- func (m *Module) IsUpdateOpAuthorised(project, dbType, col, token string, req *model.UpdateRequest) (int, error)
- func (m *Module) SetConfig(project string, secret string, rules config.Crud, fileStore *config.FileStore, ...)
- func (m *Module) SetSecret(secret string)
- type TokenClaims
Constants ¶
This section is empty.
Variables ¶
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
var ErrIncorrectRuleFieldType = errors.New("Auth: Incorrect rule field type")
ErrIncorrectRuleFieldType is thrown when the field type of a rule is of incorrect type
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 ¶
Module is responsible for authentication and authorisation
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
type TokenClaims ¶
type TokenClaims map[string]interface{}
TokenClaims holds the JWT token claims
func (TokenClaims) GetRole ¶ added in v0.10.0
func (c TokenClaims) GetRole() (string, error)
GetRole returns the role present in the token claims