Skip to content

Commit a9ca7d0

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 a9ca7d0

File tree

6 files changed

+45
-8
lines changed

6 files changed

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

apps/server/src/resources/user/business.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('test users business', () => {
135135
}, {
136136
id: faker.string.uuid(),
137137
name: faker.string.alphanumeric(),
138-
oidcGroup: '/admin',
138+
oidcGroup: '/console/admin',
139139
permissions: 0n,
140140
position: 0,
141141
}]

packages/shared/src/utils/const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const adminGroupPath = '/admin'
1+
export const adminGroupPath = '/console/admin'
22
export const deleteValidationInput = 'DELETE'
33
export const forbiddenRepoNames = ['mirror', 'infra-apps', 'infra-observability']
44

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
},

playwright/e2e-tests/system-roles.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ test.describe('System Roles at Project Creation', () => {
2020

2121
// Assert
2222
const systemRoles = [
23-
{ name: 'Administrateur', oidcGroup: '/admin' },
24-
{ name: 'DevOps', oidcGroup: '/devops' },
25-
{ name: 'Développeur', oidcGroup: '/developer' },
26-
{ name: 'Lecture seule', oidcGroup: '/readonly' },
23+
{ name: 'Administrateur', oidcGroup: '/console/admin' },
24+
{ name: 'DevOps', oidcGroup: '/console/devops' },
25+
{ name: 'Développeur', oidcGroup: '/console/developer' },
26+
{ name: 'Lecture seule', oidcGroup: '/console/readonly' },
2727
]
2828

2929
for (const role of systemRoles) {

0 commit comments

Comments
 (0)