util

package
v0.0.0-...-be294a2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 15 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 NC *nats.EncodedConn

NC nats connection object

Functions

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 CheckNats

func CheckNats() bool

CheckNats checks if nats to be included

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 ConnectNats

func ConnectNats()

ConnectNats connect to nats server

func FactCheckPermission

func FactCheckPermission(h http.Handler) http.Handler

FactCheckPermission checks weather organisation has fact-check permission

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 GetRequest

func GetRequest(url string) error

GetRequest returns error if error in status code

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

func KavachChecker

func KavachChecker() error

KavachChecker checks if Kavach is ready

func KetoChecker

func KetoChecker() error

KetoChecker checks if keto is ready

func KetoGetRequest

func KetoGetRequest(path string) (*http.Response, error)

KetoGetRequest does get request to keto with empty body

func KratosChecker

func KratosChecker() error

KratosChecker checks if Kratos is ready

func MeiliChecker

func MeiliChecker() error

MeiliChecker checks if Meilisearch is ready

func PodcastPermission

func PodcastPermission(h http.Handler) http.Handler

PodcastPermission checks weather organisation has podcast permission

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