accessx

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package accessx provides a small authn + authz + audit facade for handlers.

It is intentionally a thin orchestration layer. Business code may depend on Guard for endpoint protection, while lower-level services should still depend directly on authn.Authenticator, authz.Authorizer, and auditx.Recorder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Credential authn.Credential
	Principal  authn.Principal

	Permission string
	Resource   authz.ObjectRef

	TenantID  string
	OrgID     string
	ProjectID string

	SubjectAttrs     authz.AttributeSet
	ResourceAttrs    authz.AttributeSet
	EnvironmentAttrs authz.AttributeSet
	Consistency      authz.Consistency

	AuditAction string
	RequestID   string
	TraceID     string
	ClientIP    string
	UserAgent   string
	Metadata    auditx.AttributeSet
}

type Guard

type Guard struct {
	Authn authn.Authenticator
	Authz authz.Authorizer
	Audit auditx.Recorder
}

func AllowAllForDevOnly

func AllowAllForDevOnly() Guard

func DenyAllGuard

func DenyAllGuard() Guard

func New

func New(authenticator authn.Authenticator, authorizer authz.Authorizer, recorder auditx.Recorder) Guard

func (Guard) Authenticate

func (g Guard) Authenticate(ctx context.Context, check Check) (authn.Principal, error)

func (Guard) Authorize

func (g Guard) Authorize(ctx context.Context, principal authn.Principal, check Check) (authz.Decision, error)

func (Guard) Can

func (g Guard) Can(ctx context.Context, check Check) (bool, error)

func (Guard) Record

func (g Guard) Record(ctx context.Context, record auditx.Record) error

func (Guard) Require

func (g Guard) Require(ctx context.Context, check Check) (authn.Principal, error)

type Providers added in v0.1.16

type Providers struct {
	Authn authn.ProviderSet
	Authz authz.ProviderSet
	Audit auditx.Recorder
}

Providers is the framework-level authn/authz/audit bundle consumed by serverx/autowire. It keeps concrete implementations such as Casdoor and SpiceDB outside business packages.

func (Providers) Guard added in v0.1.16

func (p Providers) Guard() Guard

Guard builds the request-time access guard from provider-neutral Kernel interfaces. Missing authz defaults to deny-all at the Guard layer.

Jump to

Keyboard shortcuts

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