Sha256: 7aacaa27582e57fb3b0756092fa9f1763f357fc9cdf5e3555c84882f45fb77d2

Contents?: true

Size: 548 Bytes

Versions: 10

Compression:

Stored size: 548 Bytes

Contents

require 'rubygems'
require 'ramaze'

class MainController < Ramaze::Controller
  LOGINS = {
   :username => 'password',
   :admin => 'secret'
  }.map{|k,v| ["#{k}:#{v}"].pack('m').strip} unless defined? LOGINS

  helper :aspect

  before_all do
    response['WWW-Authenticate'] = %(Basic realm="Login Required")
    respond 'Unauthorized', 401 unless auth = request.env['HTTP_AUTHORIZATION'] and
                                       LOGINS.include? auth.split.last
  end

  def index
    'Secret Info'
  end
end

Ramaze.start :adapter => :mongrel

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
clivecrous-ramaze-0.3.9.5 examples/simple_auth.rb
manveru-ramaze-2008.07 examples/misc/simple_auth.rb
manveru-ramaze-2008.08 examples/misc/simple_auth.rb
ramaze-0.3.5 examples/simple_auth.rb
ramaze-0.2.1 examples/simple_auth.rb
ramaze-0.2.0 examples/simple_auth.rb
ramaze-0.3.0 examples/simple_auth.rb
ramaze-2008.06 examples/misc/simple_auth.rb
ramaze-0.3.9.1 examples/simple_auth.rb
ramaze-0.3.9 examples/simple_auth.rb