auth

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PublicGuard marks a generated page or route as intentionally public.
	PublicGuard = "public"
	// RoleGuardPrefix marks a native RBAC guard that requires a principal role.
	RoleGuardPrefix = "role:"
	// PermissionGuardPrefix marks a native RBAC guard that requires a principal permission.
	PermissionGuardPrefix = "permission:"
)

Variables

View Source
var (
	// ErrUnauthenticated reports that a native RBAC guard has no principal.
	ErrUnauthenticated = errors.New("gowdk principal is unauthenticated")
	// ErrForbidden reports that a native RBAC guard rejected the principal.
	ErrForbidden = errors.New("gowdk principal is forbidden")
)

Functions

func IsNativeGuard

func IsNativeGuard(name string) bool

IsNativeGuard reports whether name is a built-in role or permission guard.

func IsPublicGuard

func IsPublicGuard(name string) bool

IsPublicGuard reports whether name is the explicit public access marker.

Types

type Principal

type Principal struct {
	ID          string
	Roles       []string
	Permissions []string
}

Principal is the current application-owned identity visible to native RBAC guards. GOWDK does not own users, sessions, OAuth, tenants, or persistence.

func (Principal) HasPermission

func (p Principal) HasPermission(permission string) bool

HasPermission reports whether the principal has permission.

func (Principal) HasRole

func (p Principal) HasRole(role string) bool

HasRole reports whether the principal has role.

type Provider

type Provider interface {
	Principal(*http.Request) (*Principal, error)
}

Provider returns the current application-owned principal for a request. A nil principal means unauthenticated.

type ProviderFunc

type ProviderFunc func(*http.Request) (*Principal, error)

ProviderFunc adapts a function into a Provider.

func (ProviderFunc) Principal

func (fn ProviderFunc) Principal(request *http.Request) (*Principal, error)

Principal returns the current application-owned principal.

Jump to

Keyboard shortcuts

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