Sha256: 014839a26cdfa2007b192a396de54fc46a7e63445d16bd072b23c20b13c00cab
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# BonaFide [![Build Status](https://travis-ci.org/Tyr0/bona_fide.png?branch=master)](https://travis-ci.org/Tyr0/bona_fide) Low level Rack authentication enforcement. ## Features BonaFide was built to bring advanced middleware functionality to all Rails apps. By providing the key functions to setup user state, limit access, and redirect others, BonaFide is a simple solution to a complex problem. Essentially, BonaFide injects it's middleware just before Rails and it's routing are called, allowing it to read the current request's cookies, and call your designated model with the requested user state cookie. By setting user state before routing is called, BonaFide allows for more inteligent routing, as well as reduce request initialization code. ## Installation Install BonaFide gem ```ruby gem install bona_fide ``` Configure BonaFide settings Create initializer in `config/initializers/bona_fide.rb`: ```ruby BonaFide.configure do |config| config.base_class = User config.setter = :authenticate config.cookie_name = "user_cookie" end ``` ## Usage BonaFide provides a helper for routing via `BonaFide::Constraint` which allows for calling methods on the configured base class. For example: ```ruby ExampleApp::Applicatoin.routes.draw do # routes where User.admin? is true constraints(BonaFide::Constraint.new(:admin?)) do root to: "index#admin" end # routes where User.user? is true constraints(BonaFide::Constraint.new(:user?)) do root to: "index#user" end # fallback route root to: "index#visitor" end ``` ## License BonaFide is released under the [MIT License](http://www.opensource.org/licenses/MIT)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bona_fide-0.1.1 | README.md |
bona_fide-0.1.0 | README.md |