Sha256: 3e876bf9444df1ec3690ee6de7e1861c9f7cdfb571adc4e12b08bc95997c153c

Contents?: true

Size: 449 Bytes

Versions: 2

Compression:

Stored size: 449 Bytes

Contents

require 'sinatra'
require 'sinatra/pundit'

use Rack::Auth::Basic, "Restricted Area" do |username, password|
  %w(admin member).include?(username)
end

configure do
  set :show_exceptions, :after_handler
  error Pundit::NotAuthorizedError do
    status 403
    body "Forbidden"
  end
end

current_user do
  request.env['REMOTE_USER']
end

get '/' do
  "Hello World!"
end

get '/admin' do
  authorize :example, :access?
  "Restricted Admin Area"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sinatra-pundit-0.2.0 example/app.rb
sinatra-pundit-0.1.0 example/app.rb