This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To connect this middleware.rb file to your sinatra app | |
# add 'use JWTAuthorization' as one of your first lines in | |
# your Application class. | |
# e.g. | |
# require 'middlewares.rb' | |
# class Application < Sinatra::Base | |
# use JWTAuthorization | |
# ... | |
# end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ openssl genrsa -des3 -out private.pem 2048 | |
$ openssl rsa -in private.pem -outform PEM -pubout -out public.pem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JWT authentication middleware example. | |
// Uses RS256 strategy with .pem key pair files. | |
const fs = require('fs'); | |
const jwt = require('jsonwebtoken'); | |
module.exports = (req, res, next) => { | |
let publicKey = process.env.PUBLIC_KEY; |
NewerOlder