Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
feat(jwt-cert): add cert to process.env
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouncey committed Apr 24, 2018
1 parent 06125f6 commit 1dd4779
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions graphql/resolvers/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import { AuthorizationError } from '../errors';
import { asyncErrorHandler } from '../../utils';

const log = debug('fcc:resolvers:directives');
const certPath = process.cwd() + '/public.pem';
const cert = fs.readFileSync(certPath);
const {
NODE_ENV,
STAGING_JWT_CERT: stagingCert,
PRODUCTION_JWT_CERT: productionCert
} = process.env;

const cert = NODE_ENV !== 'production' ? stagingCert : productionCert;

function verifyWebToken(ctx) {
const token = ctx.headers.authorization;
Expand Down
4 changes: 3 additions & 1 deletion sample.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
MONGODB_URL='mongodb://foo:bar@baz:41019/quuz'
GRAPHQL_ENDPOINT_URL='/graphql'
GRAPHQL_ENDPOINT_URL='/graphql'
STAGING_JWT_CERT="-----BEGIN CERTIFICATE-----\n needs to be wrapped in double quotes \n with new lines escaped \n-----END CERTIFICATE-----"
PRODUCTION_JWT_CERT="-----BEGIN CERTIFICATE-----\n needs to be wrapped in double quotes \n with new lines escaped \n-----END CERTIFICATE-----"

0 comments on commit 1dd4779

Please sign in to comment.