rbac_data

package
v0.0.0-...-845c20a Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RBACPermissionUndefined = RBACPermission("")
)

RBACPermissionUndefined represent the undefined permission

Variables

This section is empty.

Functions

func SetRbacResourceValidator

func SetRbacResourceValidator(h RbacResourceValidator)

func SetRbacServiceValidator

func SetRbacServiceValidator(v RbacServiceValidator)

SetRbacServiceValidator set the service validator function that will be called when loading the rbac mapping. v is the validator function.

Types

type Method

type Method string

type Permission

type Permission string

type RBACConfig

type RBACConfig struct {
	// Skipper function to skip for some request if necessary
	Skipper echo_middleware.Skipper
	// Prefix for the permission map
	Prefix string
	// PermissionMap has the mapping between {route,method}=>permission
	PermissionMap RBACMap
	// Client for rbac access
	Client rbac_client.Rbac
}

type RBACMap

type RBACMap map[Route]map[Method]RBACPermission

RBACMap mapping type

func RBACMapLoad

func RBACMapLoad(data []byte) (string, RBACMap)

func (*RBACMap) GetPermission

func (r *RBACMap) GetPermission(prefix, route, method string) (RBACPermission, error)

GetPermission

type RBACMapBuilder

type RBACMapBuilder interface {
	Build() RBACMap
	Add(r Route, m Method, p RBACPermission) RBACMapBuilder
}

RBACMapBuilder represent the builder for the rbac mapping

func NewRBACMapBuilder

func NewRBACMapBuilder() RBACMapBuilder

NewRBACMap create a builder to generate a RBACMap

type RBACPermission

type RBACPermission string

RBACPermission

func NewRbacPermission

func NewRbacPermission(service RBACService, resource RBACResource, verb RBACVerb) RBACPermission

NewRbacPermission

type RBACPermissionValidator

type RBACPermissionValidator func(p RBACPermission) RBACPermission

RBACPermissionValidator

type RBACResource

type RBACResource string

RBACResource

const (
	RBACResourceUndefined RBACResource = ""
	RBACResourceAny       RBACResource = "*"
)

func DefaultRbacResourceValidator

func DefaultRbacResourceValidator(r RBACResource) RBACResource

type RBACService

type RBACService string

RBACService

const (
	RBACServiceUndefined RBACService = ""
	RBACServiceAny       RBACService = "*"
)

func DefaultRbacServiceValidator

func DefaultRbacServiceValidator(s RBACService) RBACService

type RBACVerb

type RBACVerb string
const (
	RbacVerbUndefined RBACVerb = ""
	RbacVerbAny       RBACVerb = "*"
	RbacVerbRead      RBACVerb = "read"
	RbacVerbWrite     RBACVerb = "write"
	RbacVerbCreate    RBACVerb = "create"
	RbacVerbUpdate    RBACVerb = "update"
	RbacVerbDelete    RBACVerb = "delete"
	RbacVerbLink      RBACVerb = "link"
	RbacVerbUnlink    RBACVerb = "unlink"
	RbacVerbOrder     RBACVerb = "order"
	RbacVerbExecute   RBACVerb = "execute"
)

The following constants result from the schema below https://github.com/RedHatInsights/rbac-config/blob/master/schemas/permissions.schema

func DefaultRbacVerbValidator

func DefaultRbacVerbValidator(v RBACVerb) RBACVerb

type RbacFile

type RbacFile struct {
	Version string  `yaml:"version"`
	Prefix  string  `yaml:"prefix"`
	Data    RBACMap `yaml:"data"`
}

type RbacResourceValidator

type RbacResourceValidator func(r RBACResource) RBACResource

RbacResourceValidator validate the provided resource and panic if something is wrong, else return the provided value.

func NewRbacResourceValidator

func NewRbacResourceValidator(resources ...RBACResource) RbacResourceValidator

NewRbacResourceValidator return a handler to manage this scenario

type RbacServiceValidator

type RbacServiceValidator func(s RBACService) RBACService

func NewRbacServiceValidator

func NewRbacServiceValidator(myService RBACService) RbacServiceValidator

type RbacVerbValidator

type RbacVerbValidator func(v RBACVerb) RBACVerb

type Route

type Route string

Jump to

Keyboard shortcuts

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