diff options
author | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2014-06-24 19:34:36 +0200 |
---|---|---|
committer | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2014-06-24 19:34:36 +0200 |
commit | b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70 (patch) | |
tree | 718df6305bcb82c8dcb4b287a7132422e748cdfb /library/openid/provider/example.php | |
parent | c2d520f1be115fb3cb5da2a35eb10146cecee8aa (diff) | |
parent | a92fb0b04c3e6474ec48faf8e4cc65c382e89d66 (diff) | |
download | volse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.tar.gz volse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.tar.bz2 volse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'library/openid/provider/example.php')
-rw-r--r-- | library/openid/provider/example.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/library/openid/provider/example.php b/library/openid/provider/example.php new file mode 100644 index 000000000..b8a4c24a9 --- /dev/null +++ b/library/openid/provider/example.php @@ -0,0 +1,53 @@ +<?php +/** + * This example shows how to create a basic provider usin HTTP Authentication. + * This is only an example. You shouldn't use it as-is in your code. + */ +require 'provider.php'; + +class BasicProvider extends LightOpenIDProvider +{ + public $select_id = true; + public $login = ''; + public $password = ''; + + function __construct() + { + parent::__construct(); + + # If we use select_id, we must disable it for identity pages, + # so that an RP can discover it and get proper data (i.e. without select_id) + if(isset($_GET['id'])) { + $this->select_id = false; + } + } + + function setup($identity, $realm, $assoc_handle, $attributes) + { + header('WWW-Authenticate: Basic realm="' . $this->data['openid_realm'] . '"'); + header('HTTP/1.0 401 Unauthorized'); + } + + function checkid($realm, &$attributes) + { + if(!isset($_SERVER['PHP_AUTH_USER'])) { + return false; + } + + if ($_SERVER['PHP_AUTH_USER'] == $this->login + && $_SERVER['PHP_AUTH_PW'] == $this->password + ) { + # Returning identity + # It can be any url that leads here, or to any other place that hosts + # an XRDS document pointing here. + return $this->serverLocation . '?id=' . $this->login; + } + + return false; + } + +} +$op = new BasicProvider; +$op->login = 'test'; +$op->password = 'test'; +$op->server(); |