summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@cprogrammer.org>2007-11-20 20:02:52 +0000
committertailor <cygnus@cprogrammer.org>2007-11-20 20:02:52 +0000
commit8d6f82a082e79462bfa1a4026479fbf38bcfc576 (patch)
tree2f7d79bc7a4267cde83c37e302974be7d0ef3a23
parentaa9361aaba848687781a67b38387dedf3e7f2b6f (diff)
downloadphp-openid-8d6f82a082e79462bfa1a4026479fbf38bcfc576.zip
php-openid-8d6f82a082e79462bfa1a4026479fbf38bcfc576.tar.gz
php-openid-8d6f82a082e79462bfa1a4026479fbf38bcfc576.tar.bz2
[project @ Update example RP to use PAPE extension]
-rw-r--r--examples/consumer/common.php12
-rw-r--r--examples/consumer/finish_auth.php29
-rw-r--r--examples/consumer/index.php14
-rw-r--r--examples/consumer/try_auth.php7
4 files changed, 62 insertions, 0 deletions
diff --git a/examples/consumer/common.php b/examples/consumer/common.php
index ba287c6..5e63fce 100644
--- a/examples/consumer/common.php
+++ b/examples/consumer/common.php
@@ -27,10 +27,22 @@ function doIncludes() {
* Require the Simple Registration extension API.
*/
require_once "Auth/OpenID/SReg.php";
+
+ /**
+ * Require the PAPE extension module.
+ */
+ require_once "Auth/OpenID/PAPE.php";
}
doIncludes();
+global $pape_policy_uris;
+$pape_policy_uris = array(
+ PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
+ PAPE_AUTH_MULTI_FACTOR,
+ PAPE_AUTH_PHISHING_RESISTANT
+ );
+
function &getStore() {
/**
* This is where the example will store its OpenID information.
diff --git a/examples/consumer/finish_auth.php b/examples/consumer/finish_auth.php
index 527291b..a54049d 100644
--- a/examples/consumer/finish_auth.php
+++ b/examples/consumer/finish_auth.php
@@ -48,6 +48,35 @@ function run() {
if (@$sreg['fullname']) {
$success .= " Your fullname is '".$sreg['fullname']."'.";
}
+
+ $pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
+
+ if ($pape_resp) {
+ if ($pape_resp->auth_policies) {
+ $success .= "<p>The following PAPE policies affected the authentication:</p><ul>";
+
+ foreach ($pape_resp->auth_policies as $uri) {
+ $success .= "<li><tt>$uri</tt></li>";
+ }
+
+ $success .= "</ul>";
+ } else {
+ $success .= "<p>No PAPE policies affected the authentication.</p>";
+ }
+
+ if ($pape_resp->auth_age) {
+ $success .= "<p>The authentication age returned by the " .
+ "server is: <tt>".$pape_resp->auth_age."</tt></p>";
+ }
+
+ if ($pape_resp->nist_auth_level) {
+ $success .= "<p>The NIST auth level returned by the " .
+ "server is: <tt>".$pape_resp->nist_auth_level."</tt></p>";
+ }
+
+ } else {
+ $success .= "<p>No PAPE response was sent by the provider.</p>";
+ }
}
include 'index.php';
diff --git a/examples/consumer/index.php b/examples/consumer/index.php
index 235f7bb..343a39c 100644
--- a/examples/consumer/index.php
+++ b/examples/consumer/index.php
@@ -1,3 +1,8 @@
+<?php
+require_once "common.php";
+
+global $pape_policy_uris;
+?>
<html>
<head><title>PHP OpenID Authentication Example</title></head>
<style type="text/css">
@@ -52,6 +57,15 @@
Identity&nbsp;URL:
<input type="hidden" name="action" value="verify" />
<input type="text" name="openid_identifier" value="" />
+
+ <p>Optionally, request these PAPE policies:</p>
+ <p>
+ <?php foreach ($pape_policy_uris as $i => $uri) {
+ print "<input type=\"checkbox\" name=\"policies[]\" value=\"$uri\" />";
+ print "$uri<br/>";
+ } ?>
+ </p>
+
<input type="submit" value="Verify" />
</form>
</div>
diff --git a/examples/consumer/try_auth.php b/examples/consumer/try_auth.php
index 3cf5b4b..4d2714c 100644
--- a/examples/consumer/try_auth.php
+++ b/examples/consumer/try_auth.php
@@ -37,6 +37,13 @@ function run() {
$auth_request->addExtension($sreg_request);
}
+ $policy_uris = $_GET['policies'];
+
+ $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
+ if ($pape_request) {
+ $auth_request->addExtension($pape_request);
+ }
+
// Redirect the user to the OpenID server for authentication.
// Store the token for this authentication so we can verify the
// response.