Skip to content

Plugin System Overview

The Authrim Plugin System provides a modular architecture for integrating external services and custom functionality into the Authrim identity platform. Plugins are bundled with Workers at deploy time, while their configuration can be resolved from environment bootstrap values and KV-backed global or tenant overrides.

Plugin TypeCapability PatternExamples
Notifiernotifier.{channel}Email, SMS, Push notifications
Identity Provideridp.{provider}Google, SAML, OIDC federation
Authenticatorauthenticator.{method}TOTP, Passkey, OTP
Flowflow.{name}Custom authentication flow nodes (future)

The plugin system follows a three-layer architecture that separates Worker request handling, plugin capability registration, and runtime infrastructure access:

flowchart TB
    subgraph Application["Application Layer"]
        direction LR
        A1[ar-auth]
        A2[ar-token]
        A3[ar-userinfo]
        A4[ar-management]
    end

    subgraph Plugin["Plugin Layer"]
        direction LR
        P1[Notifier<br/>email, sms, push]
        P2[IdP<br/>provider handlers]
        P3[Authenticator<br/>method handlers]
    end

    subgraph Infra["Infrastructure Layer"]
        direction LR
        I1[Storage Stores<br/>D1, KV, DO, tenant profiles]
        I2[Policy Infra<br/>ReBAC, ABAC]
    end

    Application -->|PluginContext| Plugin
    Plugin -->|store and policy interfaces| Infra
AspectPlugin LayerInfrastructure Layer
SwitchingDeploy-time code, runtime configRuntime storage profile or deployment resource change
Failure ImpactUsually limited to the capability using the pluginCan affect shared storage, policy, or protocol state
Tenant VarianceGlobal defaults plus tenant overridesDepends on the selected runtime storage profile
ConfigurationWorker bootstrap env + KV config.authrim, wrangler bindings, D1/KV/DO resources
PrincipleDescription
Hybrid ConfigurationStatic code bundling with bootstrap env and KV-based configuration
Type SafetyFull TypeScript support with Zod schema validation
Cloudflare NativeDesigned for Workers and explicit deployment bindings
Multi-TenantTenant-specific plugin configuration supported where the Worker loads the plugin

Since Authrim runs on Cloudflare Workers, plugin loading is intentionally explicit:

Plugin trust is determined by distribution source, not metadata claims:

Trust LevelSourceUI Display
officialBuilt into ar-lib-plugin/builtin/Authrim Official (Built-in)
officialnpm @authrim/* scopeAuthrim Official (npm)
communityOther npm packages or local filesCommunity Plugin

Authrim currently registers these official notifier plugins for discovery. ar-auth bootstraps the email plugins from Worker env values when configured, then resolves KV overrides through the plugin context.

Plugin IDTypeDescription
notifier-consoleNotifierConsole logger for development
notifier-cloudflareNotifierCloudflare Email Service binding
notifier-resendNotifierResend Email API

Authenticator and identity-provider plugin capabilities are part of the plugin API, but only notifier plugins are auto-registered for Admin UI discovery today. Register additional capability plugins explicitly in the Worker that uses them.

┌─────────────────────────────────────────────────────────┐
│ Plugin Lifecycle │
├─────────────────────────────────────────────────────────┤
│ 1. RESOLVE CONFIG │
│ ├── Merge bootstrap env, global KV, tenant KV │
│ └── Validate config against schema │
├─────────────────────────────────────────────────────────┤
│ 2. INITIALIZE (optional) │
│ ├── Connect to external services │
│ ├── Warm up caches │
│ └── Validate dependencies │
├─────────────────────────────────────────────────────────┤
│ 3. REGISTER │
│ ├── Register capabilities with registry │
│ └── Must be synchronous, no side effects │
├─────────────────────────────────────────────────────────┤
│ 4. ACTIVE │
│ └── Plugin handles requests via registered handlers │
├─────────────────────────────────────────────────────────┤
│ 5. HEALTH / ADMIN INSPECTION │
│ ├── Expose schema and status │
│ └── Report dependency health when implemented │
└─────────────────────────────────────────────────────────┘