util

package
v0.0.0-...-c7114d0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const OrganisationIDKey ctxKeyOrganisationID = 0

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

Variables

View Source
var Template *template.Template

Template template object

Functions

func CheckCategoryName

func CheckCategoryName(space uint, name string, IsForTemplate bool) bool

CheckCategoryName checks if the category table contains any entry with same name

func CheckKetoPolicy

func CheckKetoPolicy(entity, action string) func(h http.Handler) http.Handler

CheckKetoPolicy returns middleware that checks the permissions of user from keto server

func CheckName

func CheckName(space uint, name, table string) bool

CheckName checks if the table contains any entry with same name

func CheckOwnerFromKavach

func CheckOwnerFromKavach(uID, oID int) (bool, error)

CheckOwnerFromKavach checks if user is owner of organisation

func CheckSpaceKetoPermission

func CheckSpaceKetoPermission(action string, oID, uID uint) error

CheckSpaceKetoPermission checks keto policy for operations on space

func GenerateOrganisation

func GenerateOrganisation(h http.Handler) http.Handler

GenerateOrganisation check X-User in header

func GetAllOrganisationsMap

func GetAllOrganisationsMap(q string) (map[uint]model.Organisation, error)

GetAllOrganisationsMap return slice of all organisations

func GetOrganisation

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

GetOrganisation return organisation ID

func HTMLDescription

func HTMLDescription(jsonData postgres.Jsonb) (string, error)

func IsAllowed

func IsAllowed(result KetoAllowed) (int, error)

IsAllowed checks if keto policy allows user to action on resource returns (status code, error)

func KavachChecker

func KavachChecker() error

KavachChecker checks if Kavach is ready

func KetoChecker

func KetoChecker() error

KetoChecker checks if keto is ready

func NilJsonb

func NilJsonb() postgres.Jsonb

NilJsonb return nil json

func Request

func Request(method, path string, body interface{}) (*http.Response, error)

Request does get request to keto with empty body

func RequestOrganisation

func RequestOrganisation(r *http.Request) ([]model.Organisation, error)

RequestOrganisation - request kavach to get all organisations of user

func SetupTemplates

func SetupTemplates()

SetupTemplates setups the templates

func Unmarshal

func Unmarshal(data postgres.Jsonb) map[string]interface{}

Types

type KetoAllowed

type KetoAllowed struct {
	Subject  string `json:"subject"`
	Action   string `json:"action"`
	Resource string `json:"resource"`
}

KetoAllowed is request object to check permissions of user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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