SPID Integration
SPID (Sistema Pubblico di Identità Digitale) is Italy's national digital identity system. Clavex acts as a SAML 2.0 Service Provider and federates with all accredited SPID identity providers — your users authenticate at their chosen IdP, and Clavex issues OIDC tokens to your application, transparently bridging SAML and OpenID Connect.
How It Works
Step 1 — Prerequisites
Before enabling SPID you need:
- A valid X.509 certificate + private key for your Service Provider (SP). Use
opensslto generate a 2048-bit RSA key pair signed by a trusted CA, or self-signed for testing. - A public HTTPS domain for your Clavex instance — SPID IdPs will not accept
localhostfor production. - An AgID accreditation for production. For testing, use the SPID validator at
https://validator.spid.gov.it.
Step 2 — Enable SPID in config
Add the SPID section to your config.yaml. The SP entity ID and ACS URL must
be publicly reachable — they are embedded in your SAML metadata and registered with AgID.
Step 3 — Publish SP Metadata
Clavex auto-generates SAML SP metadata at startup. Register this URL with the AgID federation portal. For testing, download and upload it to the SPID validator.
# Verify metadata is valid $ curl -s https://id.acme.eu/saml/spid/metadata | xmllint --noout - ✓ metadata valid
# ACS (Assertion Consumer Service) endpoint https://id.acme.eu/saml/spid/acs
# SLO (Single Logout) endpoint https://id.acme.eu/saml/spid/slo
Step 4 — Enable Per-Organization
SPID is enabled globally in config, but each organization must activate it individually. This allows multi-tenant deployments where only some orgs need SPID.
# SPID login button now appears on the org's login page: https://id.acme.eu/acme/login → "Accedi con SPID"
Step 5 — OIDC Claims Mapping
SPID attributes are mapped to standard OIDC claims automatically. The
fiscalNumber attribute becomes available as a custom claim.
| SPID Attribute | OIDC Claim | Notes |
|---|---|---|
| name | given_name | As per SPID attribute set |
| familyName | family_name | |
| Attribute set 2+ | ||
| fiscalNumber | fiscal_number | Italian codice fiscale |
| dateOfBirth | birthdate | ISO 8601 (YYYY-MM-DD) |
| placeOfBirth | birthplace | Municipality code (Belfiore) |
| spidCode | spid_code | Unique SPID identifier |
Step 6 — Test with SPID Demo
CIE — Carta d'Identità Elettronica
CIE uses a separate SAML SP configuration but follows the same flow. Enable it in config:
CIE's SAML IdP metadata is fetched from
https://collaudo.idserver.servizicie.interno.gov.it/idp/shibboleth (pre-production)
and https://idserver.servizicie.interno.gov.it/idp/shibboleth (production).
Clavex refreshes it automatically on a 24-hour schedule.