How to use authentication in Sinatra?

1

What would be the best way to do authentication in applications built with Ruby / Sinatra? Devise I know it does not work. I have tried several tutorials with Warden, but the settings are very complex and confusing as I see it. Simple authentication with HTTP would be crazy. What is the best way then?

    
asked by anonymous 15.08.2014 / 05:46

1 answer

1

Apparently there is a gem 'sinatra_warden' that interfaces the warden with sinatra for you link . Example usage, from the module documentation itself:

require 'sinatra'
require 'sinatra_warden'

class Application < Sinatra::Base
  register Sinatra::Warden

  get '/admin' do
    authorize!('/login') # require session, redirect to '/login' instead of work
    haml :admin
  end

  get '/dashboard' do
    authorize! # require a session for this action
    haml :dashboard
  end
end
    
26.09.2014 / 22:48