Sha256: 9ecbdda011c34dbcf87c1f079e3bb9bda781f785da46e46e31d62a18f97fbb6a

Contents?: true

Size: 1.07 KB

Versions: 16

Compression:

Stored size: 1.07 KB

Contents

$:.unshift( "../lib" )
require 'capcode'
require 'digest/md5'

module Capcode
  OPAQUE = Digest::MD5.hexdigest( Time.now.to_s )
  http_authentication( :type => :digest, :opaque => OPAQUE, :realm => "Private part", :routes => "/noauth/private" ) { 
    {
      "greg" => "toto",
      "mu" => "maia"
    }
  }

  class Index < Route '/admin'    
    def get
      # Basic HTTP Authentication
      http_authentication( :type => :digest, :opaque => OPAQUE, :realm => "Admin part" ) { 
        {
          "greg" => "toto",
          "mu" => "maia"
        }
      }
      render "Welcome in admin part #{request.env['REMOTE_USER']}"
    end
  end 
  
  class Noauth < Route '/noauth'
    def get
      render "You don't need any special authorization here !"
    end
  end
  
  class Private < Route '/noauth/private'
    def get
      render "Welcome in the private part #{request.env['REMOTE_USER']}"
    end
  end

  class Private2 < Route '/noauth/private/again'
    def get
      render "Welcome in the private/again part #{request.env['REMOTE_USER']}"
    end
  end
  
end

Capcode.run( )

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
Capcode-1.0.0 examples/auth-digest.rb
Capcode-0.9.9 examples/auth-digest.rb
Capcode-0.9.8 examples/auth-digest.rb
Capcode-0.9.7 examples/auth-digest.rb
Capcode-0.9.6 examples/auth-digest.rb
Capcode-0.9.5 examples/auth-digest.rb
Capcode-0.9.4 examples/auth-digest.rb
Capcode-0.9.3 examples/auth-digest.rb
Capcode-0.9.2 examples/auth-digest.rb
Capcode-0.9.1 examples/auth-digest.rb
Capcode-0.9.0 examples/auth-digest.rb
Capcode-0.8.9 examples/auth-digest.rb
Capcode-0.8.8 examples/auth-digest.rb
Capcode-0.8.7 examples/auth-digest.rb
Capcode-0.8.6 examples/auth-digest.rb
Capcode-0.8.5 examples/auth-digest.rb