Skip to content
Last updated

Authentication flow

This page describes the end-to-end authentication flow using ESP. Each step corresponds to a specific API call. For detailed parameter reference, see the individual endpoint pages.

Overview

Identity Provider(SPID / CIE / EIDAS)ESPYour ApplicationUserIdentity Provider(SPID / CIE / EIDAS)ESPYour ApplicationUserGET getKeyauthnKeyGET login (authnKey)Redirect to IdPAuthenticateAssertionRedirect to final URL (id + key)GET getUser (id + key)JWT with user attributes

Authentication

All server-side API calls to ESP require an API key provided by Namirial during the Setup Test Environment phase.

Include it in every request as a header:

Esp-Api-Key: YOUR_API_KEY

Login and Logout are browser-based redirects — no API key is required for those calls.

Step 1 — Get a session key

Before redirecting the user to the identity provider, your application must obtain a session key (authnKey) from ESP.

Call the Get Key endpoint, specifying the authentication level and the attribute set required:

  • level: 1, 2, or 3
  • attributes: Base or Full

The response is a string (authnKey) that identifies the authentication session. It must be passed to the login endpoint in the next step.

Step 2 — Redirect the user to the identity provider

Use the authnKey obtained in Step 1 to build the login URL and open it in the user's browser.

ESP redirects the user to the selected identity provider (SPID, CIE, or EIDAS) login screen. The user authenticates directly with the identity provider — your application is not involved in this step.

After a successful authentication, the identity provider sends the SAML assertion to ESP, which validates it and redirects the user back to the final URL configured during the assessment phase.

Step 3 — Retrieve the user JWT

After authentication, ESP redirects the user to your final URL.

Call the Get user token endpoint, passing the sessionid and sessionkey parameters, to retrieve a JWT containing the user's attributes.

Step 4 — Logout

Note

Logout is not required for Level 2 authentications.

To terminate the SPID session, call the Logout endpoint and open the resulting URL in the user's browser. The user is presented with the identity provider logout screen and then redirected to the final URL configured for logout.