Question

How can I do the same authentication stuff in this page using a subclass like this:

        class Configuration < HTTPServlet::AbstractServlet
        def do_GET (request, response)
            SOMETHING....
        end
        end

    server = HTTPServer.new(:Port => 666)
    server.mount "/conf", Configuration
    trap "INT" do server.shutdown end
    server.start
Was it helpful?

Solution

Seems to work OK for me if you do it in pretty much the same style e.g.

class Configuration < HTTPServlet::AbstractServlet
    def do_GET(req, res)
        HTTPAuth.basic_auth(req, res, "My Realm") {|user, pass|
          # block should return true if
          # authentication token is valid
          user == 'user' && pass == 'topsecret'
        }
        res.body = 
          "Authenticated OK\n"
    end
end

What is the problem you're having?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top