This repository was archived by the owner on May 17, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,19 @@ const jsonParser = require('body-parser').json()
1818app . use ( jsonParser )
1919
2020const DEFAULT_ENVIRONMENT = 'multi-mega'
21+ const JWT_ENABLED = process . env . NODE_ENV !== 'development'
2122
2223/**
2324 * Secret for JSON web tokens.
2425 */
25- let JWT_SECRET = process . env . JWT_SECRET
26- if ( ! JWT_SECRET ) {
27- if ( process . env . NODE_ENV === 'development' ) JWT_SECRET = 'not-a-secret'
28- else throw Error ( 'JWT_SECRET must be set' )
29- }
26+ if ( JWT_ENABLED ) {
27+ const JWT_SECRET = process . env . JWT_SECRET
28+ if ( ! JWT_SECRET ) {
29+ throw Error ( 'JWT_SECRET must be set' )
30+ }
3031
31- app . use ( jwt ( { secret : JWT_SECRET } ) )
32+ app . use ( jwt ( { secret : JWT_SECRET } ) )
33+ }
3234
3335/**
3436 * Validates that all the `requiredParameters` are properties of `body`.
@@ -100,6 +102,12 @@ function doRequestValidation (request: express.Request, response: express.Respon
100102 * @param expectedContainerId
101103 */
102104function getJwtData ( request : express . Request , response : express . Response , expectedContainerId : string | null = null ) : any {
105+ if ( ! JWT_ENABLED ) {
106+ return {
107+ 'cid' : expectedContainerId
108+ }
109+ }
110+
103111 // @ts -ignore
104112 const jwtData : any = request . user
105113
You can’t perform that action at this time.
0 commit comments