File: basic_auth.ru

package info (click to toggle)
ruby-excon 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,240 kB
  • sloc: ruby: 7,970; makefile: 5
file content (14 lines) | stat: -rw-r--r-- 419 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
require File.join(File.dirname(__FILE__), 'basic')

class BasicAuth < Basic
  before do
    auth ||= Rack::Auth::Basic::Request.new(request.env)
    user, pass = auth.provided? && auth.basic? && auth.credentials
    unless [user, pass] == ["test_user", "test_password"]
      response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
      throw(:halt, [401, "Not authorized\n"])
    end
  end
end

run BasicAuth