app-restconsole icon indicating copy to clipboard operation
app-restconsole copied to clipboard

Support for digest authentication

Open dkotvan opened this issue 13 years ago • 5 comments

Hi,

It would be very nice to have digest authentication on the client too. I need to test a few services that uses this kind of authentication.

Thanks

dkotvan avatar Aug 10 '11 16:08 dkotvan

agreed, I've been working on adding that.

ahmadnassri avatar Aug 10 '11 16:08 ahmadnassri

Seconded

ecammit avatar Sep 01 '11 18:09 ecammit

Guys, I've never used digest auth before, is there a quick and easy way to test a server side implementation of it? can you point me to some service already out there that uses it so I can test against?

thanks.

ahmadnassri avatar Sep 28 '11 00:09 ahmadnassri

Sorry, I don't know a service to test. But I wrote a simple example of a digest server in ruby using rack.

  • Install ruby and rack (if you don't is easy to find tutorials in web)
  • Create a file with the contents below and save as config.ru
  • Run rackup at command line
require "rubygems"
require "rack"

class AuthDigest
  REALM = "realm"
  OPAQUE = "opaque"
  USERNAME = "username"
  PASSWORD = "password"

  def initialize(app)
    @app = app
  end

  def call(env)
    secure_app = Rack::Auth::Digest::MD5.new(@app) do |username|
      Digest::MD5.hexdigest("#{username}:#{REALM}:#{PASSWORD}") if USERNAME == username
    end

    secure_app.realm = REALM
    secure_app.opaque = OPAQUE
    secure_app.passwords_hashed = true

    secure_app.call(env)
  end
end

App = Rack::Builder.new
  use AuthDigest

  map "/" do
    [200, {"Content-Type" => "text/plain"}, "Authenticated"]
  end
end

dkotvan avatar Nov 14 '11 20:11 dkotvan

thank you! this is exactly what I needed.

ahmadnassri avatar Nov 14 '11 22:11 ahmadnassri