Sha256: 7268c746192ade677cf23669cee7a52d3306eaf0afbf7ab54c2dbaaaedceeaea

Contents?: true

Size: 688 Bytes

Versions: 12

Compression:

Stored size: 688 Bytes

Contents

require 'webrick'

include WEBrick

config = { :Realm => 'DigestAuth_REALM' }

htdigest = WEBrick::HTTPAuth::Htdigest.new 'my_password_file'
htdigest.set_passwd config[:Realm], 'digest_username', 'digest_password'
htdigest.flush

config[:UserDB] = htdigest

digest_auth = WEBrick::HTTPAuth::DigestAuth.new config

class TestServlet < HTTPServlet::AbstractServlet
  def do_GET(req, res)
    @options[0][:authenticator].authenticate req, res
    res.body = "You are authenticated to see the super secret data\n"
  end
end

s = HTTPServer.new(:Port => 3000)
s.mount('/', TestServlet, {:authenticator => digest_auth})
trap("INT") do
  File.delete('my_password_file')
  s.shutdown
end
s.start

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
em-http-request-samesite-0.1.1 examples/digest_auth/server.rb
em-http-request-samesite-1.1.7 examples/digest_auth/server.rb
em-http-request-1.1.7 examples/digest_auth/server.rb
em-http-request-1.1.6 examples/digest_auth/server.rb
em-http-request-1.1.5 examples/digest_auth/server.rb
em-http-request-1.1.4 examples/digest_auth/server.rb
em-http-request-1.1.3 examples/digest_auth/server.rb
em-http-request-1.1.2 examples/digest_auth/server.rb
z-http-request-0.2.0 examples/digest_auth/server.rb
z-http-request-0.1.0 examples/digest_auth/server.rb
em-http-request-1.1.1 examples/digest_auth/server.rb
em-http-request-1.1.0 examples/digest_auth/server.rb