USPS JWT Authentication
Installation
Add the gem to your Gemfile:
gem 'usps-jwt_auth', '>= 0.0.11'
Then run the install task:
bundle exec rails usps:jwt:install
Configuration
Usps::JwtAuth.configure do |config|
config.environment = Rails.env
config.keys_path = 'config/keys'
config.public_keys_path = 'config/public_keys'
config.jwt = {
audience: ENV.fetch('JWT_AUDIENCE'),
issuer_base: ENV.fetch('JWT_ISSUER_BASE', 'usps:1'),
issuers: ENV.fetch('JWT_ISSUERS', 'admin:1').split(','),
}
end
Usage
class ApplicationController < ActionController::Base
include Usps::JwtAuth::Concern
before_action :authenticate_user_from_jwt!
# skip_before_action :authenticate_user_from_jwt!, only: %i[]
# ...
end