Skip to content

Commit b03e724

Browse files
committed
FUND-2062 Updated README file
1 parent 3d9563d commit b03e724

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,66 @@ Configuration can be done through:
100100

101101
For more information, visit our [documentation portal](https://dev.oneground.nl).
102102

103+
## Data Protection & Encryption
104+
105+
The Zaken API supports encryption of sensitive personal data (BSN - Burgerservicenummer) stored in the database. This uses two mechanisms:
106+
107+
### HMAC Hashing (for searchable lookups)
108+
109+
BSN values are hashed using HMAC-SHA256 so they can be searched without storing plaintext. Configure the HMAC key via an environment variable on the Zaken container:
110+
111+
```yaml
112+
# docker-compose.yml (zgw.zaken.webapi service)
113+
environment:
114+
HmacHasher__HmacKey: "<base64-encoded-key-minimum-32-bytes>"
115+
```
116+
117+
To generate a key:
118+
119+
```bash
120+
# Linux/macOS
121+
openssl rand -base64 32
122+
123+
# PowerShell
124+
[Convert]::ToBase64String((1..32 | ForEach-Object { Get-Random -Maximum 256 }) -as [byte[]])
125+
```
126+
127+
> **Warning**: The HMAC key is permanent — if you change it, existing hashes become unsearchable. Back it up securely.
128+
129+
### DataProtection Encryption (for reversible encryption at rest)
130+
131+
BSN values are also encrypted using ASP.NET Core DataProtection. Encryption keys are stored in the database (`data_protection.DataProtectionKeys` table). Optionally, these keys can be protected with an X.509 certificate:
132+
133+
```yaml
134+
# docker-compose.yml (zgw.zaken.webapi service)
135+
environment:
136+
DataProtection__Certificate: "<base64-encoded-pfx>"
137+
DataProtection__CertificatePassword: "<pfx-password>"
138+
```
139+
140+
To generate a self-signed certificate:
141+
142+
```bash
143+
# Generate cert + key
144+
openssl req -x509 -newkey rsa:4096 \
145+
-keyout dp-key.pem -out dp-cert.pem \
146+
-sha256 -days 3650 -nodes \
147+
-subj "/CN=OneGround-DataProtection"
148+
149+
# Convert to PFX
150+
openssl pkcs12 -export \
151+
-in dp-cert.pem -inkey dp-key.pem \
152+
-out dataprotection.pfx \
153+
-passout pass:YourStrongPassword
154+
155+
# Base64 encode
156+
base64 -w 0 dataprotection.pfx
157+
```
158+
159+
> **Warning**: If the certificate is lost, all encrypted data in the database becomes permanently unreadable. Always back up the PFX file.
160+
161+
If no certificate is configured, DataProtection keys are stored unencrypted in the database. This is acceptable for development but not recommended for production.
162+
103163
## Project Structure
104164
105165
- src: source code

0 commit comments

Comments
 (0)