My place in the WordPress community
- I have had a wordpress.org account since 2006.
- I contributed to WordPress core for versions 7.0 and 7.1.
- I maintain 30 plugins on wordpress.org.
- I organise and speak at WordCamps.
- I have attended every WordCamp Europe from 2017 to 2026.
- Local WordPress meetup: WordPress Firenze Community
Login with the electronic identity card suits a service that has to know who is on the other side: a booking portal, a tax-adjacent application, a member area. In Italy the card is the CIE, and the scheme for services is “Entra con CIE”. I build the Next.js side of such a login from Gdynia, remotely and in writing, and I work from the official CIE documents. Legal and organisational questions about federation are for you and your adviser.

The covered market of San Lorenzo in Florence. Photo by Sailko, CC BY 3.0, via Wikimedia Commons.
What is Entra con CIE?
The CIE technical manual for public and private service providers describes it as an identification scheme built on a federated identity model. One identity provider, the Ministero dell’Interno, verifies the user, and online services request that verification after they have federated with it. The Ministry issues the card and also manages its use as a digital identity tool.
The authentication runs on the CieID Server. According to the manual it is hosted at the Ministry and built and maintained by the Poligrafico e Zecca dello Stato (PZS). It accepts authentication requests from federated services, runs the challenge at the required security level and sends qualified attributes only with the user’s explicit consent. It returns a signed assertion as proof that the user was recognised.
The user can work in a desktop browser, on a smartphone with the CieID app, or with both together. The manual names three levels of assurance:
| Level | What the user does |
|---|---|
| 1 | username and password, enabled by the card holder |
| 2 | two-factor authentication: SMS one-time code or a push notification to the CieID app |
| 3 | the chip of the card is read and the certificate is released with the PIN, with an RF reader on desktop or NFC on a smartphone |
Which level a service asks for is a product decision with legal weight. A login to a newsletter preference page and a login to a medical record do not need the same one.
SAML or OpenID Connect for a Next.js app?
The CieID Server works as a SAML 2.0 server and as an OpenID Provider, so both protocols are on offer. The manual says its protocol sections are 3 for SAML and 4 for OIDC. In the federation process the technical contact states which protocol the service uses.
For a Next.js App Router project I lean towards OpenID Connect. The flow is a sequence of redirects and server-to-server calls, which Route Handlers express directly, and the tokens are JWTs that a server-side library can verify. That is a preference about fit, not a rule from the documents. If your organisation already runs a SAML stack behind the Next.js front end, federating through that stack is a legitimate choice.
How does a service get federated with the CIE?
The operational manual, which is still published as a draft, describes the process in four steps:
- submitting the federation request
- authorisation of the federation
- entering the technical federation data
- federation to the Entra con CIE scheme
It names two roles. The administrative contact fills in the identifying data of the public or private entity, the entity details and statistical data, and sends the membership form. The administrative contact then enables the technical contact. The technical contact picks the federation protocol and the federation environment, enters the technical details, acquires the technical component and completes its federation. The manual shows a separate federation environment choice, and its section on conditions has general obligations plus further obligations for aggregators and for private entities.
The overview manual adds that PZS provides technical support throughout the integration. The draft index I read does not say how long the process takes or how pre-production differs from production in detail, so I do not plan a delivery date around it. In a project I treat federation as a dependency with its own calendar and build against the test environment first.
What does the OIDC flow look like in the App Router?
The SPID/CIE OpenID Connect rules describe the flow of “Entra con SPID” and “Entra con CIE” as the OpenID Connect Authorization Code Flow with PKCE under RFC 7636. In sequence:
- The user presses “Entra con CIE” on your site.
- Your server builds an authorization request with the parameters PKCE needs and sends the user to the Authorization Endpoint of the provider.
- The user authenticates and consents. The provider redirects to your redirect URI with an authorization code.
- Your server sends the code to the Token Endpoint and receives an ID token, an access token and, where provided, a refresh token.
- Your server validates both tokens.
- Your server calls the UserInfo Endpoint with the access token in the HTTP Authorization header and receives the attributes the user released.
Steps 2 and 4 to 6 belong on the server. In Next.js that means two Route Handlers: one that starts the login and stores state, nonce and the PKCE verifier in a short-lived server-set cookie, and one for the redirect URI. The Next.js documentation describes Route Handlers as custom request handlers built on the Web Request and Response APIs, and it says they need the same security checks as public endpoints.
What does the token endpoint expect from the service?
The rules for the token endpoint are specific, and they decide most of the code in the callback handler.
- The relying party authenticates with
private_key_jwt. - The
client_idmust be an HTTPS URL that identifies the relying party uniquely. - The request carries
client_assertion_typeset tourn:ietf:params:oauth:client-assertion-type:jwt-bearer, thegrant_type, and for the authorization code grant thecodeand thecode_verifier. - The client assertion is a JWT signed with the private key of the relying party. Its
issequals theclient_id, itsaudis the Token Endpoint URL of the provider, it hasiatandexp, and a uniquejti, for example a UUID.
A sketch of the exchange. The environment variables, the algorithm and the lifetime of the assertion come from the technical rules and the federation data, not from this example:
// app/api/cie/callback/route.ts
import "server-only";
import { SignJWT, importPKCS8 } from "jose";
import { randomUUID } from "node:crypto";
const clientId = process.env.CIE_CLIENT_ID!; // HTTPS URL of the relying party
const tokenEndpoint = process.env.CIE_TOKEN_ENDPOINT!;
const alg = process.env.CIE_SIGNING_ALG!; // as named in the technical rules
async function clientAssertion() {
const key = await importPKCS8(process.env.CIE_PRIVATE_KEY!, alg);
return new SignJWT({})
.setProtectedHeader({ alg })
.setIssuer(clientId)
.setSubject(clientId)
.setAudience(tokenEndpoint)
.setIssuedAt()
.setExpirationTime("1m") // placeholder, take the value from the rules
.setJti(randomUUID())
.sign(key);
}
export async function GET(request: Request) {
const url = new URL(request.url);
const code = url.searchParams.get("code");
// compare state with the value stored at login start, load code_verifier
// from the same server-set cookie, then:
const body = new URLSearchParams({
grant_type: "authorization_code",
code: code ?? "",
code_verifier: "...",
client_id: clientId,
client_assertion_type:
"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
client_assertion: await clientAssertion(),
});
const res = await fetch(tokenEndpoint, { method: "POST", body });
// validate id_token and access_token before creating a session
return Response.json({ ok: res.ok });
}The private key sits in an environment variable. The Next.js documentation says variables without the NEXT_PUBLIC_ prefix are available only in the Node.js environment and are not exposed to the browser, and import "server-only" keeps the module out of client bundles.
What must the service validate in the ID token?
The OIDC rules say relying parties must validate the ID token. The claims they list:
issmatches the provider that was calledaudequals yourclient_idacris equal to or higher than the level you requestedat_hashis checked against the access token that came with itiatandexpare valid, andjtiis rejected if the token was already processednoncematches the one in the authentication request, and is at least 32 alphanumeric characterssubis of pairwise type
The last point matters for the data model. A pairwise subject means the identifier is specific to your service, so it cannot be matched against another service’s records.
The rules also cover refresh tokens. A refresh token must not be valid longer than 30 days. For CIE it requires scope=offline_access and prompt=consent, it cannot be used to obtain an ID token, and each use returns a new refresh token and invalidates the previous ones. Unless the product needs long-lived access, I would not ask for one.
Which endpoints must a federated entity expose?
The page on federation endpoints says every entity must expose /.well-known/openid-federation, which serves its Entity Configuration, and a resolve endpoint. Entities acting as trust anchors or intermediaries expose more. The page does not describe what the Entity Configuration of a relying party holds and points to the OpenID Connect Federation specification and a separate page on relying party metadata. Whether and how the relying party endpoints apply to your integration is to be confirmed in the federation process with PZS. A Route Handler can serve such a path, and I test it on the Next.js version in use before the federation file is submitted.
How should the session after login work?
The login ends when your own session begins. The Next.js authentication guide separates authentication, session management and authorization, and describes two session types: stateless, with the data in a cookie, and database sessions, with only an encrypted session ID in the browser. It calls the database variant more secure but heavier on the server.
Practical consequences from that guide:
- set the cookie on the server, with
HttpOnly,Secure, aSameSitevalue, an expiry and a path - keep the payload minimal: an identifier and a role, not personal data such as an email address or a tax code
- verify the session in a data access layer close to the data, not only in a layout, because layouts do not re-render on every navigation
- treat Server Actions and Route Handlers like public endpoints and check authorisation in each
What your service stores of the identity attributes is a data protection decision. Keep only what the service needs.
How does a CIE login project run?
- You send the service description, the assurance level you need, whether you are a public or private entity and who will be the administrative and technical contacts.
- I write down the protocol choice, the callback design, the session model and the points that depend on federation, as a short plan you can send to your adviser.
- I build against the test environment on a staging deployment, with failure screens for a refused consent, an expired code and an unreachable provider.
- After your written approval of staging, the login goes live.
I need the federation data from the Ministry process, the signing key handling policy and the list of attributes your application really uses. The wider Next.js work I take on is listed on the Next.js developer page.
A CIE login for your Florence service
If a Florence service of yours should accept the electronic identity card, send the assurance level you need and who the administrative and technical contacts would be through the contact form. The first written estimate for the callback handlers and the session layer is free. Whether your service may federate, and as which kind of entity, is for the Ministry process and your adviser to settle.
Selected projects
Examples of my work.
Photo Studio Balbriggan - Photography Website & Booking Platform
Photo Studio Balbriggan is a modern photography centre in Ireland offering professional photography services, advanced photo editing, high-quality printing, studio rental, and photography workshops.
Portbrzezno.pl - Adventure Rope Park Website
The Port Brzeźno Rope Park is a place where both children and adults can experience an unforgettable adventure at height with a good dose of adrenaline in Gdańsk, Poland.
QUALITY WATCH - Mystery Shopping & Customer Experience Solutions
The Quality Watch project was created with the aim of presenting the services of a company specializing in improving customer service standards, quality management, customer experience, customer journeys and customer intelligence.
WordPress support & development in Florence
Need this service: Next.js developer in Florence?
Describe your project by e-mail. I reply within 24 hours.
Describe your projectExplore other WordPress services and knowledge base
Migration to Astro, Next.js, and headless WordPress.
WooCommerce sync with ERP and wholesale systems.
Business process automation around WordPress and company systems.
Library of concrete automation use cases.
Headless WordPress, Sanity, Strapi, and Contentful with Astro or Next.js.
Astro, MDX, edge delivery, and Core Web Vitals measured on real traffic.
Custom WordPress engineering and architecture.
Scalable headless, ERP, and AI architecture for enterprise.
Related categories
Supporting articles

Six to sixteen weeks for typical engagements, with a four-phase shape: discovery, scoping, build and cutover, tuning. The variables are catalogue size, integration count, URL preservation, and editorial team readiness, not framework choice.

A definitive 4-year Total Cost of Ownership (TCO) analysis, real-world Core Web Vitals benchmarks, Astro 7 GraphQL APQ architecture, and a 10-point executive decision matrix for choosing between decoupled and traditional WordPress.

The Shopify Plus vs WooCommerce headless decision in 2026 is no longer a binary "platform vs custom" trade-off. Both can run headless, both integrate AI, both ship at the edge. The real axes are control, total cost over five years, and exit strategy. This article walks the matrix with confirmed platform facts.