Project

cerber

0.0
No commit activity in last 3 years
No release in over 3 years
A collection of easily plugable rack authentication middlewares
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0

Runtime

= 2.1.0
 Project Readme

Cerberus

This gem provides various authentication middlewares.

At the moment there are two:

  • Cerberus::Jwt
  • Cerberus::Basic

Installation

Add this line to your application's Gemfile:

gem "cerber", require: "cerberus"

And then execute:

$ bundle

Or install it yourself as:

$ gem install cerber

Usage

Configure Cerberus with required information:

require "cerberus"

Cerberus.configure do |config|
  config.jwt = {
    rsa_public: ENV["JWT_RSA_PUBLIC"],
    algorithm: "RS256",
    issuer: "org.website.project",
    enabled: ->(env) { Rails.env.production? }
  }.freeze

  config.basic = {
    username_digest: ::Digest::SHA256.hexdigest("test"),
    password_digest: ::Digest::SHA256.hexdigest("test"),
    enabled: ->(env) { env["PATH_INFO"].start_with?("/protected") }
  }.freeze
end

require "cerberus/jwt"
require "cerberus/basic"

And then just inject a middleware:

config.middleware.use Cerberus::Jwt
config.middleware.use Cerberus::Basic

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/krzyczak/cerberus.

License

The gem is available as open source under the terms of the MIT License.