开发者

Openid get Provider

开发者 https://www.devze.com 2023-02-02 04:29 出处:网络
Iam using lightopenid in my php开发者_JAVA技巧 project as login system and after a user cancels authentication and returns back to my site, i want to know from which site he has cancelled the authenti

Iam using lightopenid in my php开发者_JAVA技巧 project as login system and after a user cancels authentication and returns back to my site, i want to know from which site he has cancelled the authentication.

For this, i tried the php HTTP_REFERER, but it is not able to get me the real site url. Suppose the user came from yahoo authentication page, i want to know that it is yahoo url.

How can i achieve this? Basically i want to know how to get the previous page url in php, if that works.


If you really need to, you could do something like that:

if(isset($_POST['openid_identifier'])) {
    $openid->identity = $_POST['openid_identifier'];
    $openid->returnUrl .= '?identifier=' . urlencode($openid->identity);
    header('Location: ' . $openid->authUrl());
}

Then, when user cancels:

if($openid->mode == 'cancel') {
    $openid->identity = $_GET['identifier'];
    echo 'User has canceled authentication! '
       . 'The authentication url was ' . $openid->authUrl();
}

The idea is to force the provider to send the claimed identifier via the return url. Then, you can just call $openid->authUrl() on this identifier and get the url you've redirected your user to.

I don't know, however, why would you want to do it. Maybe if you'd describe why do you need this, there would be a better solution?


You cannot, and it would not make sense if you could.

You redirect to the users OpenID provider. That means, you know the user's OpenID provider already. Anything that happens after that is out of the scope of the OpenID specification, until the user's browser request the URL under which you expect answers to authentication requests to come in. If this request comes in, the shared secret and the user's session are both good hints to which OpenID provider was used.

0

精彩评论

暂无评论...
验证码 换一张
取 消