auth

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidSigningMethod denotes a jwt signing method type not used by Space Cloud.
	ErrInvalidSigningMethod = errors.New("invalid signing method type")
	ErrTokenVerification    = errors.New("AUTH: JWT token could not be verified")
)
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(nodeID string, crud *crud.Module, schema *schema.Schema, removeProjectScope bool) *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) GetInternalAccessToken added in v0.12.0

func (m *Module) GetInternalAccessToken() (string, error)

GetInternalAccessToken returns the token that can be used internally by Space Cloud

func (*Module) GetSCAccessToken added in v0.15.0

func (m *Module) GetSCAccessToken() (string, error)

GetSCAccessToken returns the token that can be used to verify Space Cloud

func (*Module) IsAggregateOpAuthorised

func (m *Module) IsAggregateOpAuthorised(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, project, token, path string, op utils.FileOpType, args map[string]interface{}) (*PostProcess, error)

IsFileOpAuthorised checks if the caller is authorized to make the request

func (*Module) IsFuncCallAuthorised

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

IsFuncCallAuthorised checks if the func call is authorised

func (*Module) IsReadOpAuthorised

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

IsReadOpAuthorised checks if the crud operation is authorised

func (*Module) IsTokenInternal added in v0.13.0

func (m *Module) IsTokenInternal(token string) error

IsTokenInternal checks if the provided token is internally generated

func (*Module) IsUpdateOpAuthorised

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

IsUpdateOpAuthorised checks if the crud operation is authorised

func (*Module) PostProcessMethod added in v0.15.0

func (m *Module) PostProcessMethod(postProcess *PostProcess, result interface{}) error

PostProcessMethod to do processing on result

func (*Module) SetConfig

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

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

func (*Module) SetMakeHttpRequest added in v0.13.0

func (m *Module) SetMakeHttpRequest(function utils.MakeHttpRequest)

func (*Module) SetSecret

func (m *Module) SetSecret(secret string)

SetSecret sets the secret key to be used for JWT authentication

type PostProcess added in v0.15.0

type PostProcess struct {
	// contains filtered or unexported fields
}

PostProcess is responsible for implementing force and remove rules

type PostProcessAction added in v0.15.0

type PostProcessAction struct {
	Action string
	Field  string
	Value  interface{}
}

PostProcessAction has action -> force/remove and field,value depending on the Action.

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

Jump to

Keyboard shortcuts

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