Skip to content

Commit 3a2ee7c

Browse files
Merge pull request #4484 from open-formulieren/feature/3967-record-vestiging-eherkenning
Record and expose vestiging for eherkenning logins
2 parents 6d0c76f + b5e791e commit 3a2ee7c

File tree

14 files changed

+1031
-11
lines changed

14 files changed

+1031
-11
lines changed

docker/keycloak/README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ VCR.py). The primary reason this setup exists, is for automated testing reasons.
4343

4444
- `testuser` / `testuser`, has the `bsn`, `kvk`, `name_qualifier`, `legalSubjectID` and
4545
`actingSubjectID` attributes (authentication plugins: DigiD, eHerkenning)
46-
- `digid-machtigen` / `digid-machtigen`, has the `aanvrager.bsn`, `gemachtigde.bsn` and
47-
`service_id` attributes (for DigiD machtigen)
48-
- `eherkenning-bewindvoering` / `eherkenning-bewindvoering`, has the `legalSubjectID`
49-
(kvk), `actingSubjectID` (pseudo ID), `representeeBSN`, `service_id`, `service_uuid`,
50-
and `name_qualifier` attributes (for eHerkenning bewindvoering)
51-
- `admin` / `admin`, intended to create as django user (can be made staff). The email
52-
address is `admin@example.com`.
46+
- `digid-machtigen` / `digid-machtigen`, has the `aanvrager.bsn`, `gemachtigde.bsn` and `service_id`
47+
attributes (for DigiD machtigen)
48+
- `eherkenning-bewindvoering` / `eherkenning-bewindvoering`, has the `legalSubjectID` (kvk),
49+
`actingSubjectID` (pseudo ID), `representeeBSN`, `service_id`, `service_uuid`, and
50+
`name_qualifier` attributes (for eHerkenning bewindvoering)
51+
- `eherkenning-vestiging` / `eherkenning-vestiging`, has the `vestiging` attribute plus the
52+
attributes from `eherkenning-bewindvoering`.
53+
- `admin` / `admin`, intended to create as django user (can be made staff). The email address is
54+
`admin@example.com`.
5355

5456
## Exporting the Realm
5557

docker/keycloak/import/test-realm.json

+44
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,35 @@
460460
"realmRoles" : [ "default-roles-test" ],
461461
"notBefore" : 0,
462462
"groups" : [ ]
463+
}, {
464+
"id" : "44be45f6-a7ae-42c2-9486-30f078cf5b39",
465+
"createdTimestamp" : 1719999585061,
466+
"username" : "eherkenning-vestiging",
467+
"enabled" : true,
468+
"totp" : false,
469+
"emailVerified" : false,
470+
"attributes" : {
471+
"service_uuid" : [ "81216fa4-80a1-4686-a8ac-5c8e5c030c93" ],
472+
"representeeBSN" : [ "000000000" ],
473+
"legalSubjectID" : [ "12345678" ],
474+
"actingSubjectID" : [ "4B75A0EA107B3D36" ],
475+
"service_id" : [ "urn:etoegang:DV:00000001002308836000:services:9113" ],
476+
"name_qualifier" : [ "urn:etoegang:1.9:EntityConcernedID:KvKnr" ],
477+
"vestiging" : [ "123456789012" ]
478+
},
479+
"credentials" : [ {
480+
"id" : "5e4a5b82-f5b1-48b6-9335-e25d3b417cef",
481+
"type" : "password",
482+
"userLabel" : "My password",
483+
"createdDate" : 1719999593682,
484+
"secretData" : "{\"value\":\"etDGywOL01Nr9RD1tG2x95/A37HEsf0zk2Kol8GNIJ0=\",\"salt\":\"pnnxOICMkQRoCM/ywGSOww==\",\"additionalParameters\":{}}",
485+
"credentialData" : "{\"hashIterations\":27500,\"algorithm\":\"pbkdf2-sha256\",\"additionalParameters\":{}}"
486+
} ],
487+
"disableableCredentialTypes" : [ ],
488+
"requiredActions" : [ ],
489+
"realmRoles" : [ "default-roles-test" ],
490+
"notBefore" : 0,
491+
"groups" : [ ]
463492
}, {
464493
"id" : "a28aac19-6ac5-4ce5-bbe3-b6c24051914a",
465494
"createdTimestamp" : 1707141299906,
@@ -1346,6 +1375,21 @@
13461375
"claim.name" : "service_id",
13471376
"jsonType.label" : "String"
13481377
}
1378+
}, {
1379+
"id" : "5ba6ed6e-e6c5-4c74-9049-185c875df8ad",
1380+
"name" : "vestiging",
1381+
"protocol" : "openid-connect",
1382+
"protocolMapper" : "oidc-usermodel-attribute-mapper",
1383+
"consentRequired" : false,
1384+
"config" : {
1385+
"introspection.token.claim" : "true",
1386+
"userinfo.token.claim" : "true",
1387+
"user.attribute" : "vestiging",
1388+
"id.token.claim" : "true",
1389+
"access.token.claim" : "true",
1390+
"claim.name" : "vestiging",
1391+
"jsonType.label" : "String"
1392+
}
13491393
}, {
13501394
"id" : "e12f9cee-121e-4b29-be63-0eda4cc0e8ba",
13511395
"name" : "legalSubjectID",

docs/manual/forms/variables.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ authenticatiecontextdatamodel_. De structuur is als volgt:
112112
"authorizee": {
113113
"legalSubject": {
114114
"identifierType": "string",
115-
"identifier": "string"
115+
"identifier": "string",
116+
"branchNumber": "string"
116117
},
117118
"actingSubject": {
118119
"identifierType": "string",
@@ -169,6 +170,10 @@ De onderdelen van deze structuur worden ook als individuele variabelen aangebode
169170
Identificatie van de (wettelijke) vertegenwoordiger. Leeg indien het formulier
170171
zonder inloggen gestart is.
171172

173+
``auth_context_branch_number``
174+
Vestigingsnummer waarvoor de medewerker ingelogd is. Leeg indien het geen
175+
eHerkenning-login betreft.
176+
172177
``auth_context_acting_subject_identifier_type``
173178
In de praktijk zal de waarde altijd ``opaque`` of leeg zijn. Geeft aan hoe de
174179
identificatie van de handelende persoon ("de persoon aan de knoppen")

src/openforms/authentication/contrib/digid_eherkenning_oidc/plugin.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def get_logo(self, request) -> LoginLogo | None:
212212
return LoginLogo(title=self.get_label(), **get_eherkenning_logo(request))
213213

214214
def transform_claims(self, normalized_claims: EHClaims) -> FormAuth:
215-
return {
215+
form_auth: FormAuth = {
216216
"plugin": self.identifier,
217217
# TODO: look at `identifier_type_claim` and return kvk or rsin accordingly.
218218
# Currently we have no support for RSIN at all, so that will need to be
@@ -225,6 +225,9 @@ def transform_claims(self, normalized_claims: EHClaims) -> FormAuth:
225225
"acting_subject_claim"
226226
],
227227
}
228+
if service_restriction := normalized_claims.get("branch_number_claim", ""):
229+
form_auth["legal_subject_service_restriction"] = service_restriction
230+
return form_auth
228231

229232

230233
class DigiDmachtigenClaims(TypedDict):
@@ -340,7 +343,7 @@ def transform_claims(self, normalized_claims: EHBewindvoeringClaims) -> FormAuth
340343
}
341344
)
342345

343-
return {
346+
form_auth: FormAuth = {
344347
"plugin": self.identifier,
345348
"attribute": self.provides_auth,
346349
"value": normalized_claims["representee_claim"],
@@ -368,6 +371,10 @@ def transform_claims(self, normalized_claims: EHBewindvoeringClaims) -> FormAuth
368371
},
369372
}
370373

374+
if service_restriction := normalized_claims.get("branch_number_claim", ""):
375+
form_auth["legal_subject_service_restriction"] = service_restriction
376+
return form_auth
377+
371378
def get_label(self) -> str:
372379
return "eHerkenning bewindvoering"
373380

0 commit comments

Comments
 (0)