# panva/node-oidc-provider architecture

> Architecture diagram of the GitHub repository panva/node-oidc-provider, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/panva/node-oidc-provider
- Repository: https://github.com/panva/node-oidc-provider

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Authorization Server
- Authorization Endpoint
- Token Endpoint
- UserInfo Endpoint
- Discovery Endpoint
- Registration Endpoint
- Introspection Endpoint
- Revocation Endpoint

b) Storage Layer
- Adapters (Multiple implementations: Redis, MongoDB, etc.)
- Models (Access Tokens, Authorization Codes, Clients, etc.)

c) Security & Authentication
- JWT Handler
- Encryption Layer
- PKCE Implementation
- DPoP Implementation

d) Interaction Handlers
- Login Flows
- Consent Management
- Session Management

##### Component Relationships

**┌─────────────────────────────────────────────────────────────────┐**
- OIDC Provider Core                          │
- ┬────────────────────────┬────────────────────┤
- Authorization  │      Token Flow        │    Discovery &     │
- Flow       │     Management         │   Registration     │
- ┬────────┴──────────┬─────────────┴────────┬───────────┘

- ▼                    ▼                      ▼
**┌─────────────────────────────────────────────────────────────────┐**
- Security Layer                              │
- ┬─────────────────┬────────────────┬────────────┤
- JWT Handling  │     PKCE        │     DPoP       │   MTLS     │
- ┴─────────────────┴────────────────┴────────────┘

- ▼                    ▼                      ▼
**┌─────────────────────────────────────────────────────────────────┐**
- Storage Layer                               │
- ┬─────────────────┬────────────────┬────────────┤
- Models      │    Adapters     │   Sessions     │  Grants    │
- ┴─────────────────┴────────────────┴────────────┘

##### Important Elements

- External integration points (for client applications)
- Security boundaries
- Data persistence flows
- Session management paths

##### Specific Implementation Details

- Support for multiple response types (code, implicit, hybrid)
- Various token formats (JWT, opaque)
- Multiple client authentication methods
- Interaction points for custom implementations

##### Implementation Notes

Callouts for:
- Supported specifications
- Configuration options
- Extension points
- Security considerations

- Clear hierarchical representation
- Proper flow visualization
- Component relationship mapping
- Security boundary marking

Remember to include version information and supported specification references as documented in the README to ensure accuracy and completeness of the architectural representation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core["Core Authorization Server"]
        direction TB
        Auth["Authorization Endpoint"]
        Token["Token Endpoint"]
        UserInfo["UserInfo Endpoint"]
        Discovery["Discovery Endpoint"]
        Registration["Registration Endpoint"]
        Introspection["Introspection Endpoint"]
        Revocation["Revocation Endpoint"]
    end

    subgraph Security["Security Layer"]
        direction TB
        JWT["JWT Handler"]
        PKCE["PKCE Implementation"]
        DPoP["DPoP Implementation"]
        Encryption["Encryption Layer"]
    end

    subgraph Storage["Storage Layer"]
        direction TB
        Adapters["Storage Adapters"]
        Models["Data Models"]
        TokenStore["Token Storage"]
        ClientStore["Client Storage"]
        SessionStore["Session Storage"]
    end

    subgraph Interaction["Interaction Handlers"]
        direction TB
        InteractionMgmt["Interaction Management"]
        LoginFlow["Login Flow"]
        ConsentMgmt["Consent Management"]
        SessionMgmt["Session Management"]
    end

    subgraph Response["Response Modes"]
        direction TB
        RespHandlers["Response Handlers"]
        FormPost["Form Post"]
        Fragment["Fragment"]
        Query["Query"]
    end

    Core --> Security
    Core --> Storage
    Core --> Interaction
    Core --> Response
    Security --> Storage
    Interaction --> Storage

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef core fill:#dae8fc,stroke:#6c8ebf
    classDef security fill:#d5e8d4,stroke:#82b366
    classDef storage fill:#fff2cc,stroke:#d6b656
    classDef interaction fill:#e1d5e7,stroke:#9673a6
    classDef response fill:#f8cecc,stroke:#b85450

    class Auth,Token,UserInfo,Discovery,Registration,Introspection,Revocation core
    class JWT,PKCE,DPoP,Encryption security
    class Adapters,Models,TokenStore,ClientStore,SessionStore storage
    class InteractionMgmt,LoginFlow,ConsentMgmt,SessionMgmt interaction
    class RespHandlers,FormPost,Fragment,Query response

    click Auth "https://github.com/panva/node-oidc-provider/tree/main/lib/actions/authorization/"
    click Token "https://github.com/panva/node-oidc-provider/blob/main/lib/actions/token.js"
    click UserInfo "https://github.com/panva/node-oidc-provider/blob/main/lib/actions/userinfo.js"
    click Discovery "https://github.com/panva/node-oidc-provider/blob/main/lib/actions/discovery.js"
    click Registration "https://github.com/panva/node-oidc-provider/blob/main/lib/actions/registration.js"
    click Introspection "https://github.com/panva/node-oidc-provider/blob/main/lib/actions/introspection.js"
    click Revocation "https://github.com/panva/node-oidc-provider/blob/main/lib/actions/revocation.js"
    click Adapters "https://github.com/panva/node-oidc-provider/blob/main/lib/adapters/memory_adapter.js"
    click Models "https://github.com/panva/node-oidc-provider/tree/main/lib/models/"
    click TokenStore "https://github.com/panva/node-oidc-provider/blob/main/lib/models/access_token.js"
    click ClientStore "https://github.com/panva/node-oidc-provider/blob/main/lib/models/client.js"
    click SessionStore "https://github.com/panva/node-oidc-provider/blob/main/lib/models/session.js"
    click JWT "https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/jwt.js"
    click PKCE "https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/pkce.js"
    click DPoP "https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/validate_dpop.js"
    click Encryption "https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/keystore.js"
    click InteractionMgmt "https://github.com/panva/node-oidc-provider/tree/main/lib/helpers/interaction_policy/"
    click LoginFlow "https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/interaction_policy/prompts/login.js"
    click ConsentMgmt "https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/interaction_policy/prompts/consent.js"
    click SessionMgmt "https://github.com/panva/node-oidc-provider/blob/main/lib/shared/session.js"
    click RespHandlers "https://github.com/panva/node-oidc-provider/tree/main/lib/response_modes/"
    click FormPost "https://github.com/panva/node-oidc-provider/blob/main/lib/response_modes/form_post.js"
    click Fragment "https://github.com/panva/node-oidc-provider/blob/main/lib/response_modes/fragment.js"
    click Query "https://github.com/panva/node-oidc-provider/blob/main/lib/response_modes/query.js"
```
