middlewarex

package
v0.0.96 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 73

Documentation

Index

Constants

View Source
const SpaceIDKey ctxKeySpaceID = 0

SpaceIDKey is the key that holds the unique space ID in a request context.

View Source
const UserIDKey ctxKeyUserID = 0

UserIDKey is the key that holds the unique user ID in a request context.

Variables

This section is empty.

Functions

func CheckAccess

func CheckAccess(appSlug string, index int, GetOrg func(ctx context.Context) (int, error)) func(h http.Handler) http.Handler

CheckAccess middleware to check if user can access the application

func CheckSpace

func CheckSpace(index int) func(h http.Handler) http.Handler

CheckSpace check X-Space in header

func CheckSuperOrganisation

func CheckSuperOrganisation(app string, GetOrganisation func(ctx context.Context) (int, error)) func(h http.Handler) http.Handler

CheckSuperOrganisation checks weather organisation of user is super org or not

func CheckUser

func CheckUser(h http.Handler) http.Handler

CheckUser check X-User in header

func GetSpace

func GetSpace(ctx context.Context) (int, error)

GetSpace return space ID

func GetSuperOrganisationID

func GetSuperOrganisationID(app string) (int, error)

GetSuperOrganisationID get superorganisation id from keto policy

func GetUser

func GetUser(ctx context.Context) (int, error)

GetUser return user ID

func GormRequestID

func GormRequestID(db **gorm.DB) func(h http.Handler) http.Handler

GormRequestID returns middleware to add request_id in gorm context

func ValidateAPIToken

func ValidateAPIToken(header string) func(h http.Handler) http.Handler

ValidateAPIToken validates the API tokens from kavach server

Types

type KetoPolicy

type KetoPolicy struct {
	ID          string   `json:"id"`
	Subjects    []string `json:"subjects"`
	Actions     []string `json:"actions"`
	Resources   []string `json:"resources"`
	Effect      string   `json:"effect"`
	Description string   `json:"description"`
}

KetoPolicy model

type KetoRelationTuple added in v0.0.80

type KetoRelationTuple struct {
	Namespace string `json:"namespace"`
	Relation  string `json:"relation"`
	Object    string `json:"object"`
	Subject   string `json:"subject_id"`
}

type KetoResponse added in v0.0.82

type KetoResponse struct {
	Tuples []KetoRelationTuple `json:"relation_tuples"`
}

type ValidationBody

type ValidationBody struct {
	Token string `json:"token" validate:"required"`
}

Jump to

Keyboard shortcuts

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