graphql-engine/community/boilerplates/auth-servers/passportjs-jwt-roles/config/jwt.js
Pilou e7fba40fad added auth-jwt-roles boilerplate (#1570)
Added a boilerplate from [this original repository](https://github.com/platyplus/authentication-server) based on the discussions in [this issue](https://github.com/hasura/graphql-engine/issues/1420) and [this issue](https://github.com/hasura/graphql-engine/issues/1446).

[skip ci]
2019-02-21 16:42:47 +05:30

15 lines
498 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var fs = require('fs')
var fnv = require('fnv-plus')
// TODO: why does rsaPemToJwk work with a file but not with a variable?
exports.key = (
process.env.AUTH_PRIVATE_KEY || fs.readFileSync('private.pem').toString()
).replace(/\\n/g, '\n')
exports.publicKey = (
process.env.AUTH_PUBLIC_KEY || fs.readFileSync('public.pem').toString()
).replace(/\\n/g, '\n')
// Key Identifier Acts as an alias for the key
exports.kid = process.env.AUTH_KEY_ID || fnv.hash(this.publicKey, 128).hex()