Documentation
¶
Overview ¶
Package pluginapi defines the stable public contract for native Nauthilus Go plugins.
Index ¶
- Constants
- Variables
- func IsPluginDebugSelector(value string) bool
- func NormalizeHookRequiredScopes(scopes []string) ([]string, error)
- func PluginDebugModuleSelector(module string) (string, error)
- func PluginDebugSubmoduleSelector(module string, name string) (string, error)
- func PluginPolicyAttributeID(extension string, moduleOrFeature string, fact string) (string, error)
- func QualifiedComponentName(module string, component string) (string, error)
- func ValidateAPIVersion(version string) error
- func ValidateBackendAttributeName(name string) error
- func ValidateCompatibilityMetric(definition MetricDefinition) error
- func ValidateCompatibilityTraceScope(scope string) error
- func ValidateComponentName(name string) error
- func ValidateDebugModuleName(name string) error
- func ValidateMetadata(metadata Metadata) error
- func ValidateModuleName(name string) error
- func ValidatePluginDebugSelector(selector string) error
- func ValidateQualifiedComponentName(name string) error
- func ValidateScopeToken(scope string) error
- type AbortPolicy
- type AccountListRequest
- type AccountListResult
- type ArgsView
- type AttributeCategory
- type AttributeDefinition
- type AttributePatch
- type AttributeType
- type Backend
- type BackendAuthRequest
- type BackendIdentityResult
- type BackendResult
- type BackendResultPatch
- type BackendServerCandidate
- type BackendServerRef
- type BackendServers
- type BuildInfo
- type Cache
- type Capability
- type ConfigView
- type ConnectionTarget
- type ConnectionTargetDirection
- type ConnectionTargets
- type Counter
- type CredentialProvider
- type DebugModuleDefinition
- type DetailDefinition
- type DetailSensitivity
- type DeterministicHelpers
- type EnvironmentRequest
- type EnvironmentResult
- type EnvironmentSource
- type Feature
- type Gauge
- type HTTPClient
- type HTTPRequest
- type HTTPResponse
- type Histogram
- type Hook
- type HookAuth
- type HookDescriptor
- type HookRequest
- type HookResponse
- type HookScope
- type Host
- type IDPInfo
- type InitContext
- type InitTask
- type LDAP
- type LDAPEndpoint
- type LDAPEntry
- type LDAPModifyOperation
- type LDAPModifyRequest
- type LDAPScope
- type LDAPSearchRequest
- type LDAPSearchResult
- type LabelValue
- type LogField
- type Logger
- type MailMessage
- type Mailer
- type Metadata
- type MetricDefinition
- type MetricType
- type Metrics
- type ObligationRequest
- type ObligationResult
- type ObligationTarget
- type Plugin
- type PolicyDecision
- type PolicyFact
- type PolicyOperation
- type PolicyStage
- type PostActionEnqueueResult
- type PostActionRequest
- type PostActionTarget
- type PublicMFAStateBackend
- type PublicMFAStateRequest
- type PublicMFAStateResult
- type RecoveryCodeBackend
- type RecoveryCodeDeleteRequest
- type RecoveryCodeGenerateRequest
- type RecoveryCodeGenerateResult
- type RecoveryCodeUseRequest
- type RecoveryCodeUseResult
- type Redis
- type RedisKeyBuilder
- type RedisScriptRegistry
- type Registrar
- type ReloadablePlugin
- type RequestDiagnostics
- type RequestSnapshot
- type ResponseHeaderMutation
- type ResponseMutation
- type RuntimeContext
- type RuntimeDelta
- type RuntimeFlags
- type RuntimePlugin
- type Secret
- type SourceDescriptor
- type Span
- type SpanKind
- type SpanStartOptions
- type SpanStatus
- type StatusMessage
- type SubjectRequest
- type SubjectResult
- type SubjectSource
- type Summary
- type TLSInfo
- type TLSLegacyInfo
- type TOTPBackend
- type TOTPBeginRequest
- type TOTPBeginResult
- type TOTPDeleteRequest
- type TOTPFinishRequest
- type TOTPFinishResult
- type TOTPVerifyRequest
- type TOTPVerifyResult
- type TraceAttribute
- type Tracer
- type WebAuthnBackend
- type WebAuthnCredential
- type WebAuthnDeleteRequest
- type WebAuthnListRequest
- type WebAuthnListResult
- type WebAuthnSaveRequest
- type WebAuthnUpdateRequest
Constants ¶
const ( // PluginPolicyAttributePrefix is the native policy fact namespace prefix. PluginPolicyAttributePrefix = "plugin" // PublicPolicyFactLogPrefix marks an intentionally public policy fact log key. PublicPolicyFactLogPrefix = "policy_fact_" )
const APIVersion = "nauthilus.plugin.v1"
APIVersion is the exact public API contract version supported by this package.
Variables ¶
var ( // ErrInvalidRedisScriptName is returned when a named Redis script uses an unsafe or unstable name. ErrInvalidRedisScriptName = errors.New("invalid redis script name") // ErrRedisScriptNotFound is returned when a plugin tries to run a script that was not uploaded. ErrRedisScriptNotFound = errors.New("redis script not found") // ErrInvalidHTTPRequest is returned when a host-managed outbound HTTP request is malformed. ErrInvalidHTTPRequest = errors.New("invalid plugin http request") // ErrHTTPResponseTooLarge is returned when a host-managed HTTP response exceeds the configured body limit. ErrHTTPResponseTooLarge = errors.New("plugin http response too large") // ErrInvalidConnectionTarget is returned when a connection target is unsafe or malformed. ErrInvalidConnectionTarget = errors.New("invalid plugin connection target") // ErrConnectionTargetConflict is returned when a duplicate connection target registration is not idempotent. ErrConnectionTargetConflict = errors.New("plugin connection target conflict") )
var ( // ErrUnsupportedAPIVersion is returned when plugin metadata uses a different API version. ErrUnsupportedAPIVersion = errors.New("unsupported plugin API version") // ErrInvalidName is returned when a public plugin module or component name is invalid. ErrInvalidName = errors.New("invalid plugin name") // ErrInvalidMetadata is returned when plugin metadata is incomplete or invalid. ErrInvalidMetadata = errors.New("invalid plugin metadata") // ErrInvalidScope is returned when hook authorization contains an invalid OAuth scope token. ErrInvalidScope = errors.New("invalid OAuth scope token") // ErrInvalidMetricDefinition is returned when an exact compatibility metric contract is invalid. ErrInvalidMetricDefinition = errors.New("invalid compatibility metric definition") // ErrInvalidTraceScope is returned when an exact compatibility instrumentation scope is invalid. ErrInvalidTraceScope = errors.New("invalid compatibility trace scope") )
Functions ¶
func IsPluginDebugSelector ¶
IsPluginDebugSelector reports whether value starts with the plugin selector namespace.
func NormalizeHookRequiredScopes ¶
NormalizeHookRequiredScopes trims, validates, de-duplicates, and copies hook scopes.
func PluginDebugModuleSelector ¶
PluginDebugModuleSelector joins and validates a module-level plugin debug selector.
func PluginDebugSubmoduleSelector ¶
PluginDebugSubmoduleSelector joins and validates a plugin-local debug selector.
func PluginPolicyAttributeID ¶
PluginPolicyAttributeID builds a validated native policy fact identifier.
func QualifiedComponentName ¶
QualifiedComponentName joins and validates a module-local component reference.
func ValidateAPIVersion ¶
ValidateAPIVersion checks that version exactly matches this package contract.
func ValidateBackendAttributeName ¶
ValidateBackendAttributeName checks a backend attribute name used in backend results.
func ValidateCompatibilityMetric ¶
func ValidateCompatibilityMetric(definition MetricDefinition) error
ValidateCompatibilityMetric validates one exact value-only collector contract.
func ValidateCompatibilityTraceScope ¶
ValidateCompatibilityTraceScope validates one exact instrumentation scope.
func ValidateComponentName ¶
ValidateComponentName checks a plugin-local component name.
func ValidateDebugModuleName ¶
ValidateDebugModuleName checks a plugin-local debug module name.
func ValidateMetadata ¶
ValidateMetadata checks the public metadata required before plugin registration.
func ValidateModuleName ¶
ValidateModuleName checks a configured plugin module instance name.
func ValidatePluginDebugSelector ¶
ValidatePluginDebugSelector checks the operator-facing plugin debug selector grammar.
func ValidateQualifiedComponentName ¶
ValidateQualifiedComponentName checks a fully qualified module.component name.
func ValidateScopeToken ¶
ValidateScopeToken checks the RFC 6749 scope-token grammar.
Types ¶
type AbortPolicy ¶
type AbortPolicy string
AbortPolicy describes how the host handles source abort signals.
const ( // AbortPolicyNone leaves later sources eligible to run. AbortPolicyNone AbortPolicy = "none" // AbortPolicySource stops later sources in the same extension plan. AbortPolicySource AbortPolicy = "source" // AbortPolicyRequest stops the request-time extension plan. AbortPolicyRequest AbortPolicy = "request" )
type AccountListRequest ¶
type AccountListRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Username string
}
AccountListRequest is passed to backend account-list operations.
type AccountListResult ¶
type AccountListResult struct {
Status *StatusMessage
Accounts []string
Facts []PolicyFact
}
AccountListResult describes accounts returned by a backend plugin.
type ArgsView ¶
type ArgsView interface {
Get(path string) (any, bool)
GetPath(path []string) (any, bool)
Sub(path string) ArgsView
SubPath(path []string) ArgsView
Decode(target any) error
IsZero() bool
}
ArgsView exposes read-only, format-neutral policy effect arguments.
type AttributeCategory ¶
type AttributeCategory string
AttributeCategory identifies the XACML-style attribute category.
const ( // AttributeCategoryEnvironment identifies environment attributes. AttributeCategoryEnvironment AttributeCategory = "environment" // AttributeCategorySubject identifies subject attributes. AttributeCategorySubject AttributeCategory = "subject" // AttributeCategoryResource identifies resource attributes. AttributeCategoryResource AttributeCategory = "resource" )
type AttributeDefinition ¶
type AttributeDefinition struct {
Details map[string]DetailDefinition
ID string
Description string
Stage PolicyStage
Operations []PolicyOperation
// ProducerTypes names compatible policy check types, such as "plugin.environment",
// that may emit this attribute when such a check is active in the compiled policy.
ProducerTypes []string
// ProducerCheck names one compiled policy check that must be active before this
// attribute may be consumed. It is a host-owned policy check name, not a plugin
// component ID such as "module.component".
ProducerCheck string
Category AttributeCategory
Type AttributeType
}
AttributeDefinition describes one policy attribute registered by a plugin.
type AttributePatch ¶
AttributePatch describes subject attribute mutations returned by a plugin.
type AttributeType ¶
type AttributeType string
AttributeType describes the declared value type of a policy attribute or detail.
const ( // AttributeTypeBool identifies boolean attribute values. AttributeTypeBool AttributeType = "bool" // AttributeTypeString identifies string attribute values. AttributeTypeString AttributeType = "string" // AttributeTypeStringList identifies string-list attribute values. AttributeTypeStringList AttributeType = "string_list" // AttributeTypeNumber identifies numeric attribute values. AttributeTypeNumber AttributeType = "number" // AttributeTypeIP identifies IP address attribute values. AttributeTypeIP AttributeType = "ip" // AttributeTypeCIDR identifies CIDR attribute values. AttributeTypeCIDR AttributeType = "cidr" // AttributeTypeDateTime identifies datetime attribute values. AttributeTypeDateTime AttributeType = "datetime" )
type Backend ¶
type Backend interface {
Name() string
VerifyPassword(context.Context, BackendAuthRequest) (BackendResult, error)
ListAccounts(context.Context, AccountListRequest) (AccountListResult, error)
}
Backend verifies credentials and lists accounts for one backend component.
type BackendAuthRequest ¶
type BackendAuthRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Credentials CredentialProvider
Username string
}
BackendAuthRequest is passed to backend password verification.
type BackendIdentityResult ¶
type BackendIdentityResult struct {
UniqueUserIDField string
DisplayNameField string
TOTPSecretField string
TOTPRecoveryField string
Groups []string
GroupDistinguishedNames []string
}
BackendIdentityResult carries identity metadata returned by a backend plugin.
type BackendResult ¶
type BackendResult struct {
Status *StatusMessage
Attributes map[string][]string
Facts []PolicyFact
Identity BackendIdentityResult
Account string
AccountField string
BackendServer *BackendServerRef
Authenticated bool
UserFound bool
}
BackendResult describes a password verification result from a backend plugin.
type BackendResultPatch ¶
type BackendResultPatch struct {
SelectedBackend *BackendServerRef
Attributes AttributePatch
Authenticated *bool
UserFound *bool
Account string
AccountField string
}
BackendResultPatch describes explicit value-only backend result changes from subject sources.
type BackendServerCandidate ¶
type BackendServerCandidate struct {
Name string
Protocol string
Authority string
Address string
Port int
HAProxyV2 bool
Alive bool
}
BackendServerCandidate describes one host-provided backend target safe for plugin selection logic.
func (BackendServerCandidate) Ref ¶
func (c BackendServerCandidate) Ref() BackendServerRef
Ref converts the candidate into the value returned through SubjectResult.SelectedBackend.
type BackendServerRef ¶
type BackendServerRef struct {
Name string
Protocol string
Authority string
Address string
Port string
}
BackendServerRef identifies a backend server selected by an extension.
type BackendServers ¶
type BackendServers interface {
List(context.Context) []BackendServerCandidate
}
BackendServers exposes immutable backend candidates from host monitoring state.
type Cache ¶
type Cache interface {
Set(context.Context, string, any, time.Duration)
Get(context.Context, string) (any, bool)
Delete(context.Context, string) bool
Exists(context.Context, string) bool
Push(context.Context, string, any) int
PopAll(context.Context, string) []any
Clear(context.Context)
}
Cache exposes a process-local module cache shared by a plugin module's components.
type Capability ¶
type Capability string
Capability names a host-controlled permission a plugin may request.
const ( // CapabilityCredentials allows a module instance to access request-scoped credentials. CapabilityCredentials Capability = "credentials" // CapabilityMail allows a module instance to send mail through the host mail facade. CapabilityMail Capability = "mail" )
type ConfigView ¶
type ConfigView interface {
Get(path string) (any, bool)
GetPath(path []string) (any, bool)
Sub(path string) ConfigView
SubPath(path []string) ConfigView
Decode(target any) error
IsZero() bool
}
ConfigView exposes a read-only, format-neutral plugin configuration subtree.
type ConnectionTarget ¶
type ConnectionTarget struct {
Labels map[string]string
Name string
Address string
Description string
Direction ConnectionTargetDirection
}
ConnectionTarget describes one named network target for host-owned observability.
type ConnectionTargetDirection ¶
type ConnectionTargetDirection string
ConnectionTargetDirection describes which endpoint side should be counted.
const ( // ConnectionTargetDirectionLocal counts local listening endpoints. ConnectionTargetDirectionLocal ConnectionTargetDirection = "local" // ConnectionTargetDirectionRemote counts remote outbound endpoints. ConnectionTargetDirectionRemote ConnectionTargetDirection = "remote" )
type ConnectionTargets ¶
type ConnectionTargets interface {
Register(context.Context, ConnectionTarget) error
Count(context.Context, string) (int, bool)
}
ConnectionTargets registers network targets for host-owned connection observability.
type Counter ¶
type Counter interface {
Add(context.Context, float64, ...LabelValue)
}
Counter records monotonically increasing plugin measurements.
type CredentialProvider ¶
CredentialProvider gives request-scoped access to credential material.
type DebugModuleDefinition ¶
DebugModuleDefinition declares one plugin-local debug selector.
type DetailDefinition ¶
type DetailDefinition struct {
Type AttributeType
Sensitivity DetailSensitivity
Purpose string
MaxLength int
}
DetailDefinition describes a typed policy attribute detail.
type DetailSensitivity ¶
type DetailSensitivity string
DetailSensitivity describes how policy detail values may be exposed.
const ( // DetailSensitivityPublic marks detail values safe for selected public output. DetailSensitivityPublic DetailSensitivity = "public" // DetailSensitivityInternal marks detail values for internal diagnostics. DetailSensitivityInternal DetailSensitivity = "internal" // DetailSensitivitySecret marks detail values that must never be exposed. DetailSensitivitySecret DetailSensitivity = "secret" )
type DeterministicHelpers ¶
type DeterministicHelpers interface {
AccountTag(string) string
CountryName(string) string
ScopedIP(string, string) string
IsRoutableIP(string) bool
}
DeterministicHelpers exposes shared non-secret helper logic used by plugin ports.
type EnvironmentRequest ¶
type EnvironmentRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Credentials CredentialProvider
}
EnvironmentRequest is passed to pre-auth environment sources.
type EnvironmentResult ¶
type EnvironmentResult struct {
Status *StatusMessage
Logs []LogField
Facts []PolicyFact
RuntimeDelta RuntimeDelta
Triggered bool
Abort bool
}
EnvironmentResult is returned by pre-auth environment sources.
type EnvironmentSource ¶
type EnvironmentSource interface {
Descriptor() SourceDescriptor
Evaluate(context.Context, EnvironmentRequest) (EnvironmentResult, error)
}
EnvironmentSource emits pre-auth environment facts and runtime deltas.
type Gauge ¶
type Gauge interface {
Set(context.Context, float64, ...LabelValue)
Add(context.Context, float64, ...LabelValue)
}
Gauge records mutable plugin measurements.
type HTTPClient ¶
type HTTPClient interface {
Do(context.Context, HTTPRequest) (HTTPResponse, error)
}
HTTPClient executes outbound HTTP requests through host-managed instrumentation.
type HTTPRequest ¶
type HTTPRequest struct {
Headers map[string][]string
Body []byte
Method string
URL string
Service string
Timeout time.Duration
MaxResponseBytes int64
}
HTTPRequest describes one host-managed outbound HTTP call without exposing net/http objects.
type HTTPResponse ¶
HTTPResponse contains the bounded response returned by the host HTTP facade.
type Histogram ¶
type Histogram interface {
Observe(context.Context, float64, ...LabelValue)
}
Histogram records sampled plugin measurements into buckets.
type Hook ¶
type Hook interface {
Descriptor() HookDescriptor
Serve(context.Context, HookRequest) (HookResponse, error)
}
Hook handles one HTTP-facing plugin endpoint.
type HookAuth ¶
type HookAuth string
HookAuth describes authentication required before a hook is called.
const ( // HookAuthNone requires no hook-specific authentication. HookAuthNone HookAuth = "none" // HookAuthToken requires a configured token. HookAuthToken HookAuth = "token" // HookAuthSession requires an authenticated session. HookAuthSession HookAuth = "session" // HookAuthAdmin requires administrative authorization regardless of the declared hook scope. HookAuthAdmin HookAuth = "admin" )
type HookDescriptor ¶
type HookDescriptor struct {
RequiredScopes []string
Timeout time.Duration
Name string
Method string
Path string
Alias string
Scope HookScope
Auth HookAuth
MaxBodyBytes int64
}
HookDescriptor describes an HTTP-facing plugin hook.
type HookRequest ¶
type HookRequest struct {
Snapshot RequestSnapshot
Headers map[string][]string
Query map[string][]string
Body []byte
Path string
Method string
}
HookRequest is the API-level request value passed to hook plugins. Headers and query values are host-built copies; secret-bearing headers are redacted before invocation.
type HookResponse ¶
HookResponse is the API-level response value returned by hook plugins. Use standard net/http status constants for StatusCode; the host filters unsafe headers and keeps HEAD bodies empty.
type HookScope ¶
type HookScope string
HookScope describes the host authorization surface for a hook.
const ( // MaxHookRequiredScopes bounds operator-configured authorization metadata per hook. MaxHookRequiredScopes = 32 // HookScopePublic marks a hook as public. HookScopePublic HookScope = "public" // HookScopeInternal marks a hook as internal. HookScopeInternal HookScope = "internal" // HookScopeAdmin marks a hook as administrative. HookScopeAdmin HookScope = "admin" )
type Host ¶
type Host interface {
ServiceContext() context.Context
Logger(scope string) Logger
Tracer(scope string) Tracer
CompatibilityTracer(scope string) (Tracer, error)
Metrics(scope string) Metrics
HTTP(scope string) HTTPClient
Mail(scope string) Mailer
ConnectionTargets(scope string) ConnectionTargets
BackendServers() BackendServers
Redis() Redis
Cache(scope string) (Cache, error)
Helpers() DeterministicHelpers
LDAP() LDAP
Config() ConfigView
Go(ctx context.Context, name string, fn func(context.Context) error)
}
Host exposes runtime services through narrow facades managed by Nauthilus.
type IDPInfo ¶
type IDPInfo struct {
RequestedScopes []string
UserGroups []string
AllowedClientScopes []string
AllowedClientGrantTypes []string
GrantType string
ClientID string
ClientName string
RedirectURI string
MFAMethod string
MFACompleted bool
}
IDPInfo contains safe identity-provider policy inputs for a request.
type InitContext ¶
type InitContext struct {
Host Host
Config ConfigView
}
InitContext exposes host services to init tasks without exposing server internals.
type InitTask ¶
type InitTask interface {
Name() string
Start(context.Context, InitContext) error
Stop(context.Context) error
}
InitTask is a named startup or worker unit registered by a plugin.
type LDAP ¶
type LDAP interface {
Search(context.Context, LDAPSearchRequest) (LDAPSearchResult, error)
Modify(context.Context, LDAPModifyRequest) error
Endpoints(context.Context, string) ([]LDAPEndpoint, error)
}
LDAP exposes host-owned queued LDAP operations.
type LDAPEndpoint ¶
LDAPEndpoint contains configured trace-safe endpoint metadata for one pool URI.
type LDAPModifyOperation ¶
type LDAPModifyOperation string
LDAPModifyOperation describes the LDAP modify operation kind.
const ( // LDAPModifyAdd adds LDAP attribute values. LDAPModifyAdd LDAPModifyOperation = "add" // LDAPModifyDelete deletes LDAP attribute values. LDAPModifyDelete LDAPModifyOperation = "delete" // LDAPModifyReplace replaces LDAP attribute values. LDAPModifyReplace LDAPModifyOperation = "replace" )
type LDAPModifyRequest ¶
type LDAPModifyRequest struct {
Attributes map[string][]string
PoolName string
DN string
Operation LDAPModifyOperation
}
LDAPModifyRequest describes one queued LDAP modify operation. An empty PoolName or "default" selects the default LDAP pool.
type LDAPSearchRequest ¶
type LDAPSearchRequest struct {
Attributes []string
PoolName string
BaseDN string
Filter string
Scope LDAPScope
}
LDAPSearchRequest describes one queued LDAP search. An empty PoolName or "default" selects the default LDAP pool.
type LDAPSearchResult ¶
LDAPSearchResult contains LDAP search entries and flattened attributes.
type LabelValue ¶
LabelValue binds one declared metric label to a value.
type Logger ¶
type Logger interface {
Debug(context.Context, string, ...LogField)
Info(context.Context, string, ...LogField)
Warn(context.Context, string, ...LogField)
Error(context.Context, string, ...LogField)
}
Logger records structured plugin log messages through the host logger.
type MailMessage ¶
type MailMessage struct {
To []string
Server string
HeloName string
Username string
Password string
From string
Subject string
Body string
Port int
TLS bool
StartTLS bool
LMTP bool
}
MailMessage describes one host-managed SMTP or LMTP message send request.
type Mailer ¶
type Mailer interface {
Send(context.Context, MailMessage) error
}
Mailer sends SMTP or LMTP messages through host-managed transport.
type Metadata ¶
type Metadata struct {
Build BuildInfo
Name string
Version string
APIVersion string
Description string
DocsURL string
Features []Feature
Capabilities []Capability
}
Metadata describes the plugin product before instance registration.
type MetricDefinition ¶
type MetricDefinition struct {
Buckets []float64
Labels []string
Name string
Help string
Type MetricType
// Compatibility requests an operator-allowlisted exact legacy collector in addition to the native metric.
Compatibility bool
}
MetricDefinition describes one plugin-owned metric.
type MetricType ¶
type MetricType string
MetricType identifies a Prometheus collector family without exposing Prometheus types.
const ( // MetricTypeCounter selects a monotonically increasing counter collector. MetricTypeCounter MetricType = "counter" // MetricTypeGauge selects a gauge collector. MetricTypeGauge MetricType = "gauge" // MetricTypeHistogram selects a histogram collector with explicit or default buckets. MetricTypeHistogram MetricType = "histogram" // MetricTypeSummary selects a summary collector. MetricTypeSummary MetricType = "summary" )
type Metrics ¶
type Metrics interface {
Counter(MetricDefinition) (Counter, error)
Gauge(MetricDefinition) (Gauge, error)
Histogram(MetricDefinition) (Histogram, error)
Summary(MetricDefinition) (Summary, error)
}
Metrics registers and returns host-owned plugin metric handles.
type ObligationRequest ¶
type ObligationRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Args ArgsView
Facts []PolicyFact
}
ObligationRequest is passed to synchronous policy obligation targets.
type ObligationResult ¶
type ObligationResult struct {
Status *StatusMessage
Logs []LogField
Facts []PolicyFact
Response ResponseMutation
RuntimeDelta RuntimeDelta
Applied bool
Temporary bool
}
ObligationResult is returned by synchronous policy obligation targets.
type ObligationTarget ¶
type ObligationTarget interface {
Name() string
Execute(context.Context, ObligationRequest) (ObligationResult, error)
}
ObligationTarget executes synchronous policy-selected enforcement.
type PolicyDecision ¶
type PolicyDecision string
PolicyDecision is a transport-independent policy effect.
const ( // PolicyDecisionNeutral allows the current stage to continue. PolicyDecisionNeutral PolicyDecision = "neutral" // PolicyDecisionDeny rejects the current operation. PolicyDecisionDeny PolicyDecision = "deny" // PolicyDecisionPermit permits the current operation where the stage allows it. PolicyDecisionPermit PolicyDecision = "permit" // PolicyDecisionTempFail reports a temporary failure for the current operation. PolicyDecisionTempFail PolicyDecision = "tempfail" )
type PolicyFact ¶
PolicyFact carries a typed policy value emitted by a plugin.
type PolicyOperation ¶
type PolicyOperation string
PolicyOperation identifies the request operation evaluated by policy code.
const ( // PolicyOperationAuthenticate is normal password authentication. PolicyOperationAuthenticate PolicyOperation = "authenticate" // PolicyOperationLookupIdentity is trusted identity lookup without password verification. PolicyOperationLookupIdentity PolicyOperation = "lookup_identity" // PolicyOperationListAccounts is account-list provider evaluation. PolicyOperationListAccounts PolicyOperation = "list_accounts" )
type PolicyStage ¶
type PolicyStage string
PolicyStage identifies a policy evaluation checkpoint.
const ( // PolicyStagePreAuth covers checks that run before backend authentication. PolicyStagePreAuth PolicyStage = "pre_auth" // PolicyStageAuthBackend covers backend and password evaluation facts. PolicyStageAuthBackend PolicyStage = "auth_backend" // PolicyStageSubjectAnalysis covers subject analysis after backend evaluation. PolicyStageSubjectAnalysis PolicyStage = "subject_analysis" // PolicyStageAccountProvider covers account-list provider facts. PolicyStageAccountProvider PolicyStage = "account_provider" // PolicyStageAuthDecision covers final auth result selection. PolicyStageAuthDecision PolicyStage = "auth_decision" )
type PostActionEnqueueResult ¶
type PostActionEnqueueResult struct {
Status *StatusMessage
Logs []LogField
RuntimeDelta RuntimeDelta
QueuedID string
Enqueued bool
Temporary bool
}
PostActionEnqueueResult is returned after detached post-action work is accepted or skipped.
type PostActionRequest ¶
type PostActionRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Credentials CredentialProvider
PasswordHash string
Args ArgsView
Facts []PolicyFact
}
PostActionRequest is passed to asynchronous post-action enqueue targets.
type PostActionTarget ¶
type PostActionTarget interface {
Name() string
Enqueue(context.Context, PostActionRequest) (PostActionEnqueueResult, error)
}
PostActionTarget enqueues detached post-decision work under host supervision.
type PublicMFAStateBackend ¶
type PublicMFAStateBackend interface {
PublicMFAState(context.Context, PublicMFAStateRequest) (PublicMFAStateResult, error)
}
PublicMFAStateBackend is implemented by backends that can read public MFA state.
type PublicMFAStateRequest ¶
type PublicMFAStateRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Username string
IncludeWebAuthn bool
}
PublicMFAStateRequest asks a backend for public MFA metadata.
type PublicMFAStateResult ¶
type PublicMFAStateResult struct {
Status *StatusMessage
BackendServer *BackendServerRef
WebAuthnCredentials []WebAuthnCredential
RecoveryCodeCount int
HasTOTP bool
HasWebAuthn bool
}
PublicMFAStateResult contains public MFA metadata safe for identity edges.
type RecoveryCodeBackend ¶
type RecoveryCodeBackend interface {
GenerateRecoveryCodes(context.Context, RecoveryCodeGenerateRequest) (RecoveryCodeGenerateResult, error)
UseRecoveryCode(context.Context, RecoveryCodeUseRequest) (RecoveryCodeUseResult, error)
DeleteRecoveryCodes(context.Context, RecoveryCodeDeleteRequest) error
}
RecoveryCodeBackend is implemented by backends that own TOTP recovery codes.
type RecoveryCodeDeleteRequest ¶
type RecoveryCodeDeleteRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
IdempotencyKey string
Username string
}
RecoveryCodeDeleteRequest asks a backend to remove recovery codes.
type RecoveryCodeGenerateRequest ¶
type RecoveryCodeGenerateRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
IdempotencyKey string
Username string
Count uint32
}
RecoveryCodeGenerateRequest asks a backend to generate recovery codes.
type RecoveryCodeGenerateResult ¶
type RecoveryCodeGenerateResult struct {
Status *StatusMessage
BackendServer *BackendServerRef
Codes []string
}
RecoveryCodeGenerateResult returns newly generated recovery codes.
type RecoveryCodeUseRequest ¶
type RecoveryCodeUseRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
IdempotencyKey string
Username string
Code string
}
RecoveryCodeUseRequest asks a backend to consume one recovery code.
type RecoveryCodeUseResult ¶
type RecoveryCodeUseResult struct {
Status *StatusMessage
BackendServer *BackendServerRef
Valid bool
Remaining int
}
RecoveryCodeUseResult describes recovery-code consumption.
type Redis ¶
type Redis interface {
Read() redis.Cmdable
Write() redis.Cmdable
ReadPipeline() redis.Pipeliner
WritePipeline() redis.Pipeliner
Keys() RedisKeyBuilder
Scripts() RedisScriptRegistry
}
Redis exposes host-owned Redis command handles without exposing internal singletons.
type RedisKeyBuilder ¶
type RedisKeyBuilder interface {
Key(string) string
Keys(...string) []string
SameSlot([]string, string) []string
}
RedisKeyBuilder builds host-prefixed Redis keys and cluster-safe key groups.
type RedisScriptRegistry ¶
type RedisScriptRegistry interface {
Upload(context.Context, string, string) (string, error)
Run(context.Context, string, []string, ...any) (any, error)
}
RedisScriptRegistry uploads and runs host-managed named Redis scripts.
type Registrar ¶
type Registrar interface {
Config() ConfigView
RequireCapability(Capability) error
RegisterInitTask(InitTask) error
RegisterEnvironmentSource(EnvironmentSource) error
RegisterSubjectSource(SubjectSource) error
RegisterBackend(Backend) error
RegisterObligationTarget(ObligationTarget) error
RegisterPostActionTarget(PostActionTarget) error
RegisterHook(Hook) error
RegisterPolicyAttribute(AttributeDefinition) error
RegisterDebugModule(DebugModuleDefinition) error
}
Registrar records the components declared by one configured plugin module instance.
type ReloadablePlugin ¶
type ReloadablePlugin interface {
Reconfigure(context.Context, ConfigView) error
}
ReloadablePlugin is implemented by plugins that support config-only reloads.
type RequestDiagnostics ¶
type RequestDiagnostics struct {
StatusMessage string
BruteForceName string
EnvironmentName string
LatencyMillis int64
BruteForceCounter uint
HTTPStatus int
}
RequestDiagnostics contains bounded request outcome and diagnostic metadata.
type RequestSnapshot ¶
type RequestSnapshot struct {
Headers map[string][]string
IDP IDPInfo
Session string
ExternalSessionID string
Service string
Protocol string
Method string
Username string
Account string
AccountField string
UniqueUserID string
DisplayName string
ClientIP string
ClientPort string
ClientNet string
ClientHost string
ClientID string
UserAgent string
LocalIP string
LocalPort string
OIDCCID string
SAMLEntityID string
AuthLoginAttempt uint
TLS TLSInfo
Diagnostics RequestDiagnostics
Runtime RuntimeFlags
HealthCheck bool
}
RequestSnapshot contains immutable, redacted request metadata visible to plugins.
type ResponseHeaderMutation ¶
ResponseHeaderMutation describes allowed response header set and delete operations.
type ResponseMutation ¶
type ResponseMutation struct {
Headers ResponseHeaderMutation
StatusHeader bool
}
ResponseMutation carries request-time response changes without exposing server internals.
type RuntimeContext ¶
RuntimeContext exposes an isolated read-only runtime context view.
type RuntimeDelta ¶
RuntimeDelta describes runtime context mutations returned by a plugin call.
type RuntimeFlags ¶
type RuntimeFlags struct {
Debug bool
LocalRequest bool
NoAuth bool
UserFound bool
Authenticated bool
Authorized bool
Repeating bool
RWP bool
EnvironmentRejected bool
EnvironmentStageExpected bool
SubjectStageExpected bool
}
RuntimeFlags describes host-derived runtime conditions for a request snapshot.
type RuntimePlugin ¶
RuntimePlugin is implemented by plugins that need host services or lifecycle hooks.
type SourceDescriptor ¶
type SourceDescriptor struct {
Timeout time.Duration
Name string
Requires []string
After []string
Priority int
AbortPolicy AbortPolicy
}
SourceDescriptor describes one dependency-scheduled Go source component. Requires and After can target local or fully qualified plugin source names; Lua source dependencies are not supported in v1.
type Span ¶
type Span interface {
AddEvent(string, ...TraceAttribute)
SetAttributes(...TraceAttribute)
RecordError(error)
SetStatus(SpanStatus, string)
End()
}
Span records plugin-created tracing details through a host-owned tracer.
type SpanKind ¶
type SpanKind uint8
SpanKind describes the relationship between a span and the operation it represents.
const ( // SpanKindInternal identifies an in-process operation. SpanKindInternal SpanKind = iota // SpanKindServer identifies inbound request handling. SpanKindServer // SpanKindClient identifies an outbound client operation. SpanKindClient // SpanKindProducer identifies message production. SpanKindProducer // SpanKindConsumer identifies message consumption. SpanKindConsumer )
type SpanStartOptions ¶
type SpanStartOptions struct {
Attributes []TraceAttribute
Kind SpanKind
}
SpanStartOptions contains value-only options for a plugin-owned span.
type SpanStatus ¶
type SpanStatus uint8
SpanStatus describes the explicit completion state of a span.
const ( // SpanStatusUnset leaves status inference to the tracing backend. SpanStatusUnset SpanStatus = iota // SpanStatusOK marks a completed operation as successful. SpanStatusOK // SpanStatusError marks a completed operation as failed. SpanStatusError )
type StatusMessage ¶
StatusMessage is a protocol-neutral status signal returned by plugins.
type SubjectRequest ¶
type SubjectRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
BackendResult BackendResult
Credentials CredentialProvider
}
SubjectRequest is passed to post-backend subject sources.
type SubjectResult ¶
type SubjectResult struct {
Status *StatusMessage
SelectedBackend *BackendServerRef
BackendResultPatch *BackendResultPatch
Logs []LogField
Facts []PolicyFact
BackendAttributes AttributePatch
Response ResponseMutation
RuntimeDelta RuntimeDelta
Rejected bool
}
SubjectResult is returned by post-backend subject sources.
type SubjectSource ¶
type SubjectSource interface {
Descriptor() SourceDescriptor
Evaluate(context.Context, SubjectRequest) (SubjectResult, error)
}
SubjectSource enriches or rejects a subject after backend evaluation.
type Summary ¶
type Summary interface {
Observe(context.Context, float64, ...LabelValue)
}
Summary records sampled plugin measurements as quantiles.
type TLSInfo ¶
type TLSInfo struct {
Legacy TLSLegacyInfo
ServerName string
CipherSuite string
PeerCommonName string
PeerIssuer string
Version string
VerifiedChains int
Enabled bool
Mutual bool
}
TLSInfo describes the accepted TLS state for a request.
type TLSLegacyInfo ¶
type TLSLegacyInfo struct {
State string
SessionID string
ClientVerify string
ClientDN string
ClientCommonName string
Issuer string
ClientNotBefore string
ClientNotAfter string
SubjectDN string
IssuerDN string
ClientSubjectDN string
ClientIssuerDN string
Protocol string
CipherSuite string
Serial string
Fingerprint string
}
TLSLegacyInfo preserves safe legacy ssl_* request metadata without exposing server internals.
type TOTPBackend ¶
type TOTPBackend interface {
BeginTOTP(context.Context, TOTPBeginRequest) (TOTPBeginResult, error)
FinishTOTP(context.Context, TOTPFinishRequest) (TOTPFinishResult, error)
VerifyTOTP(context.Context, TOTPVerifyRequest) (TOTPVerifyResult, error)
DeleteTOTP(context.Context, TOTPDeleteRequest) error
}
TOTPBackend is implemented by backends that own TOTP operations.
type TOTPBeginRequest ¶
type TOTPBeginRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
IdempotencyKey string
Username string
}
TOTPBeginRequest starts a backend-owned TOTP registration flow.
type TOTPBeginResult ¶
type TOTPBeginResult struct {
Status *StatusMessage
BackendServer *BackendServerRef
ExpiresAt time.Time
PendingRegistrationID string
OTPAuthURL string
}
TOTPBeginResult returns backend-owned TOTP registration state.
type TOTPDeleteRequest ¶
type TOTPDeleteRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
IdempotencyKey string
Username string
}
TOTPDeleteRequest removes TOTP state from a backend.
type TOTPFinishRequest ¶
type TOTPFinishRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
IdempotencyKey string
Username string
PendingRegistrationID string
Code string
}
TOTPFinishRequest completes a backend-owned TOTP registration flow.
type TOTPFinishResult ¶
type TOTPFinishResult struct {
Status *StatusMessage
BackendServer *BackendServerRef
Verified bool
}
TOTPFinishResult describes the result of completing TOTP registration.
type TOTPVerifyRequest ¶
type TOTPVerifyRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Username string
Code string
}
TOTPVerifyRequest verifies a TOTP code against a backend.
type TOTPVerifyResult ¶
type TOTPVerifyResult struct {
Status *StatusMessage
BackendServer *BackendServerRef
Verified bool
}
TOTPVerifyResult describes a TOTP verification result.
type TraceAttribute ¶
TraceAttribute is one low-cardinality tracing attribute.
type Tracer ¶
type Tracer interface {
Start(context.Context, string, ...TraceAttribute) (context.Context, Span)
StartWithOptions(context.Context, string, SpanStartOptions) (context.Context, Span)
}
Tracer starts child spans from plugin call contexts.
type WebAuthnBackend ¶
type WebAuthnBackend interface {
ListWebAuthnCredentials(context.Context, WebAuthnListRequest) (WebAuthnListResult, error)
SaveWebAuthnCredential(context.Context, WebAuthnSaveRequest) error
UpdateWebAuthnCredential(context.Context, WebAuthnUpdateRequest) error
DeleteWebAuthnCredential(context.Context, WebAuthnDeleteRequest) error
}
WebAuthnBackend is implemented by backends that own WebAuthn credentials.
type WebAuthnCredential ¶
type WebAuthnCredential struct {
LastUsed time.Time
ID []byte
PublicKey []byte
Transports []string
AAGUID string
Attestation string
Authenticator string
SignCount uint32
BackupState bool
BackupEligible bool
}
WebAuthnCredential carries API-level WebAuthn credential metadata.
type WebAuthnDeleteRequest ¶
type WebAuthnDeleteRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Username string
CredentialID []byte
}
WebAuthnDeleteRequest asks a backend to delete one WebAuthn credential.
type WebAuthnListRequest ¶
type WebAuthnListRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Username string
}
WebAuthnListRequest asks a backend for WebAuthn credentials.
type WebAuthnListResult ¶
type WebAuthnListResult struct {
Status *StatusMessage
BackendServer *BackendServerRef
Credentials []WebAuthnCredential
}
WebAuthnListResult returns WebAuthn credentials.
type WebAuthnSaveRequest ¶
type WebAuthnSaveRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Username string
Credential WebAuthnCredential
}
WebAuthnSaveRequest asks a backend to save one WebAuthn credential.
type WebAuthnUpdateRequest ¶
type WebAuthnUpdateRequest struct {
Snapshot RequestSnapshot
Runtime RuntimeContext
Username string
OldCredential WebAuthnCredential
NewCredential WebAuthnCredential
}
WebAuthnUpdateRequest asks a backend to replace one WebAuthn credential.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package exchange defines the public runtime exchange keyspace shared by Nauthilus plugins.
|
Package exchange defines the public runtime exchange keyspace shared by Nauthilus plugins. |
|
Package helpers contains deterministic, non-secret helpers for native plugins.
|
Package helpers contains deterministic, non-secret helpers for native plugins. |
|
Package password exposes Nauthilus-compatible password comparison and full password-hash helpers for native Go plugins without importing server internals.
|
Package password exposes Nauthilus-compatible password comparison and full password-hash helpers for native Go plugins without importing server internals. |