Created
January 11, 2011 22:05
-
-
Save bitdrift/775256 to your computer and use it in GitHub Desktop.
node-openid attribute exchange parameters patch
This file contains 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
From 354bd25fc63584c138d40bbf474c4a488f05bdc1 Mon Sep 17 00:00:00 2001 | |
From: Ryan Probasco <ryan@bitdrift.org> | |
Date: Tue, 11 Jan 2011 14:58:44 -0700 | |
Subject: [PATCH] Use attribute exchange params to fetch extended attributes during authentication | |
--- | |
openid.js | 26 +++++++++++++++++++++++--- | |
1 files changed, 23 insertions(+), 3 deletions(-) | |
diff --git a/openid.js b/openid.js | |
index 5fac024..f9753bb 100644 | |
--- a/openid.js | |
+++ b/openid.js | |
@@ -623,7 +623,7 @@ function _generateAssociationRequestParameters(version, algorithm) | |
return params; | |
} | |
-openid.authenticate = function(identifier, returnUrl, realm, immediate, callback) | |
+openid.authenticate = function(identifier, returnUrl, realm, immediate, ax, callback) | |
{ | |
openid.discover(identifier, function(providers, version) | |
{ | |
@@ -643,13 +643,13 @@ openid.authenticate = function(identifier, returnUrl, realm, immediate, callback | |
return console.log(answer); | |
} | |
- _requestAuthentication(provider, answer.assoc_handle, returnUrl, realm, immediate, callback); | |
+ _requestAuthentication(provider, answer.assoc_handle, returnUrl, realm, immediate, ax, callback); | |
}); | |
} | |
}); | |
} | |
-function _requestAuthentication(provider, assoc_handle, returnUrl, realm, immediate, callback) | |
+function _requestAuthentication(provider, assoc_handle, returnUrl, realm, immediate, ax, callback) | |
{ | |
var params = { | |
'openid.mode' : immediate ? 'checkid_immediate' : 'checkid_setup' | |
@@ -704,6 +704,26 @@ function _requestAuthentication(provider, assoc_handle, returnUrl, realm, immedi | |
throw new Error("No return URL or realm specified"); | |
} | |
+ // Attribute exchange parameters | |
+ if(ax) | |
+ { | |
+ params["openid.ns.ax"] = "http://openid.net/srv/ax/1.0"; | |
+ params["openid.ax.mode"] = "fetch_request"; | |
+ | |
+ var types = ["required", "if_available"]; | |
+ for(var i in types) | |
+ { | |
+ var items = []; | |
+ for(var name in ax[types[i]]) | |
+ { | |
+ params["openid.ax.type." + name] = ax[types[i]][name]; | |
+ items.push(name); | |
+ } | |
+ if(items.length > 0) | |
+ params["openid.ax." + types[i]] = items.join(","); | |
+ } | |
+ } | |
+ | |
callback(_buildUrl(provider.endpoint, params)); | |
} | |
-- | |
1.7.0.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment