Skip to content

Commit 0a26926

Browse files
committed
fix(admin-roles): admin conflicting with existing admin group in Keycloack
The new AdminRole implementation introduced by #1893 changed the source of truth from Keycloak to Console, which overrides all existing data based on the state of Console. Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
1 parent 41225c3 commit 0a26926

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

apps/server/src/prisma/migrations/20260204150335_add_system_roles/migration.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Update existing Admin role to be system role 'Administrateur Plateforme'
22
UPDATE "AdminRole"
3-
SET
3+
SET
44
"name" = 'Administrateur Plateforme',
55
"type" = 'system',
66
"permissions" = 3, -- Assuming 3n means bit 0 and 1 (1 | 2 = 3)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- Update existing Admin role to be system role 'Root Administrateur Plateforme'
2+
UPDATE "AdminRole"
3+
SET
4+
"name" = 'Root Administrateur Plateforme'
5+
WHERE "id" = '76229c96-4716-45bc-99da-00498ec9018c'::uuid;
6+
7+
-- Insert 'Administrateur Plateforme' system role if it doesn't exist
8+
INSERT INTO "AdminRole" ("id", "name", "permissions", "position", "oidcGroup", "type")
9+
VALUES (
10+
'6bebe7b2-0f0a-456e-ab7f-b3d7640a7cbf'::uuid,
11+
'Administrateur Plateforme',
12+
3, -- Assuming 3n means bit 0 and 1 (1 | 2 = 3)
13+
0,
14+
'/console/admin',
15+
'system'
16+
)
17+
ON CONFLICT ("id") DO UPDATE
18+
SET
19+
"name" = 'Administrateur Plateforme',
20+
"type" = 'system',
21+
"permissions" = 3,
22+
"oidcGroup" = '/console/admin';
23+
24+
-- Update 'Lecture Seule Plateforme' system role
25+
UPDATE "AdminRole"
26+
SET
27+
"oidcGroup" = '/console/readonly'
28+
WHERE "id" = '35848aa2-e881-4770-9844-0c5c3693e506'::uuid;

packages/test-utils/src/imports/data.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export const data = {
2424
permissions: '3n',
2525
position: 0,
2626
oidcGroup: '/admin',
27+
name: 'Root Administrateur Plateforme',
28+
type: 'system',
29+
},
30+
{
31+
id: '6bebe7b2-0f0a-456e-ab7f-b3d7640a7cbf',
32+
permissions: '3n',
33+
position: 0,
34+
oidcGroup: '/console/admin',
2735
name: 'Administrateur Plateforme',
2836
type: 'system',
2937
},
@@ -39,7 +47,7 @@ export const data = {
3947
id: '35848aa2-e881-4770-9844-0c5c3693e506',
4048
permissions: '1n',
4149
position: 2,
42-
oidcGroup: '/readonly',
50+
oidcGroup: '/console/readonly',
4351
name: 'Lecture Seule Plateforme',
4452
type: 'system',
4553
},

0 commit comments

Comments
 (0)