import
[web.mtrack] / inc / auth / openid.php
1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
3
4 /* all the clever stuff happens in openid.php */
5 class MTrackAuth_OpenID implements IMTrackAuth, IMTrackNavigationHelper {
6   function __construct() {
7     MTrackAuth::registerMech($this);
8     MTrackNavigation::registerHelper($this);
9   }
10
11   function augmentUserInfo(&$content) {
12     global $ABSWEB;
13     if (isset($_SESSION['openid.id'])) {
14       $content .= " | <a href='{$ABSWEB}openid.php/signout'>Log off</a>";
15     } else {
16       $content = "<a href='{$ABSWEB}openid.php'>Log In</a>";
17     }
18   }
19
20   function augmentNavigation($id, &$items) {
21   }
22
23   function authenticate() {
24     if (!strlen(session_id()) && php_sapi_name() != 'cli') {
25       session_start();
26     }
27     if (isset($_SESSION['openid.id'])) {
28       if (isset($_SESSION['openid.userid'])) {
29         return $_SESSION['openid.userid'];
30       }
31       return $_SESSION['openid.id'];
32     }
33     return null;
34   }
35
36   function doAuthenticate($force = false) {
37     if ($force) {
38       global $ABSWEB;
39       header("Location: {$ABSWEB}openid.php");
40       exit;
41     }
42     return null;
43   }
44
45   function enumGroups() {
46     return null;
47   }
48
49   function getGroups($username) {
50     return null;
51   }
52
53   function addToGroup($username, $groupname) {
54     return null;
55   }
56
57   function removeFromGroup($username, $groupname) {
58     return null;
59   }
60
61   function getUserData($username) {
62     return null;
63   }
64 }
65
66