I'm currently implementing OpenID authentication for a website. During testing, I've noticed that Google accepts different versions of claimed Google Profile IDs, e.g.:
- http://www.google.com/profiles/stefan.fussenegger
- http://profiles.google.com/u/0/stefan.fussenegger/about
- https://profiles.google.com/stefan.fussenegger
- https://profiles.google.com/stefanfussenegger
Interestingly, the verified ID differs as well (for the samples above, same order):
- http://www.google.com/profiles/stefan.fussenegger
- https://profiles.google.com/stefanfussenegger
- https://profiles.google.com/stefan.fussenegger
- https://profiles.google.com/stefanfussenegger
Of course, this makes looking up the associated user account quite difficult, not to say impossible. Interestingly, all above IDs work for Stackoverflow. So I thought that there has to be some normalization step I'm missing in my implementation - or SO does some specialized voodoo to get things straight.
Looking at 7.2 Normatlization of the OpenID Authentication spec I found this:
URL Identifiers MUST then be further normalized by both following redirects when retrieving their content and finally applying the rules in Section 6 of [RFC3986] to the final destination URL. This final URL MUST be noted by the Relying Party as the Claimed Identifier and be used when requesting authentication.
Following redirects of claimed IDs doesn't help too much as I'm still left with two different IDs:
Looking at redirects of verified IDs is much more helpful though as I always end up with this one:
Okay, looks like I should follow redirects of verified IDs, not claimed IDs.
The question now: Is it secure to follow redirects of claimed/verifed IDs, e.g. before search the DB like so:
do {
user = lookup(verifiedId)
if (user is null)
response = fetchUrl(verifiedId)
if (response.location is null) {
break # no redirect, jump out of loop, unknown user
} else {
verifiedId = response.location # use redirect location
}
} while (user is null)
return user;
If yes, I suspect that this should not only be done when looking up a user but when storing a new ID as well, right?
(If I should really follow redirect, I have another question about potential malicious redirects, but that will have to wait until I get an answer to this one. Might become obsolete anyway)