Skip to content

Commit

Permalink
add a constant hash secret to avoid 401 in vercel (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
portuu3 authored Aug 28, 2023
1 parent a1b21ab commit 8615c14
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/apps/job-launcher/server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RECORDING_ORACLE_ADDRESS=
REPUTATION_ORACLE_ADDRESS=

# Auth
HASH_SECRET=a328af3fc1dad15342cc3d68936008fa
JWT_SECRET=test-secret
JWT_ACCESS_TOKEN_EXPIRES_IN=1d
JWT_REFRESH_TOKEN_EXPIRES_IN=1d
Expand Down
4 changes: 3 additions & 1 deletion packages/apps/job-launcher/server/src/common/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const ConfigNames = {
PORT: 'PORT',
FE_URL: 'FE_URL',
SESSION_SECRET: 'SESSION_SECRET',
HASH_SECRET: 'HASH_SECRET',
JWT_SECRET: 'JWT_SECRET',
JWT_ACCESS_TOKEN_EXPIRES_IN: 'JWT_ACCESS_TOKEN_EXPIRES_IN',
JWT_REFRESH_TOKEN_EXPIRES_IN: 'JWT_REFRESH_TOKEN_EXPIRES_IN',
Expand Down Expand Up @@ -52,7 +53,8 @@ export const envValidator = Joi.object({
FE_URL: Joi.string().default('http://localhost:3005'),
SESSION_SECRET: Joi.string().default('session_key'),
// Auth
JWT_SECRET: Joi.string().default('secrete'),
HASH_SECRET: Joi.string().default('a328af3fc1dad15342cc3d68936008fa'),
JWT_SECRET: Joi.string().default('secret'),
JWT_ACCESS_TOKEN_EXPIRES_IN: Joi.string().default(1000000000),
JWT_REFRESH_TOKEN_EXPIRES_IN: Joi.string().default(1000000000),
// Database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { TokenRepository } from './token.repository';
import { AuthRepository } from './auth.repository';
import { ConfigNames } from '../../common/config';
import { ConfigService } from '@nestjs/config';
import { createHash, randomBytes } from 'crypto';
import { createHash } from 'crypto';
import { SendGridService } from '../sendgrid/sendgrid.service';

@Injectable()
Expand All @@ -47,7 +47,10 @@ export class AuthService {
'100000000',
);

this.salt = randomBytes(16).toString('hex');
this.salt = this.configService.get<string>(
ConfigNames.HASH_SECRET,
'a328af3fc1dad15342cc3d68936008fa',
);
this.feURL = this.configService.get<string>(
ConfigNames.FE_URL,
'http://localhost:3005',
Expand Down

1 comment on commit 8615c14

@vercel
Copy link

@vercel vercel bot commented on 8615c14 Aug 28, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

job-launcher-server – ./packages/apps/job-launcher/server

job-launcher-server-git-develop-humanprotocol.vercel.app
job-launcher-server-humanprotocol.vercel.app
job-launcher-server-nine.vercel.app

Please sign in to comment.