Skip to content

Commit

Permalink
fix(be): add argon2 hash options (#1700)
Browse files Browse the repository at this point in the history
* fix(be): add argon2 hash options

* chore(be): constantization argon2 hash option

---------

Co-authored-by: Jaehyeon Kim <[email protected]>
Co-authored-by: Jaehyeon Kim <[email protected]>
  • Loading branch information
3 people authored May 21, 2024
1 parent accdcd6 commit 5b11d38
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/backend/apps/client/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { generate } from 'generate-password'
import { ExtractJwt } from 'passport-jwt'
import { type AuthenticatedRequest, JwtAuthService } from '@libs/auth'
import { emailAuthenticationPinCacheKey } from '@libs/cache'
import { EMAIL_AUTH_EXPIRE_TIME } from '@libs/constants'
import { EMAIL_AUTH_EXPIRE_TIME, ARGON2_HASH_OPTION } from '@libs/constants'
import {
ConflictFoundException,
DuplicateFoundException,
Expand Down Expand Up @@ -186,7 +186,7 @@ export class UserService {
email
},
data: {
password: await hash(newPassword)
password: await hash(newPassword, ARGON2_HASH_OPTION)
}
})
this.logger.debug(user, 'updateUserPasswordInPrisma')
Expand Down Expand Up @@ -351,7 +351,7 @@ export class UserService {
}

async createUser(signUpDto: SignUpDto): Promise<User> {
const encryptedPassword = await hash(signUpDto.password)
const encryptedPassword = await hash(signUpDto.password, ARGON2_HASH_OPTION)

const user = await this.prisma.user.create({
data: {
Expand Down
5 changes: 5 additions & 0 deletions apps/backend/libs/constants/src/argon2.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const ARGON2_HASH_OPTION = {
timeCost: 2,
memoryCost: 2 ** 11,
parallelism: 1
}
1 change: 1 addition & 0 deletions apps/backend/libs/constants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './oauth.constants'
export * from './time.constants'
export * from './rabbitmq.constants'
export * from './submission.constants'
export * from './argon2.constants'

0 comments on commit 5b11d38

Please sign in to comment.