authorization

package
v0.4.0-rc.16-linux-arm64 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	OperationRegisterMCPMachineClient   = "registerMCPMachineClient"
	OperationDisconnectMCPMachineClient = "disconnectMCPMachineClient"
)

Variables

This section is empty.

Functions

func CanCapturedCompletionAuthority

func CanCapturedCompletionAuthority(ctx context.Context, snapshot model.CompletionAuthoritySnapshot) (bool, error)

CanCapturedCompletionAuthority evaluates only permission facts read from the scoped completion record.

func CanWithResolvedFacts

func CanWithResolvedFacts(ctx context.Context, action model.Action, resource model.Resource, facts model.AuthorizationFacts) (bool, error)

CanWithResolvedFacts evaluates tenant facts captured by a trusted persistence reader.

func DelegatedOperationInScope

func DelegatedOperationInScope(ctx context.Context, operation string) bool

DelegatedOperationInScope checks the verified grant before dispatching to an operation. Callers still need Can for each action and target used by the operation.

func DelegationScopeDescriptions

func DelegationScopeDescriptions(keys []string) []string

DelegationScopeDescriptions describes the operation mappings offered during consent.

func DelegationScopeKeys

func DelegationScopeKeys(source Source) []string

DelegationScopeKeys captures the current operation mappings for a newly authorized grant.

func IsGrantableRolePermission

func IsGrantableRolePermission(permission model.RolePermission) bool

func OperationForRoute

func OperationForRoute(method, path string) string

func ReadOnlyUserDelegationScopeKeys

func ReadOnlyUserDelegationScopeKeys() []string

ReadOnlyUserDelegationScopeKeys returns reviewed reads at their current mapping revision.

func RecentSessionAuthentication

func RecentSessionAuthentication(authenticatedAt time.Time) bool

RecentSessionAuthentication is required to change a profile's MFA settings.

func WithDecisionScope

func WithDecisionScope(ctx context.Context) context.Context

WithDecisionScope carries allowed object identities into subsequent database units of work.

func WithDelegatedPrincipal

func WithDelegatedPrincipal(ctx context.Context, principal DelegatedPrincipal, scopeKeys []string, revalidate func(context.Context, postgres.DBTX) error) context.Context

WithDelegatedPrincipal carries verified authentication and checks it again inside the protected database snapshot. Only the issuer's token verifier should bind a principal.

Types

type DelegatedPrincipal

type DelegatedPrincipal struct {
	Organization, User, APIKey slug.Slug
	PrincipalID                string
}

DelegatedPrincipal identifies the membership or key verified by the OAuth issuer.

func (DelegatedPrincipal) Source

func (p DelegatedPrincipal) Source() Source

type Input

type Input struct {
	SessionAuthenticatedAt    time.Time      // Trusted session authentication time for sensitive self-service changes.
	Operation                 string         // Registered action chosen by the server or trusted adapter.
	CheckPurpose              string         // Named secondary check when the same permission protects multiple targets.
	Source                    Source         // Authenticated credential type.
	UserSlug                  slug.Slug      // The user performing the action
	APIKeySlug                slug.Slug      // Optional API key service principal
	APIKeyRoleSlug            slug.Slug      // Authenticated role used by key management. The resolver verifies it against the current role.
	OrgSlug                   *slug.Slug     // Optional: for organization-scoped authorization
	Action                    model.Action   // The action being performed
	Resource                  model.Resource // The Core permission family for this check.
	ResourceOwnerSlug         *slug.Slug     // Global profile subject.
	Target                    model.AuthorizationTarget
	ProjectDataSourceBindings bool // The operation acts on project-owned references or bindings.
}

type RolePermissionOption

type RolePermissionOption struct {
	model.RolePermission
	ResourceLabel string
	ActionLabel   string
}

RolePermissionOption describes a grantable permission and its display labels.

func RolePermissionCatalog

func RolePermissionCatalog() []RolePermissionOption

RolePermissionCatalog returns the permissions supported on organization roles.

type Service

type Service interface {
	Can(ctx context.Context, input Input) (bool, error)
	EffectivePermissions(ctx context.Context, input Input) ([]model.RolePermission, error)
}

func New

func New(usersService userssvc.UsersService, resolve ResolveFacts) (Service, error)

func NewServiceWithLogging

func NewServiceWithLogging(base Service, logger *slog.Logger) Service

NewServiceWithLogging wraps base with method completion logging.

type ServiceWithLogging

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

ServiceWithLogging implements Service with method completion logging.

func (ServiceWithLogging) Can

func (_d ServiceWithLogging) Can(ctx context.Context, input Input) (b1 bool, err error)

Can implements Service.

func (ServiceWithLogging) EffectivePermissions

func (_d ServiceWithLogging) EffectivePermissions(ctx context.Context, input Input) (ra1 []model.RolePermission, err error)

EffectivePermissions implements Service.

type Source

type Source string

Source is established by authentication, before constructing an authorization input.

const (
	SourceSession          Source = "session"
	SourcePAT              Source = "PAT"
	SourceManagingPAT      Source = "management-enabled PAT"
	SourceAPIKey           Source = "API key"
	SourceQueuedMember     Source = "queued member"
	SourceDelegatedUser    Source = "delegated user"
	SourceDelegatedMachine Source = "delegated machine"
)

func DelegatedSource

func DelegatedSource(ctx context.Context) Source

Jump to

Keyboard shortcuts

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