Skip to content

Instantly share code, notes, and snippets.

@travist
Created August 3, 2017 13:35
Show Gist options
  • Save travist/cc3509423c2eda7d37abce53349d268d to your computer and use it in GitHub Desktop.
Save travist/cc3509423c2eda7d37abce53349d268d to your computer and use it in GitHub Desktop.
Form.io External JWT Token Generation
/**
* This code does require our Docker deployment where the "JWT_SECRET" would be the
* same secret of the environment variable when the docker is spun up.
*/
var jwt = require('jsonwebtoken');
var token = jwt.sign({
external: true,
form: {
_id: '59795d259be16e3ee58fddaa',
project: '59795d259be16e3ee58fdda6'
},
user: {
_id: 'external',
roles: [
'59795d259be16e3ee58fdda7'
]
}
}, 'JWT_SECRET');
console.log(token);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment