accesstypes

package module
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 2 Imported by: 11

README

accesstypes

The accesstypes package provides types used by the access package and other dependent packages.

Documentation

Overview

Package accesstypes provides types for permissions, roles, and domains types for the access package

Index

Constants

View Source
const GlobalDomain = Domain("global")

GlobalDomain is the domain used when a permission is applied at the Global level instead of to a specific domain.

View Source
const GlobalResource = Resource("global")

GlobalResource is the resource used when a permission is applied to the entire application, (i.e. Global level) instead of to a specific resource.

View Source
const NoopUser = "noop"

NoopUser is the user assigned to an empty role in casbin to ensure the role can be enumerated if no one else is assigned

Variables

This section is empty.

Functions

This section is empty.

Types

type Domain

type Domain string

Domain represents a domain in the authorization system

func UnmarshalDomain

func UnmarshalDomain(domain string) Domain

UnmarshalDomain unmarshals a domain string into a Domain type.

func (Domain) Marshal

func (d Domain) Marshal() string

Marshal marshals a Domain type into a string.

type Field added in v0.2.5

type Field string

Field represents the string name of a struct field

type Permission

type Permission string

Permission represents a permission in the authorization system

const (
	// NullPermission represents no permission
	NullPermission Permission = ""

	// Create is the create permission in CRUD
	Create Permission = "Create"

	// Read is the read permission in CRUD used to fetch single resource
	Read Permission = "Read"

	// List is the list permission used to fetch multiple resources
	List Permission = "List"

	// Update is the update permission in CRUD
	Update Permission = "Update"

	// Delete is the delete permission in CRUD
	Delete Permission = "Delete"

	// Execute is the execute permission used in RPC
	Execute Permission = "Execute"
)

func UnmarshalPermission

func UnmarshalPermission(permission string) Permission

UnmarshalPermission unmarshals a permission string into a Permission type.

func (Permission) Marshal

func (p Permission) Marshal() string

Marshal marshals a Permission type into a string.

type PermissionDetail

type PermissionDetail struct {
	Description string
	Scope       PermissionScope
}

PermissionDetail is a struct that holds the description and scope of a permission

type PermissionScope

type PermissionScope string

PermissionScope is the type use to define different scopes

const (
	// GlobalPermissionScope is the permission scope for global permissions
	GlobalPermissionScope PermissionScope = "global"

	// DomainPermissionScope is the permission scope for domain permissions
	DomainPermissionScope PermissionScope = "domain"
)

type ResolvedPermissions added in v0.2.5

type ResolvedPermissions struct {
	Resources ResolvedResourcePermissions
	Tags      ResolvedTagPermissions
}

ResolvedPermissions is a struct that holds the resolved permissions for resources and tags.

type ResolvedResourcePermissions added in v0.2.5

type ResolvedResourcePermissions map[Domain]map[Resource]map[Permission]bool

ResolvedResourcePermissions is a mapping for each domain and resource of which permissions are rquired for the resource

type ResolvedTagPermissions added in v0.3.0

type ResolvedTagPermissions map[Domain]map[Resource]map[Tag]map[Permission]bool

ResolvedTagPermissions is a mapping for each domain and resource of which permissions are required for a Tag

type Resource

type Resource string

Resource represents a resource in the authorization system

func UnmarshalResource

func UnmarshalResource(resource string) Resource

UnmarshalResource unmarshals a resource string into a Resource type.

func (Resource) Marshal

func (r Resource) Marshal() string

Marshal marshals a Resource type into a string.

func (Resource) ResourceAndTag added in v0.3.0

func (r Resource) ResourceAndTag() (Resource, Tag)

ResourceAndTag splits the Resource name from the Tag name for a fully qualified field resource name

func (Resource) ResourceWithTag added in v0.3.0

func (r Resource) ResourceWithTag(tag Tag) Resource

ResourceWithTag returns the fully qualified resource name for the resource feild with tag

type Role

type Role string

Role represents a role in the authorization system

func UnmarshalRole

func UnmarshalRole(role string) Role

UnmarshalRole unmarshals a role string into a Role type.

func (Role) Marshal

func (r Role) Marshal() string

Marshal marshals a Role type into a string.

type RoleCollection

type RoleCollection map[Domain][]Role

RoleCollection is a map of domain to roles defind in that domain

type RolePermissionCollection

type RolePermissionCollection map[Permission][]Resource

RolePermissionCollection is a map of permissions a Role has on resources

type Tag added in v0.3.0

type Tag string

Tag represents the string name of a json tag

type TagPermissions added in v0.5.0

type TagPermissions map[Tag][]Permission

TagPermissions is a map of Tags to a slice of permissions associated with the Tag

type User

type User string

User represents a user in the authorization system

func UnmarshalUser

func UnmarshalUser(user string) User

UnmarshalUser unmarshals a user string into a User type.

func (User) Marshal

func (u User) Marshal() string

Marshal marshals a User type into a string.

type UserPermissionCollection

type UserPermissionCollection map[Domain]map[Resource][]Permission

UserPermissionCollection is a mapping of permissions a user has for domain and resource

Jump to

Keyboard shortcuts

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