Skip to content

Instantly share code, notes, and snippets.

View marcelobbfonseca's full-sized avatar
🎯
Focusing

Marcelo marcelobbfonseca

🎯
Focusing
View GitHub Profile
@marcelobbfonseca
marcelobbfonseca / middleware.rb
Last active September 27, 2023 02:36
Sinatra ruby JWT authentication middleware
# 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
@marcelobbfonseca
marcelobbfonseca / Terminal
Created February 22, 2019 13:51
Generate RSA key pair with OpenSSL
$ openssl genrsa -des3 -out private.pem 2048
$ openssl rsa -in private.pem -outform PEM -pubout -out public.pem
@marcelobbfonseca
marcelobbfonseca / middleware.js
Last active September 18, 2020 12:42
ExpressJS JWT authentication middleware example
// 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;