# openidc/liboauth2 architecture

> Architecture diagram of the GitHub repository openidc/liboauth2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openidc/liboauth2
- Repository: https://github.com/openidc/liboauth2

## Overview

liboauth2 is a reusable C library for OAuth 2.x and OpenID Connect clients, servers, and web-server bindings. A typical request enters through an Apache or NGINX binding, is represented through the HTTP abstraction, and is processed by protocol/token-verification or OpenID Connect logic; session handling and configurable caches support the resulting authentication flow. The README documents additional protocol and token-location capabilities that are represented at subsystem level because their implementation was not sampled. Edges are limited to documented relationships or source-index references; unsampled wiring is omitted.

Main entry points: [`src/oauth2.c`](https://github.com/openidc/liboauth2/blob/master/src/oauth2.c) (OAuth token engine), [`src/http.c`](https://github.com/openidc/liboauth2/blob/master/src/http.c) (HTTP abstraction), [`src/openidc/openidc.c`](https://github.com/openidc/liboauth2/blob/master/src/openidc/openidc.c) (OIDC flow), [`src/cache.c`](https://github.com/openidc/liboauth2/blob/master/src/cache.c) (Cache framework)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bindings["Web-server bindings"]
  node_apache["Apache binding<br/>[apache.c]"]
  node_nginx["NGINX binding<br/>[nginx.c]"]
end

subgraph group_protocol["OAuth and security"]
  node_oauth_engine["OAuth token engine<br/>[oauth2.c]"]
  node_protocol_ops["Protocol operations<br/>[proto.c]"]
  node_dpop["DPoP validation<br/>[dpop.c]"]
  node_jose["JOSE and JWT<br/>[jose.c]"]
end

subgraph group_oidc["OpenID Connect"]
  node_openidc_flow["OIDC flow<br/>[openidc.c]"]
  node_oidc_client["OIDC client<br/>[client.c]"]
  node_provider_resolver["Provider resolver<br/>[resolver.c]"]
  node_provider_state["Provider and state<br/>[state.c]"]
  node_session["Session management<br/>[session.c]"]
end

subgraph group_foundation["Shared infrastructure"]
  node_http["HTTP abstraction<br/>[http.c]"]
  node_configuration["Configuration"]
  node_cache_api["Cache framework<br/>[cache.c]"]
  node_cache_backends["Cache backends"]
  node_ipc["Interprocess support<br/>[ipc.c]"]
  node_utilities["Utilities<br/>[util.c]"]
end

node_web_client(("Web client"))

node_web_client -->|"sends request"| node_apache
node_web_client -->|"sends request"| node_nginx
node_apache -->|"abstracts requests"| node_http
node_nginx -->|"abstracts requests"| node_http
node_http -.->|"provides request"| node_oauth_engine
node_oauth_engine -->|"uses JWT"| node_jose
node_oauth_engine -->|"uses HTTP"| node_http
node_oauth_engine -.->|"validates proof"| node_dpop
node_oauth_engine -.->|"supports protocol"| node_protocol_ops
node_openidc_flow -->|"uses OAuth"| node_oauth_engine
node_openidc_flow -->|"uses JOSE"| node_jose
node_openidc_flow -->|"uses sessions"| node_session
node_openidc_flow -.->|"resolves provider"| node_provider_resolver
node_oidc_client -.->|"uses resolver"| node_provider_resolver
node_provider_state -.->|"supports state"| node_openidc_flow
node_session -->|"stores records"| node_cache_api
node_cache_api -->|"dispatches backend"| node_cache_backends
node_provider_resolver -->|"uses cache"| node_cache_api
node_configuration -->|"configures cache"| node_cache_api
node_configuration -->|"uses IPC"| node_ipc
node_http -->|"uses helpers"| node_utilities
node_jose -->|"fetches keys"| node_http

click node_apache "https://github.com/openidc/liboauth2/blob/master/src/server/apache.c"
click node_nginx "https://github.com/openidc/liboauth2/blob/master/src/server/nginx.c"
click node_http "https://github.com/openidc/liboauth2/blob/master/src/http.c"
click node_oauth_engine "https://github.com/openidc/liboauth2/blob/master/src/oauth2.c"
click node_protocol_ops "https://github.com/openidc/liboauth2/blob/master/src/proto.c"
click node_dpop "https://github.com/openidc/liboauth2/blob/master/src/dpop.c"
click node_jose "https://github.com/openidc/liboauth2/blob/master/src/jose.c"
click node_openidc_flow "https://github.com/openidc/liboauth2/blob/master/src/openidc/openidc.c"
click node_oidc_client "https://github.com/openidc/liboauth2/blob/master/src/openidc/client.c"
click node_provider_resolver "https://github.com/openidc/liboauth2/blob/master/src/openidc/resolver.c"
click node_provider_state "https://github.com/openidc/liboauth2/blob/master/src/openidc/state.c"
click node_session "https://github.com/openidc/liboauth2/blob/master/src/session.c"
click node_configuration "https://github.com/openidc/liboauth2/tree/master/src/cfg"
click node_cache_api "https://github.com/openidc/liboauth2/blob/master/src/cache.c"
click node_cache_backends "https://github.com/openidc/liboauth2/tree/master/src/cache"
click node_ipc "https://github.com/openidc/liboauth2/blob/master/src/ipc.c"
click node_utilities "https://github.com/openidc/liboauth2/blob/master/src/util.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_apache,node_nginx,node_web_client toneBlue
class node_oauth_engine,node_protocol_ops,node_dpop,node_jose toneAmber
class node_openidc_flow,node_oidc_client,node_provider_resolver,node_provider_state,node_session toneMint
class node_http,node_configuration,node_cache_api,node_cache_backends,node_ipc,node_utilities toneRose
```

## Components

### Web-server bindings

- [Apache binding](https://github.com/openidc/liboauth2/blob/master/src/server/apache.c): `src/server/apache.c`
- [NGINX binding](https://github.com/openidc/liboauth2/blob/master/src/server/nginx.c): `src/server/nginx.c`

### OAuth and security

- [OAuth token engine](https://github.com/openidc/liboauth2/blob/master/src/oauth2.c): `src/oauth2.c`
- [Protocol operations](https://github.com/openidc/liboauth2/blob/master/src/proto.c): `src/proto.c`
- [DPoP validation](https://github.com/openidc/liboauth2/blob/master/src/dpop.c): `src/dpop.c`
- [JOSE and JWT](https://github.com/openidc/liboauth2/blob/master/src/jose.c): `src/jose.c`

### OpenID Connect

- [OIDC flow](https://github.com/openidc/liboauth2/blob/master/src/openidc/openidc.c): `src/openidc/openidc.c`
- [OIDC client](https://github.com/openidc/liboauth2/blob/master/src/openidc/client.c): `src/openidc/client.c`
- [Provider resolver](https://github.com/openidc/liboauth2/blob/master/src/openidc/resolver.c): `src/openidc/resolver.c`
- [Provider and state](https://github.com/openidc/liboauth2/blob/master/src/openidc/state.c): `src/openidc/state.c`
- [Session management](https://github.com/openidc/liboauth2/blob/master/src/session.c): `src/session.c`

### Shared infrastructure

- [HTTP abstraction](https://github.com/openidc/liboauth2/blob/master/src/http.c): `src/http.c`
- [Configuration](https://github.com/openidc/liboauth2/tree/master/src/cfg): `src/cfg`
- [Cache framework](https://github.com/openidc/liboauth2/blob/master/src/cache.c): `src/cache.c`
- [Cache backends](https://github.com/openidc/liboauth2/tree/master/src/cache): `src/cache`
- [Interprocess support](https://github.com/openidc/liboauth2/blob/master/src/ipc.c): `src/ipc.c`
- [Utilities](https://github.com/openidc/liboauth2/blob/master/src/util.c): `src/util.c`

### Other components

- **Web client**

## Connections

- Web client → Apache binding: sends request
- Web client → NGINX binding: sends request
- Apache binding → HTTP abstraction: abstracts requests
- NGINX binding → HTTP abstraction: abstracts requests
- HTTP abstraction → OAuth token engine: provides request
- OAuth token engine → JOSE and JWT: uses JWT (evidence: `src/oauth2.c`)
- OAuth token engine → HTTP abstraction: uses HTTP (evidence: `src/oauth2.c`)
- OAuth token engine → DPoP validation: validates proof
- OAuth token engine → Protocol operations: supports protocol
- OIDC flow → OAuth token engine: uses OAuth (evidence: `src/openidc/openidc.c`)
- OIDC flow → JOSE and JWT: uses JOSE (evidence: `src/openidc/openidc.c`)
- OIDC flow → Session management: uses sessions (evidence: `src/openidc/openidc.c`)
- OIDC flow → Provider resolver: resolves provider
- OIDC client → Provider resolver: uses resolver
- Provider and state → OIDC flow: supports state
- Session management → Cache framework: stores records (evidence: `src/session.c`)
- Cache framework → Cache backends: dispatches backend
- Provider resolver → Cache framework: uses cache (evidence: `src/openidc/resolver.c`)
- Configuration → Cache framework: configures cache (evidence: `src/cfg/session_cfg.c`)
- Configuration → Interprocess support: uses IPC (evidence: `src/cfg/session_cfg.c`)
- HTTP abstraction → Utilities: uses helpers (evidence: `src/http.c`)
- JOSE and JWT → HTTP abstraction: fetches keys (evidence: `src/jose.c`)
