rolemanager

package
v0.0.0-...-8c2db74 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAllowedResources

func FindAllowedResources(ctx context.Context, rm gimlet.RoleManager, roles []string, resourceType, requiredPermission string, requiredLevel int) ([]string, error)

FindAllowedResources takes a list of roles and a permission to check in those roles. It returns a list of all resources that the given roles have access to with the given permission check. It answers the question "Given this list of roles (likely from a single user), what resources can they access, given this permission check?"

func HighestPermissionsForRoles

func HighestPermissionsForRoles(rolesIDs []string, rm gimlet.RoleManager, opts gimlet.PermissionOpts) (gimlet.Permissions, error)

HighestPermissionsForRoles takes in a list of roles and returns an aggregated list of the highest levels for all permissions

func HighestPermissionsForRolesAndResourceType

func HighestPermissionsForRolesAndResourceType(roleIDs []string, resourceType string, rm gimlet.RoleManager) (map[string]gimlet.Permissions, error)

HighestPermissionsForResourceType takes a list of role IDs, a resource type, and a role manager and returns a mapping of all resource IDs for the given roles to their highest permissions based on those roles.

func MakeRoleWithPermissions

func MakeRoleWithPermissions(rm gimlet.RoleManager, resourceType string, resources []string, permissions gimlet.Permissions) (*gimlet.Role, error)

func NewInMemoryRoleManager

func NewInMemoryRoleManager() gimlet.RoleManager

func NewMongoBackedRoleManager

func NewMongoBackedRoleManager(opts MongoBackedRoleManagerOpts) gimlet.RoleManager

Types

type MongoBackedRoleManagerOpts

type MongoBackedRoleManagerOpts struct {
	Client          *mongo.Client
	DBName          string
	RoleCollection  string
	ScopeCollection string
}

type PermissionSummary

type PermissionSummary struct {
	Type        string                  `json:"type"`
	Permissions PermissionsForResources `json:"permissions"`
}

func PermissionSummaryForRoles

func PermissionSummaryForRoles(ctx context.Context, rolesIDs []string, rm gimlet.RoleManager) ([]PermissionSummary, error)

type PermissionsForResources

type PermissionsForResources map[string]gimlet.Permissions

Jump to

Keyboard shortcuts

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