Created
May 12, 2010 19:45
-
-
Save hns/399046 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/auth.js b/auth.js | |
index 0ae0627..b324f8e 100644 | |
--- a/auth.js | |
+++ b/auth.js | |
@@ -6,11 +6,11 @@ module.shared = true; | |
exports.middleware = function (app) { | |
return function (env) { | |
- if (auth[env.PATH_INFO.replace(/^\//, '').replace(/\/$/, '')]) { | |
+ if (auth[env.pathInfo.replace(/^\//, '').replace(/\/$/, '')]) { | |
var toAuth = // Determine path to authorize with credentials. | |
- auth[env.PATH_INFO.replace(/^\//, '').replace(/\/$/, '')]; | |
- if (env.HTTP_AUTHORIZATION) { // Extract credentials from HTTP. | |
- var credentials = base64.decode(env.HTTP_AUTHORIZATION. | |
+ auth[env.pathInfo.replace(/^\//, '').replace(/\/$/, '')]; | |
+ if (env.headers.authorization) { // Extract credentials from HTTP. | |
+ var credentials = base64.decode(env.headers.authorization. | |
replace(/Basic /, '')).split(':'); | |
if (credentials[1].digest('sha1') === toAuth[credentials[0]]) { | |
return app(env); // Authorization. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment