Skip to content

A sinatra extension wrapped in a gem that implements authentication/permissions with openid

Notifications You must be signed in to change notification settings

rwboyer/sinatra-authentication

 
 

Repository files navigation

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

About

A sinatra extension wrapped in a gem that implements authentication/permissions with openid

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%