OpenAgentID documentation
Source referencesRust module referenceopenagent-aegis-core

openagent-aegis-core · plugin

Declared module signatures, types, configuration, and source documentation.

Source: aegis/openagent-aegis-core/src/plugin.rs. SHA-256: 31309c020db740be017aadfba79c93a91f34f46791eca5b9801d67ff4d0a365a.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

plugin::CreateDidParams

Parameters for creating a new DID.

#[derive(Debug, Clone)]
pub struct CreateDidParams {
/// Entity kind (human, agent, organization).

pub entity_kind: String,
/// Namespace for the DID.

pub namespace: String,
/// Unique identifier within the namespace.

pub identifier: String,
/// Additional creation parameters.

pub metadata: HashMap<String, String>
}

Source line: 25.

plugin::DidCreationResult

Result of creating a new DID.

#[derive(Debug, Clone)]
pub struct DidCreationResult {
/// The created DID string.

pub did: String,
/// The initial OAS Identity Document.

pub document: OasDocument
}

Source line: 38.

plugin::DidResolver

DID Resolver plugin interface (AEGIS Spec §4.1).

Enables AEGIS to resolve any DID method without coupling to a specific resolution mechanism. Each resolver handles one or more DID methods.

#[async_trait]
pub trait DidResolver: Send + Sync {
    /// Resolve a DID to its DID Document.
    ///
    /// MUST return a valid OAS Document or an error.
    /// MUST complete within 5 seconds (SHOULD within 3 seconds).
    async fn resolve(&self, did: &str) -> Result<OasDocument, ResolverError>;

    /// Check if this resolver handles the given DID.
    fn handles(&self, did: &str) -> bool;

    /// List supported DID methods (e.g., ["oas", "key"]).
    fn supported_methods(&self) -> Vec<String>;

    /// Create a new DID (optional — not all resolvers support creation).
    async fn create(&self, _params: CreateDidParams) -> Result<DidCreationResult, ResolverError> ;

    /// Update a DID Document (optional).
    async fn update(&self, _did: &str, _document: OasDocument) -> Result<(), ResolverError> ;

    /// Deactivate a DID (optional).
    async fn deactivate(&self, _did: &str) -> Result<(), ResolverError> ;
}

Source line: 50.

plugin::AuthProvider

Auth Provider plugin interface (AEGIS Spec §4.2).

Validates credentials and returns authentication context. Each provider handles specific credential types (OAuth, challenge-response, API keys, etc.).

#[async_trait]
pub trait AuthProvider: Send + Sync {
    /// Validate a credential and return auth context.
    ///
    /// MUST return a valid `AuthContext` or an error.
    /// MUST verify cryptographic integrity of the credential.
    async fn validate(&self, credential: &AuthCredential) -> Result<AuthContext, AuthError>;

    /// Get identity information from auth context.
    async fn get_identity(&self, ctx: &AuthContext) -> Result<AegisIdentity, AuthError>;

    /// Get the provider identifier.
    fn provider_name(&self) -> &str;

    /// Refresh a session or token (optional).
    async fn refresh(&self, _ctx: &AuthContext) -> Result<AuthContext, AuthError> ;

    /// Revoke a session (optional).
    async fn revoke(&self, _ctx: &AuthContext) -> Result<(), AuthError> ;
}

Source line: 88.

plugin::PolicyEngine

Policy Engine plugin interface (AEGIS Spec §4.3).

Evaluates authorization decisions. Only one policy engine is active at any time. If unavailable, AEGIS MUST fail-closed (deny all).

#[async_trait]
pub trait PolicyEngine: Send + Sync {
    /// Evaluate a policy request.
    ///
    /// MUST return a `PolicyDecision` including allowed/denied and obligations.
    /// MUST complete within 100ms (SHOULD within 50ms).
    /// Evaluation MUST be deterministic.
    async fn evaluate(&self, request: &PolicyRequest) -> Result<PolicyDecision, PolicyError>;

    /// Simple permission check (convenience wrapper).
    async fn check_permission(&self, check: &PermissionCheck) -> Result<bool, PolicyError>;

    /// Get the engine identifier.
    fn engine_name(&self) -> &str;

    /// List policies for an identity (optional).
    async fn get_policies(&self, _did: &str) -> Result<Vec<serde_json::Value>, PolicyError> ;
}

Source line: 125.

plugin::PluginRegistry

The Plugin Registry manages all loaded plugins and routes requests to the appropriate plugin (AEGIS Spec §4.4).

Requirements:

  • Supports multiple DID Resolvers (routes by handles() method matching).
  • Supports multiple Auth Providers (keyed by provider_name()).
  • Supports exactly one Policy Engine.
  • Plugin registration order is deterministic.
pub struct PluginRegistry {

}

Source line: 157.

plugin::PluginRegistry::new

Create an empty plugin registry.

pub fn new() -> Self;

Source line: 168.

plugin::PluginRegistry::register_resolver

Register a DID Resolver plugin.

Resolvers are tried in registration order. The first resolver whose handles() returns true for a given DID is used.

pub fn register_resolver(&mut self, resolver: Arc<dyn DidResolver>);

Source line: 180.

plugin::PluginRegistry::register_auth_provider

Register an Auth Provider plugin.

Providers are keyed by provider_name(). Registering a provider with the same name replaces the previous one.

pub fn register_auth_provider(&mut self, provider: Arc<dyn AuthProvider>);

Source line: 188.

plugin::PluginRegistry::set_policy_engine

Set the active Policy Engine plugin.

Only one policy engine may be active. Setting a new one replaces the previous engine.

pub fn set_policy_engine(&mut self, engine: Arc<dyn PolicyEngine>);

Source line: 197.

plugin::PluginRegistry::resolve_did

Resolve a DID by routing to the appropriate resolver.

Iterates over registered resolvers in order and uses the first resolver whose handles() method returns true.

pub async fn resolve_did(&self, did: &str) -> Result<OasDocument, ResolverError>;

Source line: 205.

plugin::PluginRegistry::validate_credential

Validate a credential by routing to the named provider, or trying each provider if no explicit name is given.

pub async fn validate_credential(
        &self,
        credential: &AuthCredential,
        provider_name: Option<&str>,
    ) -> Result<AuthContext, AuthError>;

Source line: 218.

plugin::PluginRegistry::evaluate_policy

Evaluate a policy request.

If no policy engine is registered, MUST fail-closed.

pub async fn evaluate_policy(
        &self,
        request: &PolicyRequest,
    ) -> Result<PolicyDecision, PolicyError>;

Source line: 249.

plugin::PluginRegistry::check_permission

Simple permission check via the policy engine.

pub async fn check_permission(&self, check: &PermissionCheck) -> Result<bool, PolicyError>;

Source line: 260.

plugin::PluginRegistry::get_resolver_for

Get a DID resolver by DID method.

pub fn get_resolver_for(&self, did: &str) -> Option<&Arc<dyn DidResolver>>;

Source line: 268.

plugin::PluginRegistry::get_auth_provider

Get an auth provider by name.

pub fn get_auth_provider(&self, name: &str) -> Option<&Arc<dyn AuthProvider>>;

Source line: 273.

plugin::PluginRegistry::get_policy_engine

Get the active policy engine.

pub fn get_policy_engine(&self) -> Option<&Arc<dyn PolicyEngine>>;

Source line: 278.

plugin::PluginRegistry::resolver_count

Returns the number of registered DID resolvers.

pub fn resolver_count(&self) -> usize;

Source line: 283.

plugin::PluginRegistry::auth_provider_count

Returns the number of registered auth providers.

pub fn auth_provider_count(&self) -> usize;

Source line: 288.

plugin::PluginRegistry::has_policy_engine

Returns true if a policy engine is registered.

pub fn has_policy_engine(&self) -> bool;

Source line: 293.

On this page