0.0
Low commit activity in last 3 years
No release in over a year
JWT authentication done in all apps in form builder
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Fb::Jwt::Auth

Installation

Add this line to your application's Gemfile:

gem 'fb-jwt-auth'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install fb-jwt-auth

Usage

Fb::Jwt::Auth.configure do |config|
  # Service token cache domain
  #
  config.service_token_cache_root_url = ENV['SERVICE_TOKEN_CACHE_ROOT_URL']
end

In order to generate the service access token we need to use Fb::Jwt::Auth::ServiceAccessToken.new.generate or if you require a subject, Fb::Jwt::Auth::ServiceAccessToken.new(subject: subject).generate

In the case you need to configure the service access token as a client

Fb::Jwt::Auth.configure do |config|
  config.issuer = 'fb-editor'
  config.namespace = 'formbuilder-saas-test'
  config.encoded_private_key = 'base64 encoded private key'
end

Using other endpoint versions

Service token cache can have different versions of authenticating a service.

You can configure the version:

Fb::Jwt::Auth.configure do |config|
  config.service_token_cache_api_version = :v3
end

Verifying the token

Fb::Jwt::Auth.new(
  access_token: request.headers['x-access-token-v2'],
  key: 'fb-editor', # service name
  leeway: ENV['MAX_IAT_SKEW_SECONDS'],
  logger: Rails.logger
).verify!