diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-02-07 00:08:28 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-02-07 00:08:28 -0600 |
commit | 2277fbedbea930fb8ce38ab7eb133de6fcc4a2d6 (patch) | |
tree | 784f2dfcd066eaa17a89cc435ec4de44393799c8 /actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract | |
parent | 24f2e676f700b8a387c6f4c27acf172658cd7863 (diff) | |
download | rails-2277fbedbea930fb8ce38ab7eb133de6fcc4a2d6.tar.gz rails-2277fbedbea930fb8ce38ab7eb133de6fcc4a2d6.tar.bz2 rails-2277fbedbea930fb8ce38ab7eb133de6fcc4a2d6.zip |
Temporarily bundle Rack 1.0 prerelease for testing
Diffstat (limited to 'actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract')
-rw-r--r-- | actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb | 28 | ||||
-rw-r--r-- | actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb | 37 |
2 files changed, 65 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb new file mode 100644 index 0000000000..b213eac6f4 --- /dev/null +++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb @@ -0,0 +1,28 @@ +module Rack + module Auth + # Rack::Auth::AbstractHandler implements common authentication functionality. + # + # +realm+ should be set for all handlers. + + class AbstractHandler + + attr_accessor :realm + + def initialize(app, &authenticator) + @app, @authenticator = app, authenticator + end + + + private + + def unauthorized(www_authenticate = challenge) + return [ 401, { 'WWW-Authenticate' => www_authenticate.to_s }, [] ] + end + + def bad_request + [ 400, {}, [] ] + end + + end + end +end diff --git a/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb b/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb new file mode 100644 index 0000000000..1d9ccec685 --- /dev/null +++ b/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb @@ -0,0 +1,37 @@ +module Rack + module Auth + class AbstractRequest + + def initialize(env) + @env = env + end + + def provided? + !authorization_key.nil? + end + + def parts + @parts ||= @env[authorization_key].split(' ', 2) + end + + def scheme + @scheme ||= parts.first.downcase.to_sym + end + + def params + @params ||= parts.last + end + + + private + + AUTHORIZATION_KEYS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION'] + + def authorization_key + @authorization_key ||= AUTHORIZATION_KEYS.detect { |key| @env.has_key?(key) } + end + + end + + end +end |