1717from app .auth import get_auth_ctx
1818
1919
20+ API_DESCRIPTION = """
21+ The Pseudoniemendienst (PRS) lets parties exchange data about a person without
22+ sharing their BSN. Instead of a BSN, parties exchange **RIDs** and **pseudonyms**
23+ that are scoped to a recipient organization and scope.
24+
25+ A recipient organization is always identified by a URA in the form
26+ `ura:<8 digits>` (e.g. `ura:90000036`).
27+
28+ The endpoints are grouped into the sections below. Most sections are protected by
29+ mutual TLS (mTLS); the calling organization and, where relevant, its public key
30+ are derived from the client certificate.
31+ """
32+
33+ # Section (tag) metadata shown in the Swagger UI / OpenAPI schema. The order here
34+ # determines the order in which the sections are rendered.
35+ TAGS_METADATA = [
36+ {
37+ "name" : "Service Information" ,
38+ "description" : (
39+ "Public, unauthenticated endpoints reporting the service version and "
40+ "health status. Useful for load balancers, monitoring, and smoke tests."
41+ ),
42+ },
43+ {
44+ "name" : "Organizational Services" ,
45+ "description" : (
46+ "Manage recipient organizations. An organization is identified by its "
47+ "URA and has a `max_key_usage` (`bsn`, `rp`, or `irp`) that caps which "
48+ "pseudonym types it is allowed to exchange."
49+ ),
50+ },
51+ {
52+ "name" : "Key Registration Services" ,
53+ "description" : (
54+ "Register and manage the public keys that pseudonyms and RIDs are "
55+ "encrypted to. The organization and its public key are derived from the "
56+ "mTLS client certificate, so they are not part of the request body."
57+ ),
58+ },
59+ {
60+ "name" : "Key Version Services" ,
61+ "description" : (
62+ "Manage the HSM key versions used to derive pseudonyms. Multiple "
63+ "versions can be active at once to support key rotation, where older "
64+ "versions remain available alongside the latest one."
65+ ),
66+ },
67+ {
68+ "name" : "OPRF Services" ,
69+ "description" : (
70+ "Evaluate a blinded personal identifier using the Oblivious "
71+ "Pseudo-Random Function and return a JWE (encrypted to the recipient's "
72+ "public key) containing the evaluation for the active key version(s)."
73+ ),
74+ },
75+ ]
76+
77+ # Section (tag) metadata for the exchange routes. Only included in the OpenAPI
78+ # schema when `enable_exchange_services_routes` is set, matching when these routes
79+ # are mounted.
80+ EXCHANGE_TAGS_METADATA = [
81+ {
82+ "name" : "Exchange Services" ,
83+ "description" : (
84+ "Exchange a personal ID for a pseudonym or RID targeted at a recipient "
85+ "organization/scope, and redeem a previously issued RID for a pseudonym "
86+ "(or the BSN, when permitted by both the RID usage and the "
87+ "organization's `max_key_usage`)."
88+ ),
89+ },
90+ ]
91+
92+ # Section (tag) metadata for the test/helper routes. Only included in the OpenAPI
93+ # schema when `enable_test_routes` is set, matching when these routes are mounted.
94+ TEST_TAGS_METADATA = [
95+ {
96+ "name" : "OPRF Testing Services" ,
97+ "description" : (
98+ "Helper endpoints for testing and debugging the OPRF and JWE flows "
99+ "(client-side blinding, receiver finalization, JWE decoding, pseudonym "
100+ "reversal, and mTLS introspection). These are only mounted when "
101+ "`enable_test_routes` is set and must not be enabled in production."
102+ ),
103+ },
104+ ]
105+
106+
20107def get_uvicorn_params () -> dict [str , Any ]:
21108 config = get_config ()
22109
@@ -72,13 +159,20 @@ def setup_logging() -> None:
72159def setup_fastapi () -> FastAPI :
73160 config = get_config ()
74161
162+ openapi_tags = list (TAGS_METADATA )
163+ if config .app .enable_exchange_services_routes :
164+ openapi_tags += EXCHANGE_TAGS_METADATA
165+ if config .app .enable_test_routes :
166+ openapi_tags += TEST_TAGS_METADATA
167+
75168 fastapi = (
76169 FastAPI (
77170 docs_url = config .uvicorn .docs_url ,
78171 redoc_url = config .uvicorn .redoc_url ,
79172 title = "Pseudoniemendienst API" ,
80173 summary = "API for the Pseudoniemendienst" ,
81- description = "Provides endpoints for OPRF, key management, organization management, and RID exchange." ,
174+ description = API_DESCRIPTION ,
175+ openapi_tags = openapi_tags ,
82176 root_path = config .uvicorn .root_path ,
83177 )
84178 if config .uvicorn .swagger_enabled
@@ -98,9 +192,10 @@ def setup_fastapi() -> FastAPI:
98192 oprf_router ,
99193 key_router ,
100194 hsm_key_version_router ,
101- exchange_router ,
102195 org_router ,
103196 ]
197+ if config .app .enable_exchange_services_routes :
198+ routers .append (exchange_router )
104199 if config .app .enable_test_routes :
105200 routers .append (test_oprf_router )
106201
0 commit comments