22.11. KyCH-native Helper RESTful API#
KyCH does no cryptography itself: for every identification it asks a
helper – a verifier for EU Digital Identity Wallets, an eID server for
the German identity card – to talk to the person’s wallet or card, to check
what is presented, and to report the outcome. The upstream helpers each have
an API of their own, which KyCH’s adapters translate. KyCH’s own helpers
implement this one, the KyCH-native helper API, so that one adapter
(TYPE = kych-native in kych.conf(5)) serves all of them:
kych-oid4vp, the OpenID for Verifiable Presentations 1.0 verifier for the EU PID as SD-JWT VC and as ISO mdoc (requests of kindoid4vp);kych-eumw-bridge, the German identity card’s online function through the Governikus eIDAS Middleware (kindeid-server, kych-eumw-bridge(1)), and other member states’ notified eIDs through the EU eIDAS-Node Connector (kindeidas-saml, kych-eumw-bridge(1), eidas-node-connector(1));kych-eid, KyCH’s own eID server for the German identity card (kindeid-server, kych-eid(1)).
Anything else that implements this API can be used the same way.
A helper has two interfaces that belong on different sides of a firewall:
the management interface described here, which only KyCH may reach. It is served on a Unix domain socket or on a loopback address and requires a bearer secret: unlike the upstream helpers, a KyCH-native helper authenticates its caller;
the public interface the wallet (or, for an eID server, the person’s browser and eID client) talks to. Its paths are the helper’s own business; the reverse proxy publishes them and nothing else. For
kych-oid4vpthey are described in kych-oid4vp(1).
The flow of one session:
KyCH creates a session with
POST /sessions, saying what to ask for, whom to trust, until when, and where to notify it. The answer is the session id and what to show the person: a wallet URL for the QR code and a deep link, or a browser URL to redirect to.The wallet (or browser) talks to the helper’s public interface. The helper checks everything – signatures, disclosures, holder binding, the issuer’s trust, the revocation status – and records the outcome.
The helper posts
{"session_id": ...}to thenotify_url. The notification carries no personal data and no outcome; KyCH then asksGET /sessions/$SESSION_IDitself. Without anotify_url, or when a notification is lost, KyCH polls, optionally long-polling with?wait=.The outcome is the disclosed claims plus an
evidenceobject in the very shape KyCH’s/infohands out (KyCHEvidence, see KyCH OAuth2 Gateway RESTful API), so that KyCH passes it on without translating it.The helper deletes the claims, the evidence and everything that could decrypt or replay the presentation a configurable time after it first delivered a final outcome, and when the session expires.
22.11.1. Authentication#
Every request to the management interface except GET /config carries
Authorization: Bearer $SECRET
where $SECRET is a secret configured on both sides (API_SECRET in the
helper’s [helper-*] section of kych.conf(5), and in the helper’s own
configuration). A missing or wrong secret is answered with 401
Unauthorized (unauthorized). The secret is compared in constant time.
The management interface must not be reachable over a network: a helper listens on a Unix domain socket, whose permissions decide who may connect, or on a loopback address, and refuses to start otherwise.
22.11.2. Versioning#
The protocol version follows GNU libtool’s current:revision:age, as the
other GNU Taler APIs do: a client that implements version current C
can talk to a helper whose current - age <= C <= current. This document
describes version 0:0:0.
A helper ignores members of a request it does not know, and a client ignores
members of an answer it does not know, so that both can grow without a new
current.
22.11.3. Errors#
Every error answer of the management interface has this body:
interface KyCHHelperErrorResponse {
// Machine-readable error code.
error: string;
// Human-readable explanation, for the operator's logs.
hint?: string;
}
The codes are unauthorized (401), invalid_request (400: a body that
cannot be read, a member of the wrong type, an unsupported kind, a query
the helper cannot serve), unknown_session (404), request_too_large
(413), internal_error (500) and unavailable (503: the helper cannot
take new sessions now, e.g. kych-eid with an expired authorisation
certificate or a stale block list; the hint says why).
22.11.4. Configuration#
- GET /config#
What the helper is and what it can do. Needs no authentication, so that a client can check compatibility and use it as a health check.
Response:
interface KyCHHelperConfig { // Always "kych-native-helper". name: "kych-native-helper"; // Protocol version, current:revision:age. version: string; // The program and its version, e.g. "kych-oid4vp" and "0.0.1". // These become evidence.helper.name and evidence.helper.version. implementation: string; implementation_version: string; // The kinds of request this helper serves: "oid4vp", "eid-server", // "eidas-saml". kinds: string[]; // For "oid4vp": the credential formats it verifies ("dc+sd-jwt", // "mso_mdoc"), whether it takes DCQL credential_sets and claim_sets, // the response mode and the client identifier of its requests. formats?: string[]; credential_sets?: boolean; claim_sets?: boolean; response_mode?: "direct_post" | "direct_post.jwt"; client_id?: string; // How the helper takes trust decisions: "kych-trust". trust?: string; // For "eid-server": the attributes (TR-03130 names) the helper can // deliver, and the eID server behind it ("governikus-eumw", // "kych-eid"). attributes?: string[]; eid_server?: string; // For "eidas-saml" (kych-eumw-bridge): the citizen countries offered, // the lowest level of assurance asked for, the attribute URIs it // can ask for, and "connector": "eidas-node". eidas?: { countries: string[]; level_of_assurance: string; attributes: string[]; connector: string }; // kych-eid: its authorisation certificate's holder reference and // last day, and, while it cannot take sessions, why not. terminal_certificate?: { holder: string; valid_until: string }; unavailable?: string; }
22.11.5. Sessions#
- POST /sessions#
Starts one identification.
Request:
- Request Headers:
Authorization –
Bearer $SECRET.
The body is a KyCHHelperSessionRequest, at most 1 MiB.
interface KyCHHelperSessionRequest { // The kind of the KyCH vocabulary the session is for: "oid4vp" for // a wallet, "eid-server" for an eID card, "eidas-saml" for another // member state's eID through the eIDAS network. It decides what // "request" is. kind: "oid4vp" | "eid-server" | "eidas-saml"; // The name of the session's vocabulary in KyCH ("eupid"), for the // helper's logs. When the request offers the wallet several // vocabularies, the first. vocabulary: string; // What to ask for: a DCQL query (OpenID4VP 1.0, section 6) for // "oid4vp", a KyCHHelperEidRequest for "eid-server" and // "eidas-saml". // // For "oid4vp", the ids of the credential queries are what the // outcome's claims are keyed by; KyCH names them after its // vocabularies. Several credential queries in one credential set // offer the wallet a choice (an EU PID as SD-JWT VC or as mdoc), and // claim_sets mark claims optional. request: object; // Whom to trust, per credential query id: required for "oid4vp", // with an entry for every credential query. A presentation whose // issuer is not trusted for its entry fails. trust?: { [credential_query_id: string]: KyCHHelperTrust }; // A registration certificate (ETSI TS 119 475, a compact JWS) the // helper hands the wallet with the request, where one is required // ("verifier_info" of the OpenID4VP request object). registration_certificate?: string; // Where the wallet (same device) or the browser (eID server) is sent // when the person is done: KyCH's /return/$VERIFICATION_ID. An https // URL, except on loopback. return_url?: string; // Where to post the notification (below): an http or https URL, or // "http+unix://" followed by the percent-encoded path of a Unix // domain socket and the request path, e.g. // "http+unix://%2Frun%2Fkych%2Fkych.sock/notification". Without // it, the caller polls. notify_url?: string; // Until when the person may answer. A helper may shorten it (its // own maximum session lifetime); the answer says what it is. expires: Timestamp; // The caller's own id for the identification (KyCH's verification // id). Echoed as evidence.verification_id; the session id if absent. reference?: string; }
interface KyCHHelperTrust { // What the issuer must be listed as: the CLASS of a list kych-trust // serves, e.g. "PID" (kych-trust.conf(5)). The issuer's chain is // checked in that class's issuance context ("PID"), a status list's // signer in its revocation context ("PIDStatus"). class: string; // For CLASS = EAA: the use case of the list. use_case?: string; // The level of assurance a presentation reaches when its issuer is // trusted and its holder binding verified (for the EU's list of PID // providers: "high"). Absent: no level is stated, as for a simulated // list. level_of_assurance?: string; }
// Implemented by kych-eumw-bridge and kych-eid. A helper refuses // (invalid_request) a required attribute it cannot deliver -- kych-eid // also one its authorisation certificate does not allow -- and leaves // out an optional one. "return_url" is required. interface KyCHHelperEidRequest { // The attributes to read: for "eid-server" under the eID server // interface's names (BSI TR-03130, e.g. "FamilyNames"), for // "eidas-saml" the eIDAS SAML Attribute Profile's URIs (e.g. // "http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName"). // An optional one may be missing without failing the session. attributes: { name: string; required: boolean }[]; }
Response:
- 200 OK:
The session exists; a KyCHHelperSessionCreated.
- 400 Bad Request:
invalid_request: an unknownkind, a DCQL query that is not valid or asks for a format the helper does not verify, a credential query without atrustentry, anotify_urlorreturn_urlwith another scheme, anexpiresin the past.- 401 Unauthorized:
unauthorized.- 413 Request entity too large:
request_too_large.
interface KyCHHelperSessionCreated { // The helper's id for the session: unguessable, URL-safe. session_id: string; // When it expires: the request's, or earlier. expires: Timestamp; // For a wallet: the authorization request URI, for the QR code // (e.g. "openid4vp://?client_id=...&request_uri=..."). wallet_url?: string; // For a wallet on the same device: the link that opens it. deeplink?: string; // For an eID server: where to send the browser. browser_url?: string; }
- GET /sessions/$SESSION_ID#
The state of a session, and its outcome once there is one.
Request:
- Request Headers:
Authorization –
Bearer $SECRET.
- Query Parameters:
wait – Optional. Up to that many seconds (at most 60) to wait for a session that is still
pendingto change, before answering. The answer comes as soon as it does, or when the session expires.
Response:
- 200 OK:
A KyCHHelperSessionStatus. Answering a final status for the first time starts the purge grace period.
- 401 Unauthorized:
unauthorized.- 404 Not found:
unknown_session: never created, or deleted since (sessions are deleted some time after they ended; see the helper’s configuration).
interface KyCHHelperSessionStatus { session_id: string; // "pending" until the person has answered and the answer was // checked; then "verified" or "failed". "expired": the session's // time ran out without an answer. status: "pending" | "verified" | "failed" | "expired"; expires: Timestamp; // For "oid4vp": whether the wallet has fetched the request object. request_retrieved?: boolean; // When verified: the disclosed claims of every presented credential, // under its credential query id. For an SD-JWT VC, the claims as // the credential nests them (with the disclosed selectively // disclosable ones in place); for an mdoc, its namespaces, each an // object of data elements, CBOR converted to JSON (byte strings as // base64url, tags dropped); for "eid-server", the attributes read. claims?: { [credential_query_id: string]: object }; // When verified: how the result was obtained and checked, in the // shape of KyCH's /info (KyCHEvidence), with helper.type // "kych-native", helper.name the implementation and // verification_id the request's reference. evidence?: KyCHEvidence; // When failed or expired: why. error?: KyCHHelperFailure; // True once the claims and the evidence have been deleted. purged?: boolean; }
interface KyCHHelperFailure { // Why the session failed; see the list below. code: string; // For a presentation that failed a format check, its class: // "malformed", "unsupported", "signature", "digest", "binding", // "expired", "unsatisfied", "crypto". kind?: string; // A human-readable explanation, for the operator. It never holds // personal data. hint?: string; }
Failure codes of
kych-oid4vp. The first group is the wallet’s own answer, the second a response refused before it was read, the third a presentation that failed a check:access_deniedand the other error codes of OpenID4VP 1.0 section 8.5, as the wallet sent them (the person declined, or the wallet holds nothing that fits);invalid_encrypted_response(adirect_post.jwtresponse that does not decrypt with the session’s key),unexpected_response_mode(a cleartext response todirect_post.jwt, or the reverse),response_too_large,state_mismatch,malformed_response;invalid_signature,invalid_disclosure(a digest that does not match, or a disclosure no digest covers),holder_binding_failed(key-binding JWT ordeviceSignature: missing, wrongnonce,aud,sd_hash, too old, or over another SessionTranscript),credential_expired,query_not_satisfied,malformed_presentation,unsupported_presentation,issuer_not_trusted,status_list_not_trusted(a status list signed by someone the list does not name for revocation),credential_revoked(also suspended),status_unavailable(the status list could not be fetched or read: the check fails closed),status_unsupported(the credential’s revocation information is in a mechanism the helper cannot check, such as an ISO/IEC 18013-5 identifier list: it fails closed too),replayed_presentation;presentation_expired(statusexpired) andcancelled(DELETE).
Failure codes of an
eid-serverhelper (kych-eumw-bridge):access_denied(the person cancelled, also after a wrong PIN),card_invalid(expired, on the block list, or not authentic: the eID server’sinvalidDocument),eid_error(anything else the eID server reports; the hint carries its message),invalid_response(an answer of the eID server that does not verify),attribute_missing(a required attribute the card did not deliver),presentation_expired,cancelled.kych-eid has the same codes and says more in
kind:access_deniedwithcancelled(the person cancelled in the eID client, also after a wrong PIN) orrights_deselected;card_invalidwithexpired(document validity),revoked(block list),not_authentic(Passive or Chip Authentication failed),defect(defect list),untrusted_cvcaorunsupported;invalid_responsefor an eID client or card that broke the protocol or the secure messaging;eid_errorfor an error the eID client reports.Failure codes of kych-eumw-bridge’s
eidas-samlsessions:access_denied(the person cancelled or refused consent at the proxy service or the identity provider),loa_too_low(a level of assurance below the one asked for),invalid_response(an answer the Connector calls broken, or one without the evidence),eid_error(anything else the proxy service reports; the hint carries its status and message),attribute_missing,presentation_expired,cancelled. An error the Connector finds itself (an untrusted or expired proxy service metadata, a signature that fails) ends on the Connector’s own error page and never reaches the helper: the session then expires.For
eid-serverandeidas-saml,claimshas one entry, under the vocabulary’s name, with the attributes read, e.g.{"npa": {"FamilyNames": "MUSTERMANN", "DateOfBirth": {"DateString": "19640812", "DateValue": "1964-08-12"}, "PlaceOfResidence": {"StructuredPlace": {...}}, "RestrictedID": {"ID": "..."}}}.
- DELETE /sessions/$SESSION_ID#
Ends a session: a pending one fails with
cancelled, and the claims, the evidence and the presentation are deleted at once. For a caller that has stored the outcome and does not want to wait for the purge.Request:
- Request Headers:
Authorization –
Bearer $SECRET.
Response:
- 204 No content:
Done.
- 401 Unauthorized:
unauthorized.- 404 Not found:
unknown_session.
22.11.6. Notification#
When a session with a notify_url reaches a final status – verified,
failed or expired – the helper posts
interface KyCHHelperNotification {
session_id: string;
}
as application/json to it, and nothing else: no outcome, no personal
data. The caller looks the session up with GET /sessions/$SESSION_ID and
must not trust the notification for anything but “look now”; KyCH’s
/notification endpoint answers 200 OK to anything. A helper retries a
notification that failed a few times, and gives up after that: the caller’s
own polling covers a lost one.
KyCH listens on a Unix domain socket, which a helper’s HTTP client may not be
allowed to open. Either the reverse proxy offers KyCH’s /notification on
a loopback address (http://localhost:18444/notification, as the example
nginx sites do), or the helper is given the socket itself
(http+unix://%2Frun%2Fkych%2Fkych.sock/notification) and the permission
to connect to it.
22.11.7. Evidence#
evidence is KyCH’s KyCHEvidence (see KyCH OAuth2 Gateway RESTful API), filled by the
helper. For kych-oid4vp:
helper:typekych-native,namekych-oid4vp,version;format,credential_type(thevct, or the doctype);issuer:subjectof the signing certificate,iss(SD-JWT VC),chain(base64 DER, signer first);trust: kych-trust’s decision on the chain in the class’s issuance context –context,trusted,anchor(base64 DER),entity,service,list,list_issued,snapshot– the same record KyCH’s other adapters give;level_of_assurance: the trust entry’s, if the issuer is trusted and the holder binding verified;status:checked,list,index,result(valid),format(jwtorcwt) andsigner, kych-trust’s decision on the status list’s signer in the revocation context;{"checked": false}for a credential without a status reference;holder_binding:checked,method(kb-jwtordeviceSignature),nonce,audience; for an SD-JWT VCiatandsd_hash; for an mdoc thehandover(client_id,nonce,jwk_thumbprint,response_uri) and thesession_transcript(base64url CBOR)deviceSignaturewas checked over;request:dcql_query,client_id,nonce,response_mode,response_uri,profile(haipforx509_hash,openid4vpotherwise) and the signedrequest_objectthe wallet fetched;presentation: thevp_tokenas the wallet sent it (decrypted).
For kych-eumw-bridge: helper (kych-native, kych-eumw-bridge),
credential_type de-eid, issuer (eid_server, the middleware’s
entity_id, subject and chain of its SAML signature certificate),
trust (source eid-server, the service_provider whose
authorisation certificate was used, what the eID server checked),
level_of_assurance from the assertion, request (the attributes,
the authn_request_id, the provider_name, the destination) and
presentation {"format": "saml2-assertion", "assertion": base64}: the
decrypted assertion as the middleware signed it. The card proves itself to
the eID server only; nothing in the evidence can be checked against the
card later.
For kych-eumw-bridge’s eidas-saml sessions: helper
(kych-native, kych-eumw-bridge), format saml2,
credential_type eidas-natural-person, issuer (the citizen
country, the proxy service’s entity_id, the subject and chain
of the certificate its signatures were checked against, from its metadata),
trust (source eidas-node, the connector, what it checked),
level_of_assurance from the response (low, substantial,
high), request (the attributes, citizen_country, the
level_of_assurance asked for, light_request_id, requester_id,
destination) and presentation {"format": "saml2-assertion",
"assertion": base64, "response": base64, "name_id", "name_id_format"}:
the decrypted assertion – signed by the proxy service where it signs
assertions, so that its attributes can be checked against that node’s
metadata later – and the SAML response as the proxy service sent it, whose
signature covers the assertion encrypted to the Connector.
For kych-eid: helper (kych-native, kych-eid),
credential_type de-eid, issuer (eid_server kych-eid, the
card’s document_signer and its csca), trust (source
eid-server, the terminal_certificate, dv_certificate and
cvca, and what was checked: Terminal, Chip and Passive
Authentication, the defect list, CRLs, document validity, the block list),
level_of_assurance high, status (the block list:
list_id, result valid), holder_binding (method eac),
request (the attributes, the required_rights,
optional_rights and effective_rights, what was not_read) and
presentation {"format": "kych-eid-signed-result", "signed_result":
base64, "signer_certificate": base64}: a CMS SignedData by kych-eid’s
result signing key over a JSON document of the attributes read and every
check made. Again the eID server’s own statement, not the card’s.