0.0
No release in over a year
Tools for authentication and authorisation with JWTs and OAuth
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.3
>= 1.4, < 3.0
 Project Readme

EPB Authentication and Authorisation Tools

This RubyGem provides a set of tools to use along with communitiesuk/epb-auth-server. There are two primary components: middleware for validating JWTs in sinatra apps, and a HTTP client that provides a mechanism for making authenticated requests.

Getting set up

Install

To install all required libs and other info, run make install.

Testing

To test the gem, run make test.

Syntax Cleanup

To ensure that all your code looks nice and conforms to the repo standards, run make format.

Sinatra Conditional Routing

The epb-auth-tools module has a sinatra conditional routing helper class.

To use this simply require epb-auth-tools and define the following in your application class.

# frozen_string_literal: true

require 'sinatra'
require 'epb-auth-tools'

class AppService < Sinatra::Base
  set(:jwt_auth) do
    condition do
      Auth::Sinatra::Conditional.process_request env
    rescue Auth::Errors::Error => e
      content_type :json
      halt 401, { error: e }.to_json
    end
  end

  get '/', jwt_auth: [] do
    content_type :json
    status 200
    { message: 'authenticated' }.to_json
  end
end