Login with an E-IMZO digital signature
The user signs a one-time challenge with their key; your server verifies the signature and finds the user by PINFL or TIN.
Flow
- The browser asks your backend for a challenge. The backend gets it from e-imzo-server
(
GET /frontend/challenge, valid for 120 seconds). eimzo-tsloads the selected key and signs the challenge. E-IMZO asks for the password.- The browser posts the PKCS#7 to your backend. The backend calls
POST /backend/authon e-imzo-server, which checks the signature, the certificate and the challenge. - The backend finds the user by PINFL (OID
1.2.860.3.16.1.2) or TIN (1.2.860.3.16.1.1, orUID) and opens a session.
Frontend
import { createEimzo, createFetchBackend, DEV_API_KEYS, isEimzoError } from 'eimzo-ts';
export const eimzo = createEimzo({
apiKeys: { ...DEV_API_KEYS },
backend: createFetchBackend({
challengeUrl: '/api/eimzo/challenge',
loginUrl: '/api/eimzo/login',
init: { credentials: 'include' },
}),
});
const keys = (await eimzo.listKeys()).filter((k) => !k.expired);
try {
const user = await eimzo.login(keys[0]); // returns what /api/eimzo/login returned
} catch (e) {
if (!isEimzoError(e, 'CANCELLED')) alert(eimzo.t(e));
}
Create the client once per application: E-IMZO remembers the password per loaded key, and a new client would load the key again.
Backend endpoints
| Your endpoint | Calls e-imzo-server | Returns |
|---|---|---|
GET /api/eimzo/challenge | GET /frontend/challenge | {"status":1,"challenge":"..."}, not cached |
POST /api/eimzo/login, body: PKCS#7 as text/plain | POST /backend/auth with X-Real-IP and Host | your user JSON |
X-Real-IP is the user's IP from your trusted proxy; Host is your site's domain from
configuration. In Java, the built-in HTTP clients refuse to set Host: use Apache HttpClient 5 or
the JVM flags described in the
backend guide (Russian, with a Spring Boot example).
/backend/auth statuses
| status | Meaning | Action |
|---|---|---|
| 1 | OK | Find the user, rotate the session ID |
| -1 | Certificate status could not be checked (often the VPN is down) | 503, retry later; do not log in |
| -5 | Signing time outside the allowed window | Ask the user to check the computer clock |
| -10, -11, -12 | Invalid signature or certificate | 401 |
| -20 | Challenge not found or expired | Start login again |
| -24, -25 | Certificate policy or CA not allowed | 401 |
Logout
await eimzo.unloadKey(); // removes the key and its remembered password from E-IMZO