I have a Google Chrome extension with an external user system (username/email/sessionId), that people can log into using their self-chosen credentials (over SSL). I would like to change this to using Google OpenID login like this:
- User clicks "Log in via Google":
- Extension performs a
checkid_immediate* login request:- If
checkid_immediatelogin fails:- The extension will opens a new tab with the specified parameters for
checkid_setup** login (and email fetch). - User selects accounts and approves my service.
- On my return page I save the OpenID identity and email in my database.
- I close the tab via Javascript.
- The extension will opens a new tab with the specified parameters for
- Else
checkid_immediateis successfull and an OpenID identity is returned:- I determine which user by looking for the OpenID identity in my database.
- If
- I log in the user and set up
sessionIdas usual.
As far as I have understood x-has-session will allow me to fetch the OpenID of the currently logged in user (if they have previously allowed my service to use their login), but the response is always openid_mode=setup_needed.
Using my own account for testing I am able to authorize using the new tab checkid_setup method and then get a successful response from the checkid_immediate XmlHttpRequest. This is, however, only possible when I insert my obtained OpenID from Google in the openid.claimed_id and openid.identity parameters.
The request is successfull regardless of the openid.identity and openid.ui.mode parameters.
Have I completely misunderstood what I can do with x-has-session?
If yes, is the only way to perform my checkid_immediate request from my extension (without opening it in a new tab) to do it via the OpenID identifier I obtained at the time of running the checkid_setup request?
*checkid_immediate request parameters (sent as a POST request using XMLHttpRequest):
var endpoint = "https://www.google.com/accounts/o8/ud";
var openIdParameters = {
"openid.ns": "http://specs.openid.net/auth/2.0",
"openid.mode": "checkid_immediate",
"openid.return_to": "http://example.com/googleAuth.php",
"openid.realm": "http://example.com",
"openid.claimed_id": "http://specs.openid.net/auth/2.0/identifier_select",
"openid.identity": "http://specs.openid.net/auth/2.0/identifier_select",
"openid.ns.ui": "http://specs.openid.net/extensions/ui/1.0",
"openid.ui.mode": "x-has-session"
};
At the openid.return_to URL all I do is echo json_encode($_REQUEST) (only GET/POST vars, cookies not included) which is fetched as the response in my XmlHttpRequest.
*checkid_setup request parameters (opened in new tab):
var endpoint = "https://www.google.com/accounts/o8/ud";
var openIdParameters = {
"openid.ns": "http://specs.openid.net/auth/2.0",
"openid.mode": "checkid_setup",
"openid.return_to": "http://example.com/googleAuth.php",
"openid.realm": "http://example.com",
"openid.claimed_id": "http://specs.openid.net/auth/2.0/identifier_select",
"openid.identity": "http://specs.openid.net/auth/2.0/identifier_select",
"openid.ns.ax": "http://openid.net/srv/ax/1.0",
"openid.ax.mode": "fetch_request",
"openid.ax.required": "email",
"openid.ax.type.email": "http://axschema.org/contact/email"
};