Giter Site home page Giter Site logo

fb-jwt-auth's Introduction

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!

fb-jwt-auth's People

Contributors

brenetic avatar tomas-stefano avatar njseeto avatar h3ll3m4 avatar chrispymm avatar mattempty avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.