passenger 2.2.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (160) hide show
  1. data/NEWS +40 -0
  2. data/Rakefile +1 -1
  3. data/bin/passenger-install-apache2-module +1 -0
  4. data/bin/passenger-install-nginx-module +2 -0
  5. data/doc/Architectural overview.html +173 -138
  6. data/doc/Security of user switching support.html +147 -109
  7. data/doc/Users guide Apache.html +4 -43
  8. data/doc/Users guide Nginx.html +4 -43
  9. data/doc/cxxapi/Bucket_8h-source.html +1 -1
  10. data/doc/cxxapi/Configuration_8h-source.html +1 -1
  11. data/doc/cxxapi/DirectoryMapper_8h-source.html +1 -1
  12. data/doc/cxxapi/Hooks_8h-source.html +1 -1
  13. data/doc/cxxapi/annotated.html +1 -1
  14. data/doc/cxxapi/classHooks-members.html +1 -1
  15. data/doc/cxxapi/classHooks.html +1 -1
  16. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +1 -1
  17. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +1 -1
  18. data/doc/cxxapi/classes.html +1 -1
  19. data/doc/cxxapi/definitions_8h-source.html +1 -1
  20. data/doc/cxxapi/files.html +1 -1
  21. data/doc/cxxapi/functions.html +1 -1
  22. data/doc/cxxapi/functions_func.html +1 -1
  23. data/doc/cxxapi/graph_legend.html +1 -1
  24. data/doc/cxxapi/group__Configuration.html +1 -1
  25. data/doc/cxxapi/group__Core.html +1 -1
  26. data/doc/cxxapi/group__Hooks.html +1 -1
  27. data/doc/cxxapi/group__Support.html +1 -1
  28. data/doc/cxxapi/main.html +1 -1
  29. data/doc/cxxapi/modules.html +1 -1
  30. data/doc/rdoc/classes/GC.html +4 -4
  31. data/doc/rdoc/classes/PhusionPassenger.html +2 -1
  32. data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +8 -8
  33. data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +26 -26
  34. data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +98 -98
  35. data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +61 -61
  36. data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +4 -4
  37. data/doc/rdoc/classes/PhusionPassenger/Application.html +14 -14
  38. data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +12 -12
  39. data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +4 -4
  40. data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +12 -12
  41. data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +5 -5
  42. data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +42 -42
  43. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +33 -33
  44. data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +59 -59
  45. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +3 -3
  46. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +7 -7
  47. data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +23 -23
  48. data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +4 -4
  49. data/doc/rdoc/classes/PhusionPassenger/Utils.html +2 -0
  50. data/doc/rdoc/classes/PhusionPassenger/Utils/PseudoIO.html +16 -16
  51. data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +4 -4
  52. data/doc/rdoc/classes/PlatformInfo.html +1 -1
  53. data/doc/rdoc/classes/Signal.html +23 -15
  54. data/doc/rdoc/created.rid +1 -1
  55. data/doc/rdoc/files/DEVELOPERS_TXT.html +1 -1
  56. data/doc/rdoc/files/README.html +1 -1
  57. data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +1 -1
  58. data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +1 -1
  59. data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +1 -1
  60. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +1 -1
  61. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +1 -1
  62. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +1 -1
  63. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +1 -1
  64. data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +1 -1
  65. data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +1 -1
  66. data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +1 -1
  67. data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +1 -1
  68. data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +1 -1
  69. data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +1 -1
  70. data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +1 -1
  71. data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +1 -1
  72. data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +1 -1
  73. data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +1 -1
  74. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +2 -2
  75. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +2 -2
  76. data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +1 -1
  77. data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +1 -1
  78. data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +1 -1
  79. data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +1 -1
  80. data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +1 -1
  81. data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +1 -1
  82. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +9 -9
  83. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +1 -1
  84. data/doc/rdoc/files/misc/rake/extensions_rb.html +1 -1
  85. data/doc/rdoc/fr_class_index.html +2 -0
  86. data/doc/rdoc/fr_file_index.html +1 -0
  87. data/doc/rdoc/fr_method_index.html +79 -72
  88. data/ext/apache2/Hooks.cpp +4 -2
  89. data/ext/common/StandardApplicationPool.h +4 -2
  90. data/ext/common/Version.h +1 -1
  91. data/ext/nginx/Configuration.c +1 -1
  92. data/ext/oxt/system_calls.cpp +11 -0
  93. data/ext/oxt/system_calls.hpp +2 -1
  94. data/ext/oxt/thread.hpp +97 -1
  95. data/lib/phusion_passenger/constants.rb +1 -1
  96. data/lib/phusion_passenger/dependencies.rb +32 -0
  97. data/lib/phusion_passenger/platform_info.rb +1 -1
  98. data/lib/phusion_passenger/rack/application_spawner.rb +4 -4
  99. data/lib/phusion_passenger/rack/request_handler.rb +2 -5
  100. data/lib/phusion_passenger/railz/application_spawner.rb +13 -2
  101. data/lib/phusion_passenger/utils.rb +12 -4
  102. data/{vendor/rack-1.0.0-git/lib/rack → lib/phusion_passenger/utils}/rewindable_input.rb +19 -3
  103. data/test/ApplicationPoolTest.cpp +1 -1
  104. metadata +13 -59
  105. data/vendor/README +0 -13
  106. data/vendor/README_FOR_PACKAGERS +0 -1
  107. data/vendor/rack-1.0.0-git/COPYING +0 -18
  108. data/vendor/rack-1.0.0-git/KNOWN-ISSUES +0 -18
  109. data/vendor/rack-1.0.0-git/README +0 -353
  110. data/vendor/rack-1.0.0-git/Rakefile +0 -164
  111. data/vendor/rack-1.0.0-git/lib/rack.rb +0 -90
  112. data/vendor/rack-1.0.0-git/lib/rack/adapter/camping.rb +0 -22
  113. data/vendor/rack-1.0.0-git/lib/rack/auth/abstract/handler.rb +0 -37
  114. data/vendor/rack-1.0.0-git/lib/rack/auth/abstract/request.rb +0 -37
  115. data/vendor/rack-1.0.0-git/lib/rack/auth/basic.rb +0 -58
  116. data/vendor/rack-1.0.0-git/lib/rack/auth/digest/md5.rb +0 -124
  117. data/vendor/rack-1.0.0-git/lib/rack/auth/digest/nonce.rb +0 -51
  118. data/vendor/rack-1.0.0-git/lib/rack/auth/digest/params.rb +0 -55
  119. data/vendor/rack-1.0.0-git/lib/rack/auth/digest/request.rb +0 -40
  120. data/vendor/rack-1.0.0-git/lib/rack/auth/openid.rb +0 -487
  121. data/vendor/rack-1.0.0-git/lib/rack/builder.rb +0 -63
  122. data/vendor/rack-1.0.0-git/lib/rack/cascade.rb +0 -41
  123. data/vendor/rack-1.0.0-git/lib/rack/chunked.rb +0 -49
  124. data/vendor/rack-1.0.0-git/lib/rack/commonlogger.rb +0 -52
  125. data/vendor/rack-1.0.0-git/lib/rack/conditionalget.rb +0 -47
  126. data/vendor/rack-1.0.0-git/lib/rack/content_length.rb +0 -29
  127. data/vendor/rack-1.0.0-git/lib/rack/content_type.rb +0 -23
  128. data/vendor/rack-1.0.0-git/lib/rack/deflater.rb +0 -96
  129. data/vendor/rack-1.0.0-git/lib/rack/directory.rb +0 -153
  130. data/vendor/rack-1.0.0-git/lib/rack/file.rb +0 -88
  131. data/vendor/rack-1.0.0-git/lib/rack/handler.rb +0 -69
  132. data/vendor/rack-1.0.0-git/lib/rack/handler/cgi.rb +0 -61
  133. data/vendor/rack-1.0.0-git/lib/rack/handler/evented_mongrel.rb +0 -8
  134. data/vendor/rack-1.0.0-git/lib/rack/handler/fastcgi.rb +0 -88
  135. data/vendor/rack-1.0.0-git/lib/rack/handler/lsws.rb +0 -55
  136. data/vendor/rack-1.0.0-git/lib/rack/handler/mongrel.rb +0 -84
  137. data/vendor/rack-1.0.0-git/lib/rack/handler/scgi.rb +0 -59
  138. data/vendor/rack-1.0.0-git/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
  139. data/vendor/rack-1.0.0-git/lib/rack/handler/thin.rb +0 -18
  140. data/vendor/rack-1.0.0-git/lib/rack/handler/webrick.rb +0 -67
  141. data/vendor/rack-1.0.0-git/lib/rack/head.rb +0 -19
  142. data/vendor/rack-1.0.0-git/lib/rack/lint.rb +0 -537
  143. data/vendor/rack-1.0.0-git/lib/rack/lobster.rb +0 -65
  144. data/vendor/rack-1.0.0-git/lib/rack/lock.rb +0 -16
  145. data/vendor/rack-1.0.0-git/lib/rack/methodoverride.rb +0 -27
  146. data/vendor/rack-1.0.0-git/lib/rack/mime.rb +0 -204
  147. data/vendor/rack-1.0.0-git/lib/rack/mock.rb +0 -184
  148. data/vendor/rack-1.0.0-git/lib/rack/recursive.rb +0 -57
  149. data/vendor/rack-1.0.0-git/lib/rack/reloader.rb +0 -106
  150. data/vendor/rack-1.0.0-git/lib/rack/request.rb +0 -248
  151. data/vendor/rack-1.0.0-git/lib/rack/response.rb +0 -183
  152. data/vendor/rack-1.0.0-git/lib/rack/session/abstract/id.rb +0 -142
  153. data/vendor/rack-1.0.0-git/lib/rack/session/cookie.rb +0 -91
  154. data/vendor/rack-1.0.0-git/lib/rack/session/memcache.rb +0 -109
  155. data/vendor/rack-1.0.0-git/lib/rack/session/pool.rb +0 -100
  156. data/vendor/rack-1.0.0-git/lib/rack/showexceptions.rb +0 -349
  157. data/vendor/rack-1.0.0-git/lib/rack/showstatus.rb +0 -106
  158. data/vendor/rack-1.0.0-git/lib/rack/static.rb +0 -38
  159. data/vendor/rack-1.0.0-git/lib/rack/urlmap.rb +0 -55
  160. data/vendor/rack-1.0.0-git/lib/rack/utils.rb +0 -522
@@ -1,90 +0,0 @@
1
- # Copyright (C) 2007, 2008, 2009 Christian Neukirchen <purl.org/net/chneukirchen>
2
- #
3
- # Rack is freely distributable under the terms of an MIT-style license.
4
- # See COPYING or http://www.opensource.org/licenses/mit-license.php.
5
-
6
- path = File.expand_path(File.dirname(__FILE__))
7
- $:.unshift(path) unless $:.include?(path)
8
-
9
-
10
- # The Rack main module, serving as a namespace for all core Rack
11
- # modules and classes.
12
- #
13
- # All modules meant for use in your application are <tt>autoload</tt>ed here,
14
- # so it should be enough just to <tt>require rack.rb</tt> in your code.
15
-
16
- module Rack
17
- # The Rack protocol version number implemented.
18
- VERSION = [1,0]
19
-
20
- # Return the Rack protocol version as a dotted string.
21
- def self.version
22
- VERSION.join(".")
23
- end
24
-
25
- # Return the Rack release as a dotted string.
26
- def self.release
27
- "1.0"
28
- end
29
-
30
- autoload :Builder, "rack/builder"
31
- autoload :Cascade, "rack/cascade"
32
- autoload :Chunked, "rack/chunked"
33
- autoload :CommonLogger, "rack/commonlogger"
34
- autoload :ConditionalGet, "rack/conditionalget"
35
- autoload :ContentLength, "rack/content_length"
36
- autoload :ContentType, "rack/content_type"
37
- autoload :File, "rack/file"
38
- autoload :Deflater, "rack/deflater"
39
- autoload :Directory, "rack/directory"
40
- autoload :ForwardRequest, "rack/recursive"
41
- autoload :Handler, "rack/handler"
42
- autoload :Head, "rack/head"
43
- autoload :Lint, "rack/lint"
44
- autoload :Lock, "rack/lock"
45
- autoload :MethodOverride, "rack/methodoverride"
46
- autoload :Mime, "rack/mime"
47
- autoload :Recursive, "rack/recursive"
48
- autoload :Reloader, "rack/reloader"
49
- autoload :ShowExceptions, "rack/showexceptions"
50
- autoload :ShowStatus, "rack/showstatus"
51
- autoload :Static, "rack/static"
52
- autoload :URLMap, "rack/urlmap"
53
- autoload :Utils, "rack/utils"
54
-
55
- autoload :MockRequest, "rack/mock"
56
- autoload :MockResponse, "rack/mock"
57
-
58
- autoload :Request, "rack/request"
59
- autoload :Response, "rack/response"
60
-
61
- module Auth
62
- autoload :Basic, "rack/auth/basic"
63
- autoload :AbstractRequest, "rack/auth/abstract/request"
64
- autoload :AbstractHandler, "rack/auth/abstract/handler"
65
- autoload :OpenID, "rack/auth/openid"
66
- module Digest
67
- autoload :MD5, "rack/auth/digest/md5"
68
- autoload :Nonce, "rack/auth/digest/nonce"
69
- autoload :Params, "rack/auth/digest/params"
70
- autoload :Request, "rack/auth/digest/request"
71
- end
72
- end
73
-
74
- module Session
75
- autoload :Cookie, "rack/session/cookie"
76
- autoload :Pool, "rack/session/pool"
77
- autoload :Memcache, "rack/session/memcache"
78
- end
79
-
80
- # *Adapters* connect Rack with third party web frameworks.
81
- #
82
- # Rack includes an adapter for Camping, see README for other
83
- # frameworks supporting Rack in their code bases.
84
- #
85
- # Refer to the submodules for framework-specific calling details.
86
-
87
- module Adapter
88
- autoload :Camping, "rack/adapter/camping"
89
- end
90
- end
@@ -1,22 +0,0 @@
1
- module Rack
2
- module Adapter
3
- class Camping
4
- def initialize(app)
5
- @app = app
6
- end
7
-
8
- def call(env)
9
- env["PATH_INFO"] ||= ""
10
- env["SCRIPT_NAME"] ||= ""
11
- controller = @app.run(env['rack.input'], env)
12
- h = controller.headers
13
- h.each_pair do |k,v|
14
- if v.kind_of? URI
15
- h[k] = v.to_s
16
- end
17
- end
18
- [controller.status, controller.headers, [controller.body.to_s]]
19
- end
20
- end
21
- end
22
- end
@@ -1,37 +0,0 @@
1
- module Rack
2
- module Auth
3
- # Rack::Auth::AbstractHandler implements common authentication functionality.
4
- #
5
- # +realm+ should be set for all handlers.
6
-
7
- class AbstractHandler
8
-
9
- attr_accessor :realm
10
-
11
- def initialize(app, realm=nil, &authenticator)
12
- @app, @realm, @authenticator = app, realm, authenticator
13
- end
14
-
15
-
16
- private
17
-
18
- def unauthorized(www_authenticate = challenge)
19
- return [ 401,
20
- { 'Content-Type' => 'text/plain',
21
- 'Content-Length' => '0',
22
- 'WWW-Authenticate' => www_authenticate.to_s },
23
- []
24
- ]
25
- end
26
-
27
- def bad_request
28
- return [ 400,
29
- { 'Content-Type' => 'text/plain',
30
- 'Content-Length' => '0' },
31
- []
32
- ]
33
- end
34
-
35
- end
36
- end
37
- end
@@ -1,37 +0,0 @@
1
- module Rack
2
- module Auth
3
- class AbstractRequest
4
-
5
- def initialize(env)
6
- @env = env
7
- end
8
-
9
- def provided?
10
- !authorization_key.nil?
11
- end
12
-
13
- def parts
14
- @parts ||= @env[authorization_key].split(' ', 2)
15
- end
16
-
17
- def scheme
18
- @scheme ||= parts.first.downcase.to_sym
19
- end
20
-
21
- def params
22
- @params ||= parts.last
23
- end
24
-
25
-
26
- private
27
-
28
- AUTHORIZATION_KEYS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION']
29
-
30
- def authorization_key
31
- @authorization_key ||= AUTHORIZATION_KEYS.detect { |key| @env.has_key?(key) }
32
- end
33
-
34
- end
35
-
36
- end
37
- end
@@ -1,58 +0,0 @@
1
- require 'rack/auth/abstract/handler'
2
- require 'rack/auth/abstract/request'
3
-
4
- module Rack
5
- module Auth
6
- # Rack::Auth::Basic implements HTTP Basic Authentication, as per RFC 2617.
7
- #
8
- # Initialize with the Rack application that you want protecting,
9
- # and a block that checks if a username and password pair are valid.
10
- #
11
- # See also: <tt>example/protectedlobster.rb</tt>
12
-
13
- class Basic < AbstractHandler
14
-
15
- def call(env)
16
- auth = Basic::Request.new(env)
17
-
18
- return unauthorized unless auth.provided?
19
-
20
- return bad_request unless auth.basic?
21
-
22
- if valid?(auth)
23
- env['REMOTE_USER'] = auth.username
24
-
25
- return @app.call(env)
26
- end
27
-
28
- unauthorized
29
- end
30
-
31
-
32
- private
33
-
34
- def challenge
35
- 'Basic realm="%s"' % realm
36
- end
37
-
38
- def valid?(auth)
39
- @authenticator.call(*auth.credentials)
40
- end
41
-
42
- class Request < Auth::AbstractRequest
43
- def basic?
44
- :basic == scheme
45
- end
46
-
47
- def credentials
48
- @credentials ||= params.unpack("m*").first.split(/:/, 2)
49
- end
50
-
51
- def username
52
- credentials.first
53
- end
54
- end
55
-
56
- end
57
- end
58
- end
@@ -1,124 +0,0 @@
1
- require 'rack/auth/abstract/handler'
2
- require 'rack/auth/digest/request'
3
- require 'rack/auth/digest/params'
4
- require 'rack/auth/digest/nonce'
5
- require 'digest/md5'
6
-
7
- module Rack
8
- module Auth
9
- module Digest
10
- # Rack::Auth::Digest::MD5 implements the MD5 algorithm version of
11
- # HTTP Digest Authentication, as per RFC 2617.
12
- #
13
- # Initialize with the [Rack] application that you want protecting,
14
- # and a block that looks up a plaintext password for a given username.
15
- #
16
- # +opaque+ needs to be set to a constant base64/hexadecimal string.
17
- #
18
- class MD5 < AbstractHandler
19
-
20
- attr_accessor :opaque
21
-
22
- attr_writer :passwords_hashed
23
-
24
- def initialize(*args)
25
- super
26
- @passwords_hashed = nil
27
- end
28
-
29
- def passwords_hashed?
30
- !!@passwords_hashed
31
- end
32
-
33
- def call(env)
34
- auth = Request.new(env)
35
-
36
- unless auth.provided?
37
- return unauthorized
38
- end
39
-
40
- if !auth.digest? || !auth.correct_uri? || !valid_qop?(auth)
41
- return bad_request
42
- end
43
-
44
- if valid?(auth)
45
- if auth.nonce.stale?
46
- return unauthorized(challenge(:stale => true))
47
- else
48
- env['REMOTE_USER'] = auth.username
49
-
50
- return @app.call(env)
51
- end
52
- end
53
-
54
- unauthorized
55
- end
56
-
57
-
58
- private
59
-
60
- QOP = 'auth'.freeze
61
-
62
- def params(hash = {})
63
- Params.new do |params|
64
- params['realm'] = realm
65
- params['nonce'] = Nonce.new.to_s
66
- params['opaque'] = H(opaque)
67
- params['qop'] = QOP
68
-
69
- hash.each { |k, v| params[k] = v }
70
- end
71
- end
72
-
73
- def challenge(hash = {})
74
- "Digest #{params(hash)}"
75
- end
76
-
77
- def valid?(auth)
78
- valid_opaque?(auth) && valid_nonce?(auth) && valid_digest?(auth)
79
- end
80
-
81
- def valid_qop?(auth)
82
- QOP == auth.qop
83
- end
84
-
85
- def valid_opaque?(auth)
86
- H(opaque) == auth.opaque
87
- end
88
-
89
- def valid_nonce?(auth)
90
- auth.nonce.valid?
91
- end
92
-
93
- def valid_digest?(auth)
94
- digest(auth, @authenticator.call(auth.username)) == auth.response
95
- end
96
-
97
- def md5(data)
98
- ::Digest::MD5.hexdigest(data)
99
- end
100
-
101
- alias :H :md5
102
-
103
- def KD(secret, data)
104
- H([secret, data] * ':')
105
- end
106
-
107
- def A1(auth, password)
108
- [ auth.username, auth.realm, password ] * ':'
109
- end
110
-
111
- def A2(auth)
112
- [ auth.method, auth.uri ] * ':'
113
- end
114
-
115
- def digest(auth, password)
116
- password_hash = passwords_hashed? ? password : H(A1(auth, password))
117
-
118
- KD(password_hash, [ auth.nonce, auth.nc, auth.cnonce, QOP, H(A2(auth)) ] * ':')
119
- end
120
-
121
- end
122
- end
123
- end
124
- end
@@ -1,51 +0,0 @@
1
- require 'digest/md5'
2
-
3
- module Rack
4
- module Auth
5
- module Digest
6
- # Rack::Auth::Digest::Nonce is the default nonce generator for the
7
- # Rack::Auth::Digest::MD5 authentication handler.
8
- #
9
- # +private_key+ needs to set to a constant string.
10
- #
11
- # +time_limit+ can be optionally set to an integer (number of seconds),
12
- # to limit the validity of the generated nonces.
13
-
14
- class Nonce
15
-
16
- class << self
17
- attr_accessor :private_key, :time_limit
18
- end
19
-
20
- def self.parse(string)
21
- new(*string.unpack("m*").first.split(' ', 2))
22
- end
23
-
24
- def initialize(timestamp = Time.now, given_digest = nil)
25
- @timestamp, @given_digest = timestamp.to_i, given_digest
26
- end
27
-
28
- def to_s
29
- [([ @timestamp, digest ] * ' ')].pack("m*").strip
30
- end
31
-
32
- def digest
33
- ::Digest::MD5.hexdigest([ @timestamp, self.class.private_key ] * ':')
34
- end
35
-
36
- def valid?
37
- digest == @given_digest
38
- end
39
-
40
- def stale?
41
- !self.class.time_limit.nil? && (@timestamp - Time.now.to_i) < self.class.time_limit
42
- end
43
-
44
- def fresh?
45
- !stale?
46
- end
47
-
48
- end
49
- end
50
- end
51
- end
@@ -1,55 +0,0 @@
1
- module Rack
2
- module Auth
3
- module Digest
4
- class Params < Hash
5
-
6
- def self.parse(str)
7
- split_header_value(str).inject(new) do |header, param|
8
- k, v = param.split('=', 2)
9
- header[k] = dequote(v)
10
- header
11
- end
12
- end
13
-
14
- def self.dequote(str) # From WEBrick::HTTPUtils
15
- ret = (/\A"(.*)"\Z/ =~ str) ? $1 : str.dup
16
- ret.gsub!(/\\(.)/, "\\1")
17
- ret
18
- end
19
-
20
- def self.split_header_value(str)
21
- str.scan( /(\w+\=(?:"[^\"]+"|[^,]+))/n ).collect{ |v| v[0] }
22
- end
23
-
24
- def initialize
25
- super
26
-
27
- yield self if block_given?
28
- end
29
-
30
- def [](k)
31
- super k.to_s
32
- end
33
-
34
- def []=(k, v)
35
- super k.to_s, v.to_s
36
- end
37
-
38
- UNQUOTED = ['qop', 'nc', 'stale']
39
-
40
- def to_s
41
- inject([]) do |parts, (k, v)|
42
- parts << "#{k}=" + (UNQUOTED.include?(k) ? v.to_s : quote(v))
43
- parts
44
- end.join(', ')
45
- end
46
-
47
- def quote(str) # From WEBrick::HTTPUtils
48
- '"' << str.gsub(/[\\\"]/o, "\\\1") << '"'
49
- end
50
-
51
- end
52
- end
53
- end
54
- end
55
-