Ruby Webrick HTTP Authentication

How can I do the same authentication stuff into 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 
0
source share
1 answer

It seems like I'm working fine if you do it in roughly the same style, for example.

 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 are facing?

+1
source

Source: https://habr.com/ru/post/901556/


All Articles