a little sinatra gem that implements user authentication I have no idea why I even branched this of the database version, it is much simpler and only works with rpxnow.com - you must setup an account and setup the options, see included test.rb for minimal app.
INSTALLATION:
in your sinatra app simply include “sinatra-authentication” and turn on session storage with a super secret key, like so:
require "sinatra-authentication" use Rack::Session::Cookie, :secret => 'A1 sauce 1s so good you should use 1t on a11 yr st34ksssss'
DEFAULT ROUTES
-
post ‘/login’
-
get ‘/login’ nothing really just there as a place holder
-
get ‘/logout’ not even required but it logs you out
HELPER METHODS
This plugin provides the following helper methods for your sinatra app:
-
login_required
which you place at the beginning of any routes you want to be protected
-
priv_required
same as above but requiring a specific role
-
current_user
-
logged_in?
-
render_login_logout(html_attributes)
renders a link to the open ID (rpxnow.com) widget
-
render_js
renders the required javascript, included with the link render
SIMPLE PERMISSIONS
just a hash of ‘displayName’ and ‘permision string’ will work on something suitable later
EXAMPLE
test.rb is a minimal sinatra test app to illustrate usage