Sha256: 00b284020e5a54d05aa5b1f4cd4eca1d44ad75410df65c7f7804c9e86a626414

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'rubygems'
require 'ramaze'

REALM = 'ramaze authentication required'

class MainController < Ramaze::Controller
  def index
    %|
    <p><a href="#{R(SecretController,'/')}">secret area</a></p>
    <p><a href="#{R(GuestController,'/')}">guest area</a> password must be the same as username</p>
     | 
  end
end

class SecretController < Ramaze::Controller
  map '/secret'
  helper :aspect
  helper :httpdigest

  before_all do
    @username = httpdigest 'secret area', REALM do |username|
      { 'admin' => MD5.new("admin:#{REALM}:secret"),
        'root' => MD5.new("root:#{REALM}:access"),
      }[ username ]
    end
  end

  def index
    "Hello <em>#@username</em>, welcome to SECRET world"
  end
end

class GuestController < Ramaze::Controller
  map '/guest'
  helper :aspect
  helper :httpdigest

  before_all do
    @username = httpdigest('guest area',REALM) do |username|
      username_used = username
      MD5.new("#{username}:#{REALM}:#{username}")
    end
  end

  def index
    "Hello <em>#@username</em>, welcome to GUEST world."
  end
end

Ramaze.start

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clivecrous-ramaze-0.3.9.5 examples/httpdigest.rb