Repository navigation
Expand file tree
/
Copy pathcompose.yaml
More file actions
266 lines (260 loc) · 9.03 KB
/
Copy pathcompose.yaml
File metadata and controls
266 lines (260 loc) · 9.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# Self-contained Cryptomator Hub stack for local testing. Does not reference any other file of this repository:
#
# docker compose up
#
# Hub: http://localhost:8080 (realm user `admin` / `admin`, set a license on first login)
# Keycloak: http://localhost:8180 (bootstrap admin `admin` / `admin`)
#
# NOT FOR PRODUCTION: well-known passwords, plain HTTP, all services on localhost. See README.md in this directory for details.
#
# To change ports or hostnames, update all of these together: the `ports` mappings, `KC_HOSTNAME`, `HUB_KEYCLOAK_PUBLIC_URL`, `QUARKUS_OIDC_TOKEN_ISSUER`,
# the `connect-src` entry of Hub's Content Security Policy, and the `redirectUris` / `frame-ancestors` of the embedded realm. Note that browsers grant a secure
# context (required by Hub's client-side crypto) to `localhost` only — any other hostname needs TLS, see ../prod/compose.yaml.
services:
postgres:
image: postgres:18.6-alpine
environment:
POSTGRES_DB: hub
POSTGRES_USER: hub
POSTGRES_PASSWORD: hub
configs:
- source: create-keycloak-db
target: /docker-entrypoint-initdb.d/create-keycloak-db.sql
volumes:
# postgres >= 18 keeps PGDATA in /var/lib/postgresql/<major>/docker, so the volume is mounted one level up
- postgres-data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hub -d hub"]
interval: 5s
timeout: 3s
retries: 12
keycloak:
image: ghcr.io/cryptomator/keycloak:26.8.1
command: start --optimized --import-realm
environment:
KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak
KC_DB_USERNAME: keycloak
KC_DB_PASSWORD: keycloak
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
KC_HTTP_ENABLED: "true"
# issuer/discovery URLs advertise the browser-facing origin; Hub's backchannel requests via http://keycloak:8080 still work:
KC_HOSTNAME: http://localhost:8180
KC_HOSTNAME_BACKCHANNEL_DYNAMIC: "true"
QUARKUS_TRANSACTION_MANAGER_ENABLE_RECOVERY: "false"
ports:
- "8180:8080"
configs:
# imported on first boot only; `--import-realm` never overwrites an existing realm (run `docker compose down -v` to start over)
- source: cryptomator-realm
target: /opt/keycloak/data/import/cryptomator-realm.json
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:9000/health/ready"]
interval: 5s
timeout: 3s
retries: 30
hub:
image: ghcr.io/cryptomator/hub:2.1.4
environment:
HUB_PUBLIC_ROOT_PATH: /
HUB_KEYCLOAK_PUBLIC_URL: http://localhost:8180
HUB_KEYCLOAK_LOCAL_URL: http://keycloak:8080
HUB_KEYCLOAK_REALM: cryptomator
HUB_KEYCLOAK_SYSTEM_CLIENT_ID: cryptomatorhub-system
HUB_KEYCLOAK_SYSTEM_CLIENT_SECRET: top-secret
HUB_KEYCLOAK_SYNCER_PERIOD: 1m
QUARKUS_OIDC_AUTH_SERVER_URL: http://keycloak:8080/realms/cryptomator
QUARKUS_OIDC_TOKEN_ISSUER: http://localhost:8180/realms/cryptomator
QUARKUS_OIDC_CLIENT_ID: cryptomatorhub
QUARKUS_DATASOURCE_JDBC_URL: jdbc:postgresql://postgres:5432/hub
QUARKUS_DATASOURCE_USERNAME: hub
QUARKUS_DATASOURCE_PASSWORD: hub
# the image's default CSP only allows same-origin connections, but the SPA must reach Keycloak's OIDC endpoints on localhost:8180:
QUARKUS_HTTP_HEADER__CONTENT_SECURITY_POLICY__VALUE: "default-src 'self'; connect-src 'self' api.cryptomator.org localhost:8180; object-src 'none'; child-src 'self'; img-src * data:; frame-ancestors 'none'"
QUARKUS_OTEL_SDK_DISABLED: "true"
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
keycloak:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:9000/q/health/ready"]
interval: 5s
timeout: 3s
retries: 30
configs:
# Hub and Keycloak share the postgres instance but use separate databases:
create-keycloak-db:
content: |
CREATE USER keycloak WITH PASSWORD 'keycloak';
CREATE DATABASE keycloak OWNER keycloak;
# Minimal realm: realm roles, the three OIDC clients Hub relies on, one Hub admin and the service account used by Hub to sync users/groups.
# Mirrors what the Helm chart renders (chart/templates/_realm.tpl); URLs are fixed to the ports published above.
cryptomator-realm:
content: |
{
"realm": "cryptomator",
"displayName": "Cryptomator Hub",
"loginTheme": "cryptomator",
"enabled": true,
"sslRequired": "external",
"defaultRole": {
"name": "user",
"description": "User"
},
"roles": {
"realm": [
{
"name": "user",
"description": "User",
"composite": false
},
{
"name": "create-vaults",
"description": "Can create vaults",
"composite": false
},
{
"name": "admin",
"description": "Administrator",
"composite": true,
"composites": {
"realm": [
"user",
"create-vaults"
],
"client": {
"realm-management": [
"realm-admin"
]
}
}
}
]
},
"users": [
{
"username": "admin",
"enabled": true,
"credentials": [
{
"type": "password",
"value": "admin",
"temporary": false
}
],
"realmRoles": [
"admin"
]
},
{
"username": "system",
"email": "system@localhost",
"enabled": true,
"serviceAccountClientId": "cryptomatorhub-system",
"clientRoles": {
"realm-management": [
"realm-admin",
"view-system"
]
}
}
],
"scopeMappings": [
{
"client": "cryptomatorhub",
"roles": [
"user",
"admin"
]
}
],
"clients": [
{
"clientId": "cryptomatorhub",
"serviceAccountsEnabled": false,
"publicClient": true,
"name": "Cryptomator Hub",
"enabled": true,
"redirectUris": [
"http://localhost:8080/*"
],
"webOrigins": [
"+"
],
"bearerOnly": false,
"frontchannelLogout": false,
"protocol": "openid-connect",
"attributes": {
"pkce.code.challenge.method": "S256"
},
"protocolMappers": [
{
"name": "realm roles",
"protocol": "openid-connect",
"protocolMapper": "oidc-usermodel-realm-role-mapper",
"consentRequired": false,
"config": {
"access.token.claim": "true",
"claim.name": "realm_access.roles",
"jsonType.label": "String",
"multivalued": "true"
}
},
{
"name": "client roles",
"protocol": "openid-connect",
"protocolMapper": "oidc-usermodel-client-role-mapper",
"consentRequired": false,
"config": {
"access.token.claim": "true",
"claim.name": "resource_access.$${client_id}.roles",
"jsonType.label": "String",
"multivalued": "true"
}
}
]
},
{
"clientId": "cryptomator",
"serviceAccountsEnabled": false,
"publicClient": true,
"name": "Cryptomator App",
"enabled": true,
"redirectUris": [
"http://127.0.0.1/*",
"org.cryptomator.ios:/hub/auth",
"org.cryptomator.android:/hub/auth"
],
"webOrigins": [
"+"
],
"bearerOnly": false,
"frontchannelLogout": false,
"protocol": "openid-connect",
"attributes": {
"pkce.code.challenge.method": "S256"
}
},
{
"clientId": "cryptomatorhub-system",
"serviceAccountsEnabled": true,
"publicClient": false,
"name": "Cryptomator Hub System",
"enabled": true,
"clientAuthenticatorType": "client-secret",
"secret": "top-secret",
"standardFlowEnabled": false
}
],
"browserSecurityHeaders": {
"contentSecurityPolicy": "frame-src 'self'; frame-ancestors 'self' http://localhost:8080; object-src 'none';"
}
}
volumes:
postgres-data: