rbac

package
v0.0.0-...-474e43f Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const APIPath = "/api/rbac/v1"

APIPath the rbac base path

View Source
const DefaultTimeDuration = 1 * time.Second
View Source
const PaginationLimit = "1000"

PaginationLimit to get a maximum of 1000 records

Variables

View Source
var ErrCreatingRbacURL = errors.New("error occurred when creating rbac url")
View Source
var ErrFailedToBuildAccessRequest = errors.New("failed to build access request")
View Source
var ErrInvalidAttributeFilterKey = errors.New("invalid value for attributeFilter.key in RBAC response")
View Source
var ErrInvalidAttributeFilterOperation = errors.New("invalid value for attributeFilter.operation in RBAC response")
View Source
var ErrInvalidAttributeFilterValue = errors.New("received invalid UUIDs for attributeFilter.value in RBAC response")
View Source
var ErrRbacRequestResponse = errors.New("rbac response error")
View Source
var HTTPGetCommand = http.MethodGet

HTTPGetCommand the http get command

View Source
var IOReadAll = io.ReadAll

IOReadAll The io body reader

Functions

func AccessMatch

func AccessMatch(access1, access2 AccessType) bool

AccessMatch return whether the access type matches the required resource type

func ResourceMatch

func ResourceMatch(resource1, resource2 ResourceType) bool

ResourceMatch return whether the resource type matches the required resource type

Types

type Access

type Access struct {
	ResourceDefinitions []ResourceDefinition `json:"resourceDefinitions,omitempty"`
	Permission          string               `json:"permission"`
}

Access represents a permission and an optional resource definition

func (Access) AccessType

func (a Access) AccessType() string

AccessType returns the access type in the permission

func (Access) Application

func (a Access) Application() string

Application returns the name of the application in the permission

func (Access) Resource

func (a Access) Resource() string

Resource returns the name of the resource in the permission

type AccessList

type AccessList []Access

AccessList is a slice of Accesses and is generally used to represent a principal's full set of permissions for an application

type AccessType

type AccessType string
const (
	AccessTypeAny  AccessType = "*"
	AccessTypeRead AccessType = "read"
)

type Application

type Application string
const ApplicationInventory Application = "inventory"

type Client

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

Client is the implementation of an ClientInterface

func (*Client) GetAccessList

func (c *Client) GetAccessList(application Application) (AccessList, error)

GetAccessList return the application rbac access list

func (*Client) GetInventoryGroupsAccess

func (c *Client) GetInventoryGroupsAccess(acl AccessList, resource ResourceType, accessType AccessType) (bool, []string, bool, error)

GetInventoryGroupsAccess return whether access is allowed and the groups configurations

func (*Client) GetRBacAccessHTTPRequest

func (c *Client) GetRBacAccessHTTPRequest(ctx context.Context, application Application) (*http.Request, error)

type ClientInterface

type ClientInterface interface {
	GetAccessList(application Application) (AccessList, error)
	GetInventoryGroupsAccess(acl AccessList, resource ResourceType, accessType AccessType) (bool, []string, bool, error)
}

ClientInterface is an Interface to make request to insights rbac

func InitClient

func InitClient(ctx context.Context, log log.FieldLogger) ClientInterface

InitClient initializes the client for Rbac service

type PaginationLinks struct {
	First    string `json:"first"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
	Last     string `json:"last"`
}

PaginationLinks provides links to additional pages of response data

type PaginationMeta

type PaginationMeta struct {
	Count  int `json:"count"`
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

PaginationMeta contains metadata for pagination

type ResourceDefinition

type ResourceDefinition struct {
	Filter ResourceDefinitionFilter `json:"attributeFilter"`
}

ResourceDefinition limits an Access to specific resources

type ResourceDefinitionFilter

type ResourceDefinitionFilter struct {
	Key       string    `json:"key"`
	Operation string    `json:"operation"`
	Value     []*string `json:"value"`
}

ResourceDefinitionFilter represents the key/values used for filtering

type ResourceType

type ResourceType string
const (
	ResourceTypeAny   ResourceType = "*"
	ResourceTypeHOSTS ResourceType = "hosts"
)

type ResponseBody

type ResponseBody struct {
	Meta  PaginationMeta  `json:"meta"`
	Links PaginationLinks `json:"links"`
	Data  AccessList      `json:"data"`
}

ResponseBody represents the response body format from the RBAC service

Directories

Path Synopsis
Package mock_rbac is a generated GoMock package.
Package mock_rbac is a generated GoMock package.

Jump to

Keyboard shortcuts

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