OpsisID
Sign in with an EU eID, and verify a signed-in user's identity, through OpsisID.
OpsisID verifies people for EU platforms: with their country's eID, or with an ID document and a selfie a reviewer checks. It is an OpenID Connect provider for its workspaces, and this package connects it to Entro Auth in two ways:
- Sign in with an eID (
opsisidSignIn): the person proves who they are with their eID and is signed in. Your app learns a subject that is the same at every sign-in and unrelated to what any other OpsisID workspace sees, and no name, birth date or ID number unless OpsisID granted your workspace a disclosure. - Verify a signed-in user (
opsisid): for an account that exists, such as before a payout or a first listing. The user may use any method the purpose allows, including an ID document; when a reviewer still has to decide, the result says so and the decision arrives by webhook.
Both use the authorization code flow with PKCE, and every request is pushed to OpsisID (PAR) with your API key, so the browser never carries what is asked.
Installation
Install the package
npm install @entro314labs/entro-auth-opsisidRegister your redirect URIs in OpsisID
In the OpsisID dashboard, open Settings → Sign in with OpsisID and add:
https://your-app.com/api/auth/callback/opsisidfor sign-in;https://your-app.com/api/auth/opsisid/callbackfor verification.
The client ID is shown there; the client secret is your API key. For verification results decided later, set the workspace's webhook URL to https://your-app.com/api/auth/opsisid/webhook.
Add the plugins to your auth config
Use either or both.
import { entroAuth } from "@entro314labs/entro-auth";
import { genericOAuth } from "@entro314labs/entro-auth/plugins/generic-oauth";
import { opsisid, opsisidSignIn } from "@entro314labs/entro-auth-opsisid";
const credentials = {
issuer: "https://opsisid.com",
clientId: process.env.OPSISID_CLIENT_ID!,
clientSecret: process.env.OPSISID_API_KEY!,
};
export const auth = entroAuth({
plugins: [
genericOAuth({ config: [opsisidSignIn(credentials)] }),
opsisid({ ...credentials, webhookSecret: process.env.OPSISID_WEBHOOK_SECRET }),
],
});Migrate the database
opsisid() adds the opsisidVerification table.
npx @entro314labs/entro-auth-cli@latest migrateAdd the client plugin
import { createAuthClient } from "@entro314labs/entro-auth/client";
import { opsisidClient } from "@entro314labs/entro-auth-opsisid/client";
export const authClient = createAuthClient({
plugins: [opsisidClient()],
});Sign in with an eID
await authClient.signIn.social({
provider: "opsisid",
callbackURL: "/home",
additionalParams: { country: "PL" }, // the country whose eIDs are offered
});Pass country to opsisidSignIn instead to fix it for every sign-in. A sign-in is refused when the eID result needs a reviewer, when the person cancels, and when the eID gives no national identifier to derive the subject from.
OpsisID gives no email address, so the user is created with an unverified placeholder address (createPlaceholderEmail, namespace opsisid). Ask for a real one after sign-in if your app needs it.
Only an approved OpsisID sign-in signs anyone in. The ID token's signed opsisid.purpose must be authentication: a request whose parameters were changed in the browser to verify some known user is refused.
Verify a signed-in user
await authClient.opsisid.verify({
purpose: "rental_lister",
country: "GR",
level: 1,
subject: { given_name: "Eleni", family_name: "Papadopoulou" },
callbackURL: "/account/verification",
});The user is sent to OpsisID and comes back to callbackURL; on failure to errorCallbackURL (or callbackURL) with an error query parameter. The user's ID is sent as OpsisID's external_ref by the server, so a user cannot verify as someone else, and repeated verifications of the same user build on each other in OpsisID.
purpose, level and subject are those of OpsisID's session API: see its integration guide for what each purpose checks.
Results
const { data } = await authClient.opsisid.verifications();
// [{ sessionId, purpose, country, status: "review", outcome: null, level: null, ... }]A row is written when the user returns, or, if they closed the page before returning, when the decision's webhook arrives (the plugin then reads the session from OpsisID with your API key). status is decided with an outcome when OpsisID decided at once, and review when a reviewer still has to look; the webhook then sets the decision. Graded purposes also store the level reached, its levelName and validUntil.
The webhook endpoint checks the Opsisid-Signature header against webhookSecret and refuses deliveries more than five minutes old. Without webhookSecret it refuses every delivery.
Schema
Table: opsisidVerification
Options
opsisidSignIn
| Option | Description |
|---|---|
issuer | OpsisID's issuer URL, such as https://opsisid.com. |
clientId | Your OpsisID workspace ID. |
clientSecret | Your OpsisID API key. |
country | The country whose eIDs are offered. Leave it out to pass additionalParams.country per sign-in. |
redirectURI | Defaults to {baseURL}/callback/opsisid. |
disableSignUp, disableImplicitSignUp | As for any Generic OAuth provider. |
opsisid
| Option | Description |
|---|---|
issuer, clientId, clientSecret | As above. |
webhookSecret | The workspace's webhook signing secret (whsec_…). |
redirectURI | Defaults to {baseURL}/opsisid/callback. |
schema | Custom table and field names. |