summaryrefslogtreecommitdiffstats
path: root/examples/server/server.php
blob: 38b0c197ba9616763f695588d5418d04972461b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

require_once "common.php";

$server = newServer();

function isAuthorized($identity_url, $trust_root) {
    global $success_identity;
    return ($identity_url === $success_identity);
}

list($status, $info) = $server->getOpenIDResponse('isAuthorized');

switch($status) {
case Auth_OpenID_REMOTE_ERROR:
case Auth_OpenID_REMOTE_OK:
    returnKV($info);
    return;
case Auth_OpenID_REDIRECT:
    redirect($info);
    return;
case Auth_OpenID_DO_AUTH:
    redirect($info->getCancelURL());
case Auth_OpenID_DO_ABOUT:
    include "about.php";
    return;
case Auth_OpenID_LOCAL_ERROR:
    showError($info, '400', 'Bad request');
    return;
default:
    $error = "Internal error: unknown status $status";
    showError($error, '500', 'Internal error');
    return;
}
?>