$91 GRAYBYTE WORDPRESS FILE MANAGER $19

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.36
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/ruby19/lib64/ruby/1.9.1/webrick/

HOME
Current File : /opt/alt/ruby19/lib64/ruby/1.9.1/webrick//httpauth.rb
#
# httpauth.rb -- HTTP access authentication
#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
#
# $IPR: httpauth.rb,v 1.14 2003/07/22 19:20:42 gotoyuzo Exp $

require 'webrick/httpauth/basicauth'
require 'webrick/httpauth/digestauth'
require 'webrick/httpauth/htpasswd'
require 'webrick/httpauth/htdigest'
require 'webrick/httpauth/htgroup'

module WEBrick

  ##
  # HTTPAuth provides both basic and digest authentication.
  #
  # To enable authentication for requests in WEBrick you will need a user
  # database and an authenticator.  To start, here's an Htpasswd database for
  # use with a DigestAuth authenticator:
  #
  #   config = { :Realm => 'DigestAuth example realm' }
  #
  #   htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file'
  #   htpasswd.auth_type = WEBrick::HTTPAuth::DigestAuth
  #   htpasswd.set_passwd config[:Realm], 'username', 'password'
  #   htpasswd.flush
  #
  # The +:Realm+ is used to provide different access to different groups
  # across several resources on a server.  Typically you'll need only one
  # realm for a server.
  #
  # This database can be used to create an authenticator:
  #
  #   config[:UserDB] = htpasswd
  #
  #   digest_auth = WEBrick::HTTPAuth::DigestAuth.new config
  #
  # To authenticate a request call #authenticate with a request and response
  # object in a servlet:
  #
  #   def do_GET req, res
  #     @authenticator.authenticate req, res
  #   end
  #
  # For digest authentication the authenticator must not be created every
  # request, it must be passed in as an option via WEBrick::HTTPServer#mount.

  module HTTPAuth
    module_function

    def _basic_auth(req, res, realm, req_field, res_field, err_type,
                    block) # :nodoc:
      user = pass = nil
      if /^Basic\s+(.*)/o =~ req[req_field]
        userpass = $1
        user, pass = userpass.unpack("m*")[0].split(":", 2)
      end
      if block.call(user, pass)
        req.user = user
        return
      end
      res[res_field] = "Basic realm=\"#{realm}\""
      raise err_type
    end

    ##
    # Simple wrapper for providing basic authentication for a request.  When
    # called with a request +req+, response +res+, authentication +realm+ and
    # +block+ the block will be called with a +username+ and +password+.  If
    # the block returns true the request is allowed to continue, otherwise an
    # HTTPStatus::Unauthorized error is raised.

    def basic_auth(req, res, realm, &block) # :yield: username, password
      _basic_auth(req, res, realm, "Authorization", "WWW-Authenticate",
                  HTTPStatus::Unauthorized, block)
    end

    ##
    # Simple wrapper for providing basic authentication for a proxied request.
    # When called with a request +req+, response +res+, authentication +realm+
    # and +block+ the block will be called with a +username+ and +password+.
    # If the block returns true the request is allowed to continue, otherwise
    # an HTTPStatus::ProxyAuthenticationRequired error is raised.

    def proxy_basic_auth(req, res, realm, &block) # :yield: username, password
      _basic_auth(req, res, realm, "Proxy-Authorization", "Proxy-Authenticate",
                  HTTPStatus::ProxyAuthenticationRequired, block)
    end
  end
end


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
3 Mar 2024 10.50 PM
root / root
0755
httpauth
--
3 Mar 2024 10.48 PM
root / linksafe
0755
httpservlet
--
3 Mar 2024 10.48 PM
root / linksafe
0755
accesslog.rb
4.158 KB
23 Jun 2011 7.22 AM
root / linksafe
0644
cgi.rb
6.902 KB
8 Nov 2010 8.59 PM
root / linksafe
0644
compat.rb
0.891 KB
17 May 2011 8.29 PM
root / linksafe
0644
config.rb
4.38 KB
11 Sep 2010 6.21 AM
root / linksafe
0644
cookie.rb
3.032 KB
20 Jun 2011 6.48 AM
root / linksafe
0644
htmlutils.rb
0.69 KB
14 Feb 2014 4.24 AM
root / linksafe
0644
httpauth.rb
3.327 KB
10 May 2011 11.37 PM
root / linksafe
0644
httpproxy.rb
8.854 KB
10 May 2011 12.13 AM
root / linksafe
0644
httprequest.rb
12.675 KB
22 Jul 2011 12.49 PM
root / linksafe
0644
httpresponse.rb
9.495 KB
21 Jun 2011 12.58 PM
root / linksafe
0644
https.rb
1.61 KB
29 May 2011 2.14 PM
root / linksafe
0644
httpserver.rb
7.212 KB
10 May 2011 12.13 AM
root / linksafe
0644
httpservlet.rb
0.653 KB
2 Oct 2009 10.45 AM
root / linksafe
0644
httpstatus.rb
4.946 KB
16 Jun 2011 9.12 PM
root / linksafe
0644
httputils.rb
10.278 KB
14 Feb 2014 4.24 AM
root / linksafe
0644
httpversion.rb
1.117 KB
9 May 2011 7.22 PM
root / linksafe
0644
log.rb
3.599 KB
16 Jun 2011 9.12 PM
root / linksafe
0644
server.rb
5.757 KB
10 May 2011 12.13 AM
root / linksafe
0644
ssl.rb
4.23 KB
30 Jul 2010 11.26 PM
root / linksafe
0644
utils.rb
6.232 KB
19 May 2012 5.40 AM
root / linksafe
0644
version.rb
0.345 KB
9 May 2011 7.22 PM
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF