Skip to content

Commit 96d3591

Browse files
feat: JWT 토큰 발행시간(iat)을 ms 단위로 설정
- 기존에는 JWT 토큰 발행시간이 초(s) 단위로 발행되었기 때문에 값이 서로 다른 JWT 토큰을 발행하려면 적어도 1초 뒤에 토큰을 발행해야했다. - e2e 테스트에서 값이 서로 다른 JWT 토큰을 발행하기 위해 1초 동안 전체 테스트가 블록킹되는 되는 문제를 해결하기 위해 토큰 발행시간이 ms 단위로 설정되도록 수정함. Co-Authored-By: 조영우 <[email protected]>
1 parent 0f63a00 commit 96d3591

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

backend/src/lesser-jwt/lesser-jwt.service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { JwtService } from '@nestjs/jwt';
55
export class LesserJwtService {
66
constructor(private readonly jwtService: JwtService) {}
77
createAccessToken(id: number): Promise<string> {
8-
const payload = { sub: { id }, tokenType: 'access' };
8+
const payload = { sub: { id }, tokenType: 'access', iat: Date.now() };
99
const options = { expiresIn: '15m' };
1010
return this.jwtService.signAsync(payload, options);
1111
}
1212

1313
createRefreshToken(id: number): Promise<string> {
14-
const payload = { sub: { id }, tokenType: 'refresh' };
14+
const payload = { sub: { id }, tokenType: 'refresh', iat: Date.now() };
1515
const options = { expiresIn: '1d' };
1616
return this.jwtService.signAsync(payload, options);
1717
}
1818

1919
createTempIdToken(uuid: string): Promise<string> {
20-
const payload = { sub: { uuid }, tokenType: 'tempId' };
20+
const payload = { sub: { uuid }, tokenType: 'tempId', iat: Date.now() };
2121
const options = { expiresIn: '30m' };
2222
return this.jwtService.signAsync(payload, options);
2323
}

backend/test/auth/github-signup.e2e-spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ describe('POST /api/auth/github/signup', () => {
6565
.post('/api/auth/github/authentication')
6666
.send({ authCode: 'authCode' });
6767

68-
await new Promise((resolve) => setTimeout(resolve, 1000));
6968
await request(app.getHttpServer())
7069
.post('/api/auth/github/authentication')
7170
.send({ authCode: 'authCode' });

0 commit comments

Comments
 (0)