0
0
Fork 0
forked from freeipa/ahdapa
Stateless OAuth 2.0 / OpenID Connect identity provider (IdP) written in Rust, designed for FreeIPA-managed Kerberos environments. The name comes from the Adapa, a Mesopotamian mythical figure who unknowingly refused the gift of immortality.
  • Rust 77.7%
  • TypeScript 11.9%
  • Shell 8.4%
  • Python 1.1%
  • Makefile 0.5%
  • Other 0.3%
Find a file
Alexander Bokovoy 61a32d629e test: add integration test for jwt-bearer synthetic jti replay detection
Exercises the full HTTP round-trip for a jwt-bearer assertion without
a jti claim (simulating a SPIRE JWT-SVID):

  1. Generate an EC P-256 key pair and build an inline JWKS
  2. Configure federation.trusted_issuers for the assertion issuer
  3. Seed a client with the JWKS directly into the CRDT
  4. Sign an assertion without jti, submit it → expect 200
  5. Replay the same assertion → expect 400 invalid_grant

Verifies that the synthetic sha256-derived jti is correctly inserted
into the replay cache on first use and detected on second use.

Fixes: freeipa/ahdapa#60
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
2026-08-07 10:46:58 +03:00
.fmf ci(tmt): scaffold the real tmt plan, fix fmf tree root 2026-08-05 18:26:39 +03:00
.github/workflows Add testing farm CI workflow 2026-08-05 18:43:37 +03:00
contrib ci(tmt): port the federation demo (webui build + run.sh) 2026-08-05 18:31:44 +03:00
crates refactor(bench): migrate off build_http_client onto tls_client_builder 2026-08-05 15:13:18 +03:00
docs docs: fill AppState field-table gaps, strengthen jti-replay caveat 2026-08-05 15:13:14 +03:00
migrations feat(crdt): add allowed_registry_repositories field to ClientEntry 2026-08-01 12:40:25 +03:00
plugins/idm-theme fix(webui): replace MutationObserver with data-forced-theme attribute 2026-07-23 08:35:04 +03:00
src test: add integration test for jwt-bearer synthetic jti replay detection 2026-08-07 10:46:58 +03:00
webui feat(webui): edit allowed_registry_repositories on the client detail page 2026-08-01 12:40:25 +03:00
.gitignore Ignore development artifacts 2026-08-05 11:00:43 +03:00
Cargo.lock chore: drop unused rustls-pki-types dependency 2026-08-05 15:12:51 +03:00
Cargo.toml chore: drop unused rustls-pki-types dependency 2026-08-05 15:12:51 +03:00
LICENSE Add LICENSE file 2026-05-11 11:33:50 +03:00
README.md docs: document [webui.self_service] config and self-service profile feature 2026-06-18 18:20:41 +03:00

Ahdapa

Stateless OAuth 2.0 / OpenID Connect identity provider (IdP) written in Rust, designed for FreeIPA-managed Kerberos environments. The name comes from the Adapa, a Mesopotamian mythical figure who unknowingly refused the gift of immortality.

What it does

  • OAuth 2.0 (RFC 6749) — authorization code, refresh token, client credentials, device authorization, and token exchange grant types.
  • OpenID Connect Core 1.0 — ID tokens, UserInfo endpoint, pairwise subjects, OIDC Discovery.
  • SPNEGO/Kerberos SSO — zero-click authentication for domain members via GSSAPI; password form backed by FreeIPA LDAP as fallback.
  • Stateless tokens — self-contained JWTs; authorization codes and refresh tokens are AES-256-GCM encrypted. No per-token server-side storage. Explicit logout records a short-lived session revocation so the invalidated session cookie is rejected immediately.
  • Horizontal scale — signing keys and client registry replicated across nodes with a built-in CRDT gossip protocol; any node handles any request.
  • Post-quantum ready — ML-DSA-44/65/87 signing alongside classical EdDSA/ES256/RS256.
  • Self-service profile editing — authenticated users can view and modify their own IPA attributes (name, contact, SSH keys, certificates, password) through the /ui/me page. Editability is driven by IPA attributelevelrights and admin-configurable visibility rules.
  • Federation — upstream IdP delegation (§6) with client_secret_post/basic and private_key_jwt; supports OIDC Discovery and static endpoint overrides for plain OAuth2 providers (GitHub, Discord, etc.).
  • RBAC — group-based permissions on the admin API; groups sourced from a static users file or FreeIPA LDAP memberOf.
  • Identity HBAC policy — FreeIPA-compatible Handler-Based Access Control enforced at token issuance. Policies control which users (Identity Subjects) may obtain tokens from which OAuth2 clients (Identity Handlers) for which scopes (Scoped Access). Rules are an op-based CRDT (hbac-crdt) replicated via gossip. Empty rule set = allow-all (backward compatible); client_credentials grant is exempt.
  • SPIFFE Workload API — optional SPIFFE trust domain authority and Workload API server. When [spiffe] trust_domain is configured, ahdapa issues X.509-SVIDs and JWT-SVIDs to local workloads via a Unix domain socket gRPC server, publishes the trust bundle at /.well-known/spiffe-bundle, and bridges SPIFFE identity to OAuth2 tokens.
  • ACME Token Authority (RFC 9447) — when [gssapi] is configured, ahdapa issues authority tokens for ACME tkauth-01 challenges at POST /at/account/{id}/token. Authentication is via Kerberos SPNEGO; the resulting authority token JWT carries EnhancedJWTClaimConstraints (RFC 9118) with mustInclude: ["sub"] and permittedValues binding sub to the Kerberos principal, iss to the issuer URL, and (for host/service principals) dns to IPA-managed FQDNs — a Kerberos-identity binding, not the telephony tnauthlist profile.

Standards

RFC / Spec Description
RFC 6749 OAuth 2.0 Authorization Framework
RFC 6750 Bearer Token Usage
RFC 7009 Token Revocation
RFC 7519 JSON Web Token (JWT)
RFC 7521 / 7523 JWT Bearer Assertion + Client Authentication
RFC 7636 PKCE (S256)
RFC 7662 Token Introspection
RFC 8414 Authorization Server Metadata
RFC 8628 Device Authorization Grant
RFC 8693 Token Exchange
RFC 8707 Resource Indicators
RFC 9068 JWT Profile for Access Tokens
RFC 9126 Pushed Authorization Requests (PAR)
RFC 9207 Authorization Server Issuer Identification
RFC 8705 Mutual-TLS Client Authentication
RFC 9449 DPoP
RFC 9700 OAuth 2.0 Security Best Current Practice
RFC 8226 / RFC 9118 JWTClaimConstraints / EnhancedJWTClaimConstraints — used as the Kerberos-identity constraint format in authority tokens
RFC 9447 ACME Token Authority (tkauth-01) — Kerberos-authenticated issuance only
OIDC Core 1.0 OpenID Connect Core
OIDC Discovery 1.0 OpenID Connect Discovery
OIDC Federation 1.0 Entity Statement (self-signed); bilateral trust

Prerequisites

  • Rust 1.80+ (rustup)
  • OpenSSL 3.x development headers
  • MIT Kerberos development libraries
  • OpenLDAP client development libraries
  • Node.js 20+ and npm (WebUI only)

Fedora / RHEL:

sudo dnf install openssl-devel krb5-devel openldap-devel

For --features pam: sudo dnf install pam-devel

Debian / Ubuntu:

sudo apt install libssl-dev libkrb5-dev libldap-dev

For --features pam: sudo apt install libpam0g-dev

Building

cargo build --release          # server binary → target/release/ahdapa

cd webui && npm install && npm run build   # WebUI → webui/dist/

Quick start

# /etc/ahdapa/config.toml
[server]
issuer = "https://idp.example.com"
realm  = "EXAMPLE.COM"

[db]
url = "sqlite:///var/lib/ahdapa/ahdapa.db"

[gssapi]
service = "HTTP"
keytab  = "/etc/ahdapa/ahdapa.keytab"

[ipa]
uri = "ldaps://ipa.example.com"

[webui]
static_dir = "/usr/share/ahdapa/webui"

# Without [rbac], the admin API is inaccessible.
[[rbac.role]]
name        = "admin"
permissions = ["*"]

[[rbac.group_role]]
group = "admins"
role  = "admin"
AHDAPA_CONFIG=/etc/ahdapa/config.toml ./target/release/ahdapa

See docs/src/quickstart/ for a full walkthrough including database initialization and systemd unit setup.

Database backends

Select a backend at compile time via Cargo features (default: SQLite):

Backend Feature flag Connection URL prefix
SQLite backend-sqlite (default) sqlite:///path/to/file.db
PostgreSQL backend-postgres postgres://user:pass@host/db
MariaDB / MySQL backend-mariadb mariadb://user:pass@host/db
cargo build --release --no-default-features --features backend-postgres

Optional features

Feature Default Description
backend-sqlite yes SQLite database backend.
backend-postgres no PostgreSQL database backend.
backend-mariadb no MariaDB / MySQL database backend.
varlink no Enable user/group attribute lookup via the systemd io.systemd.UserDatabase varlink interface ([varlink] config section). Requires systemd 246+. Password authentication is not performed through varlink.
pam no Enable PAM password authentication backend ([pam] config section). Inserts a PAM step between static-user lookup and LDAP simple bind. Supports expired-password change via /login/change-password. Requires pam-devel at build time.

To enable varlink support alongside the default SQLite backend:

cargo build --release --features varlink

Repository layout

src/                  Server binary (Rust)
  auth/               Authentication: GSSAPI, LDAP, AEAD, cookies, RBAC, federation
  routes/             Axum route handlers: OAuth2, admin API, federation, discovery, SPIFFE bundle
  crdt/               CRDT types: LWW map, OR-map, grow-set, refresh families, SPIFFE entries
  db/                 sqlx pool setup and schema row types
  workload.rs         SPIFFE Workload API gRPC server (tonic, Unix domain socket)
crates/
  ahdapa-gssapi/     GSSAPI/SPNEGO acceptor (Kerberos)
  ahdapa-jose/       JOSE: JWK, JWS, JWT signing and verification (incl. ML-DSA)
  ahdapa-ldap/       Async LDAP client for FreeIPA user and group lookup
  ahdapa-varlink/    Varlink userdb client (systemd io.systemd.UserDatabase, optional)
  ahdapa-pam/        PAM authentication backend (inline libpam FFI, optional)
  ahdapa-spiffe/     SPIFFE CA, SVID issuance, trust bundle, Workload API stubs (tonic/prost)
  hbac-crdt/          Identity HBAC policy engine: op-based CRDT, FreeIPA-compatible rule semantics, OAuth2 axes
webui/                React 19 + TypeScript + PatternFly 6 admin panel and login UI
migrations/           SQL migration scripts (sqlite/, postgres/, mariadb/)
contrib/
  demo/               Local demo configurations and run scripts
    cluster/          Three-node gossip cluster demo (see contrib/demo/cluster/README.md)
    spiffe/           SPIFFE Workload API demo (see contrib/demo/spiffe/README.md)
  ci/                 local-ci.sh — runs build, fmt, clippy, tests, and docs
  packages/           RPM packaging: ahdapa.spec.in, rust2rpm.toml, Makefile (make srpm / make copr-build)
  systemd/            systemd unit, sysusers.d, and tmpfiles.d templates for the RPM
docs/                 mdBook user and developer documentation

CI

contrib/ci/local-ci.sh all        # build · fmt · clippy · test · docs
contrib/ci/local-ci.sh build test # specific jobs only

The CI script requires cargo, rustfmt, and clippy. mdbook is optional (docs build).

Documentation

Full configuration reference, architecture notes, and the developer guide are in docs/. Build the book with mdbook build docs/ or browse docs/src/ as plain Markdown.

License

GPL-3.0-or-later — see LICENSE.