Skip to content

refactor(admin-token): migrate from server - #2740

Merged
shikanime merged 27 commits into
mainfrom
pr/admin-token-migration
Oct 2, 2026
Merged

shikanime merged 27 commits into
mainfrom
pr/admin-token-migration

Conversation

@shikanime

@shikanime shikanime commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Issues liées

Refs #1889


Quel est le comportement actuel ?

Les routes admin-tokens (/api/v1/admin/tokens) sont servies par l'ancienne application Fastify apps/server.

Quel est le nouveau comportement ?

Migration du module admin-token vers apps/server-nestjs :

  • AdminTokenController (UserGuard), AdminTokenService, AdminTokenModule enregistré dans main.module.ts.
  • CreateAdminTokenBodySchema : CoerceBooleanSchema sur withRevoked, ExpirationDateSchema réutilisant isAtLeastTomorrow de @cpn-console/shared.
  • admin-token-queries.utils.ts : sélections Prisma typées.
  • Parité des contrats et codes HTTP contre apps/server/src/resources/admin-token/ (rejet 400 « Date d'expiration trop courte », hash SHA-256 unsalted inchangé).

Cette PR introduit-elle un breaking change ?

Non.

Autres informations

Recréée pour #1889 (remplace #2442, non réouvrable après suppression de branche).

@shikanime
shikanime force-pushed the pr/admin-token-migration branch from 89babfe to 1b827e2 Compare September 17, 2026 10:21
@shikanime shikanime self-assigned this Sep 17, 2026
@shikanime shikanime added this to the 9.27.0 milestone Sep 17, 2026
@shikanime
shikanime force-pushed the pr/admin-token-migration branch from 1b827e2 to 116b610 Compare September 17, 2026 13:40
@github-actions github-actions Bot added the built label Sep 17, 2026
Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.controller.ts Outdated
Comment thread apps/server-nestjs/test/admin-token.e2e-spec.ts Outdated
@shikanime

Copy link
Copy Markdown
Member Author

apps/server-nestjs/src/main.module.ts:L28 🟡 risk: AdminTokenModule jamais importé dans MainModule → la route /api/v1/admin/tokens n'est jamais servie par Nest (fallback legacy). Ajouter l'import à la bascule, sinon la migration est morte-code.

Comment thread apps/server-nestjs/src/utils/schemas.ts Outdated
Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.controller.ts Outdated
@shikanime

Copy link
Copy Markdown
Member Author

Traité dans 314416c : module câblé dans MainModule.

@shikanime shikanime added the preview Deploy preview app with Argo-cd label Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

A preview of the application is available at : https://console-pr-2740.dso.cpin-hp.numerique-interieur.fr

Please be patient, deployment may take a few minutes.

Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.service.spec.ts Outdated
Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.service.spec.ts Outdated
Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.service.ts Outdated
Comment thread apps/server-nestjs/test/admin-token.e2e-spec.ts Outdated

@shikanime shikanime left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict : Changements demandés

Migration fidèle du module admin-token : parité des contrats, codes HTTP et du hash SHA-256 vérifiée contre apps/server, aucune régression du pont événements → hooks (aucun hook.adminToken en amont). Point positif : les sélections Prisma typées via satisfies garantissent l'omission du hash à la source. Un seul point bloquant : la PR désenregistre AdminRoleModule de main.module.ts, ce qui ne fait pas partie de son périmètre.

Comment thread apps/server-nestjs/src/main.module.ts
Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.service.ts
Comment thread apps/server-nestjs/src/modules/admin-token/admin-token-queries.utils.ts Outdated
Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.utils.ts Outdated
@shikanime
shikanime changed the base branch from main to pr/admin-role-event-bridge September 18, 2026 09:44
@shikanime
shikanime added this pull request to stack #2750 September 18, 2026 09:44
@shikanime
shikanime removed this pull request from stack #2750 September 18, 2026 09:44
@shikanime
shikanime changed the base branch from pr/admin-role-event-bridge to pr/stage-strangler September 18, 2026 09:45
@shikanime
shikanime changed the base branch from pr/stage-strangler to main September 18, 2026 09:45
@shikanime
shikanime changed the base branch from main to pr/cluster-migration September 18, 2026 09:46
@shikanime
shikanime added this pull request to stack #2752 September 18, 2026 09:46
shikanime added a commit that referenced this pull request Sep 18, 2026
Rebase #2740 onto pr/cluster-migration (#2495): keep both module
registrations in main.module.ts.

Signed-off-by: Shikanime Deva <22115108+shikanime@users.noreply.github.com>
shikanime added a commit that referenced this pull request Sep 18, 2026
#2740 rebases onto this branch; pre-register its module so the stack
rebases cleanly.

Signed-off-by: Shikanime Deva <22115108+shikanime@users.noreply.github.com>
@shikanime
shikanime force-pushed the pr/admin-token-migration branch 4 times, most recently from 410920c to 95a36ea Compare September 18, 2026 10:29
shikanime and others added 22 commits October 2, 2026 17:05
… of contract alias

Co-authored-by: Automata <automata@shikanime.studio>
Co-authored-by: Automata <automata@shikanime.studio>
…ce boundary

Co-authored-by: Automata <automata@shikanime.studio>
Co-authored-by: Automata <automata@shikanime.studio>
Co-authored-by: Automata <automata@shikanime.studio>
…turnType aliases

Co-authored-by: Automata <automata@shikanime.studio>
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I1d8ffcb80aa787018dc4e8008ab5a84f6a6a6964
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I957c9bb79f59855521fc4cb69964dbaa6a6a6964
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: Ie45ff1996f70edc312ba938d388016c96a6a6964
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I42726b788f39dbe4c6f660cb57af3c206a6a6964
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: Ib0b6d8746627891c22f62875b8c2f75d6a6a6964
… site

Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: Ib08a0f1a001be5d0eb788b91210f81bb6a6a6964
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I17ff50ee3a67efcccaa275508067c3ac6a6a6964
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: Iafe340dd1f247a0a221e39ff4c26bc946a6a6964
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I70793bd5f8f6d1991c97aa7a1e4f5bcd6a6a6964
Co-authored-by: Automata <automata@shikanime.studio>
Co-authored-by: Automata <automata@shikanime.studio>
Co-authored-by: Automata <automata@shikanime.studio>
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: Ic276ad1c4e15fe04cb6f24ed522ca6b96a6a6964
…tial

Co-authored-by: Automata <automata@shikanime.studio>
Co-authored-by: Automata <automata@shikanime.studio>
@shikanime
shikanime force-pushed the pr/admin-token-migration branch from cf10952 to a1d29e6 Compare October 2, 2026 15:06
@shikanime
shikanime enabled auto-merge October 2, 2026 15:17
@cloud-pi-native-sonarqube

Copy link
Copy Markdown

@shikanime
shikanime disabled auto-merge October 2, 2026 15:55
@shikanime
shikanime added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit 7af2fee Oct 2, 2026
34 checks passed
@shikanime
shikanime deleted the pr/admin-token-migration branch October 2, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

built refactor Refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants