conv

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// https://casbin.org/docs/rbac/#how-to-distinguish-role-from-user
	// ROLE_NAME_PREFIX to prefix role to help casbin to distinguish on Enforcing
	ROLE_NAME_PREFIX = "role" + PREFIX_SEPARATOR
	// OIDC_GROUP_NAME_PREFIX to prefix role to help casbin to distinguish on Enforcing
	OIDC_GROUP_NAME_PREFIX = "group" + PREFIX_SEPARATOR
	PREFIX_SEPARATOR       = ":"

	// CRUD allow all actions on a resource
	// this is internal for casbin to handle admin actions
	CRUD = "(C)|(R)|(U)|(D)"
	// CRU allow all actions on a resource except DELETE
	// this is internal for casbin to handle editor actions
	CRU         = "(C)|(R)|(U)"
	VALID_VERBS = "(C)|(R)|(U)|(D)|(A)"
	// InternalPlaceHolder is a place holder to mark empty roles
	InternalPlaceHolder = "wv_internal_empty"
)

Variables

BuiltInWildcardVerb is the wildcard verb pattern Casbin registers for each built-in role: Admin/Root get full CRUD, Viewer/ReadOnly get READ. The matcher specializes namespace-bearing resources at enforce time.

Functions

func CasbinAliases added in v1.32.0

func CasbinAliases(collection, alias string) string

func CasbinBackups

func CasbinBackups(class string) string

func CasbinClusters

func CasbinClusters() string

func CasbinData

func CasbinData(collection, shard, object string) string

func CasbinGroups added in v1.32.5

func CasbinGroups(group string, groupType string) string

func CasbinMcp added in v1.37.0

func CasbinMcp() string

func CasbinNamespaces added in v1.38.0

func CasbinNamespaces(name string) string

CasbinNamespaces returns the casbin resource string for a namespace name. An empty name expands to the wildcard pattern.

func CasbinNodes

func CasbinNodes(verbosity, class string) string

func CasbinPolicies

func CasbinPolicies(namespacesEnabled bool, casbinPolicies ...[][]string) (map[string][]authorization.Policy, error)

func CasbinReplicate added in v1.31.0

func CasbinReplicate(collection, shard string) string

func CasbinRoles

func CasbinRoles(role string) string

func CasbinSchema

func CasbinSchema(collection, shard string) string

func CasbinUsers

func CasbinUsers(user string) string

func ContainsNamespaceSeparator added in v1.38.0

func ContainsNamespaceSeparator(resource string) bool

ContainsNamespaceSeparator reports whether a casbin resource path contains the namespace separator. The separator never appears in any other valid resource path segment (collection, shard, tenant, role, and user names all forbid it), so a plain byte scan unambiguously detects namespace qualification regardless of the path shape.

func GetUserAndPrefix added in v1.30.0

func GetUserAndPrefix(name string) (string, string, error)

GetUserAndPrefix splits an internal casbin user key into the user identifier and its prefix and returns them as (user, prefix). The key is `<prefix>:<user>` where prefix is "db", "oidc", or "group" and `<user>` is itself either a bare name or a namespace-qualified `<namespace>:<name>`. Splitting on the first ":" only is what keeps namespaced principals (e.g. `oidc:customer1:alice`) from being mistaken for malformed input.

func NameHasPrefix added in v1.30.0

func NameHasPrefix(name string) bool

func PathToPermission

func PathToPermission(verb, path string) (*models.Permission, error)

func PermissionToPolicies

func PermissionToPolicies(permissions ...*models.Permission) ([]*authorization.Policy, error)

func PoliciesToPermission

func PoliciesToPermission(policies ...authorization.Policy) ([]*models.Permission, error)

func PrefixGroupName added in v1.28.5

func PrefixGroupName(name string) string

func PrefixRoleName

func PrefixRoleName(name string) string

func RolesToPolicies

func RolesToPolicies(roles ...*models.Role) (map[string][]authorization.Policy, error)

func TrimRoleNamePrefix

func TrimRoleNamePrefix(name string) string

func UserNameWithTypeFromId added in v1.30.0

func UserNameWithTypeFromId(username string, authType authentication.AuthType) string

func UserNameWithTypeFromPrincipal added in v1.30.0

func UserNameWithTypeFromPrincipal(principal *models.Principal) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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