Skip to content

refactor(user-tokens): migrate from server#2279

Open
shikanime wants to merge 1 commit into
mainfrom
shikanime/push-uotmotuknkvy
Open

refactor(user-tokens): migrate from server#2279
shikanime wants to merge 1 commit into
mainfrom
shikanime/push-uotmotuknkvy

Conversation

@shikanime

Copy link
Copy Markdown
Member

Issues liées

Issues numéro: #1889


Quel est le comportement actuel ?

Quel est le nouveau comportement ?

Cette PR introduit-elle un breaking change ?

Autres informations

Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.service.ts Fixed
Comment thread apps/server-nestjs/src/modules/user-tokens/user-tokens.service.ts Fixed
@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from a9a75b7 to 64a5234 Compare June 30, 2026 10:02
Comment thread apps/server-nestjs/src/modules/admin-token/admin-token.service.ts Fixed
Comment thread apps/server-nestjs/src/modules/user-tokens/user-tokens.service.ts Fixed
Comment thread apps/server-nestjs/test/admin-token.e2e-spec.ts Fixed
Comment thread apps/server-nestjs/test/user-tokens.e2e-spec.ts Dismissed
@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch 10 times, most recently from b37e308 to 0331d48 Compare July 1, 2026 09:54
@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from 0331d48 to c53cb23 Compare July 1, 2026 10:19
Comment thread apps/server-nestjs/src/modules/gitlab/gitlab-client.service.ts Fixed
Comment thread apps/server-nestjs/src/modules/gitlab/gitlab.service.ts Fixed
@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch 2 times, most recently from 09f3402 to b667443 Compare July 1, 2026 11:29
@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch 2 times, most recently from 1b31261 to f16a730 Compare July 1, 2026 12:00
@shikanime shikanime changed the title refactor(server-nestjs): migrate project hook refactor(user-tokens): migrate from server Jul 1, 2026
@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch 4 times, most recently from cecad1b to 10b4770 Compare July 1, 2026 13:35
@github-actions github-actions Bot added the built label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch 2 times, most recently from 0eb3e93 to 43d21dc Compare July 1, 2026 13:56
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from 2e5abec to 09ac7ac Compare July 3, 2026 14:06
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from 09ac7ac to 7b8a3c7 Compare July 3, 2026 15:31
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from 7b8a3c7 to a1e4df7 Compare July 7, 2026 10:46
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from a1e4df7 to 125804c Compare July 8, 2026 08:32
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from 125804c to aa3de07 Compare July 8, 2026 09:12
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from aa3de07 to e5ce635 Compare July 8, 2026 09:41
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch 2 times, most recently from 60bbb8e to d7d0c3b Compare July 8, 2026 09:53
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

1 similar comment
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime requested a review from KepoParis July 8, 2026 10:16
@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from d7d0c3b to 6bfdd13 Compare July 13, 2026 09:20
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from 6bfdd13 to b5b5107 Compare July 13, 2026 12:38
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from b5b5107 to 3b957fa Compare July 13, 2026 13:30
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

Signed-off-by: Shikanime Deva <william.phetsinorath@shikanime.studio>
Change-Id: I5b6db65fcf411b3bfddc4a72430b8d4c6a6a6964
@StephaneTrebel StephaneTrebel self-requested a review July 15, 2026 12:05
@shikanime shikanime force-pushed the shikanime/push-uotmotuknkvy branch from 3b957fa to 259a636 Compare July 15, 2026 12:16
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hey !

The security scan report for the current pull request is available here.

@cloud-pi-native-sonarqube

Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: tant qu'on n'a pas statué sur le sujet, je préfère qu'on ne commite aucun "plan"

| Decision | Choix |
|----------|-------|
| Approche migration | Bottom-up (feuilles d'abord, puis remontee vers les modules couples) |
| Approche migration | Bottom-up (feuilles d'abord, puis remonttee vers les modules couples) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
| Approche migration | Bottom-up (feuilles d'abord, puis remonttee vers les modules couples) |
| Approche migration | Bottom-up (feuilles d'abord, puis remontée vers les modules couples) |

@Get()
@RequireAdminPermission('ListAdminToken')
async list(@Query('withRevoked') withRevoked?: string) {
return this.service.list(withRevoked !== undefined && withRevoked !== 'false')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: ça ne serait pas mieux avec:

Suggested change
return this.service.list(withRevoked !== undefined && withRevoked !== 'false')
return this.service.list(withRevoked === 'true')

?
Parce que bon avec withRevoked = "chocapics", ça passe 😅

constructor(@Inject(PrismaService) private readonly prisma: PrismaService) {}

@StartActiveSpan()
async list(withRevoked?: boolean) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: Ouais donc effectivement y a zéro raison que withRevoked soit autre chose qu'un booléen.

Parse, don't validate

this.logger.log(`adminToken.create started (tokenName=${data.name})`)

if (data.expirationDate && !isAtLeastTomorrow(new Date(data.expirationDate))) {
this.logger.warn(`adminToken.create rejected (tokenName=${data.name}, reason=expirationTooSoon)`)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: la date peut aussi être invalide (new Date("toto") === "Invalid Date"), et je ne vois rien qui l'indique clairement.
Niveau traçabilité, c'est pas top

try {
const response = await fetch(url)
if (response.status < 500) return indicator.up({ httpStatus: response.status })
if (response.status < HttpStatus.INTERNAL_SERVER_ERROR) return indicator.up({ httpStatus: response.status })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

praise: Ah ben je me demandais dans une autre MR si on avait des constantes pour ça. Je me disais bien qu'on avait ce qu'il faut 😁


@Get()
async list(@AuthUser() user: UserContext) {
if (!user.userId || user.userType !== 'human') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: s/'human'/HUMAN_KIND

}

@Post()
@HttpCode(201)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: Mais du coup on peut utiliser les constantes des codes HTTP ici, non ? 😏

hash: 'hash-2',
})

const result = await service.create({ name: 'my-token', expirationDate: '2099-01-01' }, userId)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thought: Je me demande toujours, quand il s'agit de dates, si on est timezone-safe 🤔

D'autant que n'importe qui peut appeler l'API (légitimement j'entends)

Comment on lines +41 to +44
const password = generateRandomPassword(48, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-')
const salt = randomBytes(16).toString('hex')
const derivedKey = scryptSync(password, salt, 64).toString('hex')
const hash = `${salt}:${derivedKey}`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: Bon ben ça fait deux, là, non ? 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants