Skip to content
Snippets Groups Projects
Commit a1ba253d authored by Matt Kirby's avatar Matt Kirby
Browse files

jwt now an env variable instead of hard-coded

parent 4567d19a
No related branches found
No related tags found
1 merge request!31Implement Mongo Seeder v2
This commit is part of merge request !31. Comments created here will be created in the context of that merge request.
......@@ -2,7 +2,7 @@ import jwt, { Secret, JwtPayload } from 'jsonwebtoken';
import { Request, Response, NextFunction } from 'express';
import Config from '../../config'
export const SECRET_KEY: Secret = Config.JWT_SECRET;
export const SECRET_KEY: Secret = process.env.JWT_PRIVATE_KEY || "";
export interface CustomJWTRequest extends Request {
token?: string | JwtPayload | TokenData;
......
......@@ -2,7 +2,7 @@ import jwt, { Secret, JwtPayload } from 'jsonwebtoken';
import { Request, Response, NextFunction } from 'express';
import Config from '../../config'
export const SECRET_KEY: Secret = Config.JWT_SECRET;
export const SECRET_KEY: Secret = process.env.JWT_PRIVATE_KEY || "" ;
export interface CustomJWTRequest extends Request {
token?: string | JwtPayload | TokenData;
......
......@@ -6,7 +6,7 @@ export default async function Auth(req, res, next){
const token = req.headers.authorization.split(" ")[1];
const decodedToken = await jwt.verify(token, ENV.JWT_SECRET);
const decodedToken = await jwt.verify(token, process.env.JWT_PRIVATE_KEY);
req.user = decodedToken;
next();
......
......@@ -31,6 +31,7 @@ services:
- "9000"
environment:
- MONGO_URI=mongodb://user-mongo:27017/userdb
- JWT_PRIVATE_KEY=yB/uX5KdyjHN9P34IE49HxAcrlQ4gfvpVJEzGbo5E/I=
- ENABLE_USER_DB_SEEDING=true
friend-service:
......@@ -44,6 +45,7 @@ services:
- MONGO_HOST=friend-mongo
- MONGO_PORT=27017
- MONGO_DBNAME=friends
- JWT_PRIVATE_KEY=yB/uX5KdyjHN9P34IE49HxAcrlQ4gfvpVJEzGbo5E/I=
comment-service:
build:
......@@ -56,6 +58,7 @@ services:
- MONGO_HOST=comment-mongo
- MONGO_PORT=27017
- MONGO_DBNAME=comments
- JWT_PRIVATE_KEY=yB/uX5KdyjHN9P34IE49HxAcrlQ4gfvpVJEzGbo5E/I=
frontend-service:
build:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment