{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package auth\n\n## Types\n\n```go\ntype Permission struct {\n\tResource string `json:\"resource\"`\n\tAction   string `json:\"action\"`\n\tEffect   string `json:\"effect\"` // \"allow\" or \"deny\"\n}\n```\nPermission represents a single access control entry.\n\n```go\ntype PermissionManager struct {\n\t// contains filtered or unexported fields\n}\n```\nPermissionManager aggregates one or more PermissionProviders and delegates permission checks to the primary provider.\n\n```go\nfunc NewPermissionManager() *PermissionManager\n```\nNewPermissionManager creates an empty PermissionManager.\n\n```go\nfunc (pm *PermissionManager) AddProvider(p PermissionProvider)\n```\nAddProvider registers a provider. The first provider added automatically becomes the primary if none has been set.\n\n```go\nfunc (pm *PermissionManager) Check(ctx context.Context, subject, resource, action string) (bool, error)\n```\nCheck delegates a permission check to the primary provider.\n\n```go\nfunc (pm *PermissionManager) ListAll(ctx context.Context, subject string) ([]Permission, error)\n```\nListAll aggregates permissions from every registered provider.\n\n```go\nfunc (pm *PermissionManager) Provider(name string) (PermissionProvider, bool)\n```\nProvider returns the named provider, if registered.\n\n```go\nfunc (pm *PermissionManager) Providers() []string\n```\nProviders returns the names of all registered providers.\n\n```go\nfunc (pm *PermissionManager) SetPrimary(name string) error\n```\nSetPrimary designates the named provider as the one used for Check calls.\n\n```go\ntype PermissionProvider interface {\n\t// Name returns the unique identifier for this provider.\n\tName() string\n\t// CheckPermission evaluates whether subject may perform action on resource.\n\tCheckPermission(ctx context.Context, subject, resource, action string) (bool, error)\n\t// ListPermissions returns all permissions granted to the subject.\n\tListPermissions(ctx context.Context, subject string) ([]Permission, error)\n\t// SyncRoles pushes role definitions into the provider.\n\tSyncRoles(ctx context.Context, roles []RoleDefinition) error\n}\n```\nPermissionProvider abstracts permission evaluation so different backends (built-in RBAC, permit.io, AWS IAM, etc.) can be plugged in.\n\n```go\ntype RoleDefinition struct {\n\tName        string       `json:\"name\"`\n\tDescription string       `json:\"description\"`\n\tPermissions []Permission `json:\"permissions\"`\n}\n```\nRoleDefinition describes a named role and its permissions.\n\n","path":"github.com/GoCodeAlone/workflow/auth","name":"auth","synopsis":"","isRedistributable":true}
