Skip to content

Commit 14a80f3

Browse files
committed
Migrate syncer user to cryptomatorhub-system client
1 parent 4874008 commit 14a80f3

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

assets/js/hubsetup.js

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class HubSetup {
3333
publicUrl: 'https://domain.tld',
3434
adminUser: 'admin',
3535
adminPw: 'admin',
36-
syncerUser: 'syncer', // TODO: randomize?
37-
syncerPw: HubSetup.uuid(),
36+
systemClientSecret: HubSetup.uuid(),
3837
}
3938
}
4039
}
@@ -231,16 +230,6 @@ GRANT ALL PRIVILEGES ON DATABASE hub TO hub;`);
231230
'realm-management': ['realm-admin']
232231
}
233232
}
234-
},
235-
{
236-
name: 'syncer',
237-
description: 'syncer',
238-
composite: true,
239-
composites: {
240-
client: {
241-
'realm-management': ['view-users']
242-
}
243-
}
244233
}
245234
],
246235
},
@@ -253,13 +242,11 @@ GRANT ALL PRIVILEGES ON DATABASE hub TO hub;`);
253242
realmRoles: ['admin']
254243
},
255244
{
256-
username: this.cfg.hub.syncerUser,
257-
firstName: "syncer",
258-
lastName: "syncer",
259-
email: "syncer@localhost",
245+
username: 'system',
246+
email: "system@localhost",
260247
enabled: true,
261-
credentials: [{ type: 'password', value: this.cfg.hub.syncerPw, temporary: false }],
262-
realmRoles: ['syncer']
248+
serviceAccountClientId: "cryptomatorhub-system",
249+
clientRoles: { 'realm-management' : ['realm-admin'] }
263250
}
264251
],
265252
scopeMappings: [
@@ -325,6 +312,16 @@ GRANT ALL PRIVILEGES ON DATABASE hub TO hub;`);
325312
frontchannelLogout: false,
326313
protocol: 'openid-connect',
327314
attributes: { 'pkce.code.challenge.method': 'S256' },
315+
},
316+
{
317+
clientId: 'cryptomatorhub-system',
318+
serviceAccountsEnabled: true,
319+
publicClient: false,
320+
name: 'Cryptomator Hub System',
321+
enabled: true,
322+
clientAuthenticatorType: 'client-secret',
323+
secret: this.cfg.hub.systemClientSecret,
324+
standardFlowEnabled: false,
328325
}],
329326
browserSecurityHeaders: {
330327
contentSecurityPolicy: `frame-src 'self'; frame-ancestors 'self' ${HubSetup.urlWithTrailingSlash(this.cfg.hub.publicUrl)}; object-src 'none';`
@@ -488,9 +485,8 @@ EOF`;
488485
HUB_KEYCLOAK_PUBLIC_URL: this.cfg.keycloak.publicUrl,
489486
HUB_KEYCLOAK_LOCAL_URL: !this.cfg.keycloak.useExternal ? `http://keycloak:8080${this.getPathname(this.cfg.keycloak.publicUrl)}` : this.cfg.keycloak.publicUrl,
490487
HUB_KEYCLOAK_REALM: this.cfg.keycloak.realmId,
491-
HUB_KEYCLOAK_SYNCER_USERNAME: this.cfg.hub.syncerUser,
492-
HUB_KEYCLOAK_SYNCER_PASSWORD: this.cfg.hub.syncerPw,
493-
HUB_KEYCLOAK_SYNCER_CLIENT_ID: 'admin-cli',
488+
HUB_KEYCLOAK_SYSTEM_CLIENT_ID: 'cryptomatorhub-system',
489+
HUB_KEYCLOAK_SYSTEM_CLIENT_SECRET: this.cfg.hub.systemClientSecret,
494490
HUB_KEYCLOAK_SYNCER_PERIOD: '5m', // TODO make configurable?
495491
HUB_KEYCLOAK_OIDC_CRYPTOMATOR_CLIENT_ID: 'cryptomator',
496492
QUARKUS_OIDC_AUTH_SERVER_URL: new URL(`realms/${this.cfg.keycloak.realmId}`, HubSetup.urlWithTrailingSlash(!this.cfg.keycloak.useExternal ? `http://keycloak:8080${this.getPathname(this.cfg.keycloak.publicUrl)}` : this.cfg.keycloak.publicUrl)).href, // network-internal URL
@@ -608,8 +604,7 @@ class KubernetesConfigBuilder extends ConfigBuilder {
608604
'db_admin_pass': this.cfg.db.adminPw,
609605
'db_hub_pass': this.cfg.db.hubPw,
610606
...(!this.cfg.keycloak.useExternal) && { 'db_kc_pass': this.cfg.db.keycloakPw },
611-
'hub_syncer_user': this.cfg.hub.syncerUser,
612-
'hub_syncer_pass': this.cfg.hub.syncerPw,
607+
'hub_system_client_secret': this.cfg.hub.systemClientSecret,
613608
'initdb.sql': this.getInitDbSQL(),
614609
...(!this.cfg.keycloak.useExternal) && { 'realm.json': JSON.stringify(realmCfg, null, 2) }
615610
}
@@ -683,9 +678,8 @@ class KubernetesConfigBuilder extends ConfigBuilder {
683678
{name: 'HUB_KEYCLOAK_PUBLIC_URL', value: this.cfg.keycloak.publicUrl},
684679
{name: 'HUB_KEYCLOAK_LOCAL_URL', value: !this.cfg.keycloak.useExternal ? `http://keycloak-svc:8080${this.getPathname(this.cfg.keycloak.publicUrl)}` : this.cfg.keycloak.publicUrl},
685680
{name: 'HUB_KEYCLOAK_REALM', value: this.cfg.keycloak.realmId},
686-
{name: 'HUB_KEYCLOAK_SYNCER_USERNAME', valueFrom: {secretKeyRef: {name: 'hub-secrets', key: 'hub_syncer_user'}}},
687-
{name: 'HUB_KEYCLOAK_SYNCER_PASSWORD', valueFrom: {secretKeyRef: {name: 'hub-secrets', key: 'hub_syncer_pass'}}},
688-
{name: 'HUB_KEYCLOAK_SYNCER_CLIENT_ID', value: 'admin-cli'},
681+
{name: 'HUB_KEYCLOAK_SYSTEM_CLIENT_ID', value: 'cryptomatorhub-system'},
682+
{name: 'HUB_KEYCLOAK_SYSTEM_CLIENT_SECRET', valueFrom: {secretKeyRef: {name: 'hub-secrets', key: 'hub_system_client_secret'}}},
689683
{name: 'HUB_KEYCLOAK_SYNCER_PERIOD', value: '5m'}, // TODO make configurable?
690684
{name: 'HUB_KEYCLOAK_OIDC_CRYPTOMATOR_CLIENT_ID', value: 'cryptomator'},
691685
{name: 'QUARKUS_OIDC_AUTH_SERVER_URL', value: new URL(`realms/${this.cfg.keycloak.realmId}`, HubSetup.urlWithTrailingSlash(!this.cfg.keycloak.useExternal ? `http://keycloak-svc:8080${this.getPathname(this.cfg.keycloak.publicUrl)}` : this.cfg.keycloak.publicUrl)).href},

0 commit comments

Comments
 (0)