Skip to content

Commit 8d6f82a

Browse files
author
tailor
committed
[project @ Update example RP to use PAPE extension]
1 parent aa9361a commit 8d6f82a

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

examples/consumer/common.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@ function doIncludes() {
2727
* Require the Simple Registration extension API.
2828
*/
2929
require_once "Auth/OpenID/SReg.php";
30+
31+
/**
32+
* Require the PAPE extension module.
33+
*/
34+
require_once "Auth/OpenID/PAPE.php";
3035
}
3136

3237
doIncludes();
3338

39+
global $pape_policy_uris;
40+
$pape_policy_uris = array(
41+
PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
42+
PAPE_AUTH_MULTI_FACTOR,
43+
PAPE_AUTH_PHISHING_RESISTANT
44+
);
45+
3446
function &getStore() {
3547
/**
3648
* This is where the example will store its OpenID information.

examples/consumer/finish_auth.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,35 @@ function run() {
4848
if (@$sreg['fullname']) {
4949
$success .= " Your fullname is '".$sreg['fullname']."'.";
5050
}
51+
52+
$pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
53+
54+
if ($pape_resp) {
55+
if ($pape_resp->auth_policies) {
56+
$success .= "<p>The following PAPE policies affected the authentication:</p><ul>";
57+
58+
foreach ($pape_resp->auth_policies as $uri) {
59+
$success .= "<li><tt>$uri</tt></li>";
60+
}
61+
62+
$success .= "</ul>";
63+
} else {
64+
$success .= "<p>No PAPE policies affected the authentication.</p>";
65+
}
66+
67+
if ($pape_resp->auth_age) {
68+
$success .= "<p>The authentication age returned by the " .
69+
"server is: <tt>".$pape_resp->auth_age."</tt></p>";
70+
}
71+
72+
if ($pape_resp->nist_auth_level) {
73+
$success .= "<p>The NIST auth level returned by the " .
74+
"server is: <tt>".$pape_resp->nist_auth_level."</tt></p>";
75+
}
76+
77+
} else {
78+
$success .= "<p>No PAPE response was sent by the provider.</p>";
79+
}
5180
}
5281

5382
include 'index.php';

examples/consumer/index.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<?php
2+
require_once "common.php";
3+
4+
global $pape_policy_uris;
5+
?>
16
<html>
27
<head><title>PHP OpenID Authentication Example</title></head>
38
<style type="text/css">
@@ -52,6 +57,15 @@
5257
Identity&nbsp;URL:
5358
<input type="hidden" name="action" value="verify" />
5459
<input type="text" name="openid_identifier" value="" />
60+
61+
<p>Optionally, request these PAPE policies:</p>
62+
<p>
63+
<?php foreach ($pape_policy_uris as $i => $uri) {
64+
print "<input type=\"checkbox\" name=\"policies[]\" value=\"$uri\" />";
65+
print "$uri<br/>";
66+
} ?>
67+
</p>
68+
5569
<input type="submit" value="Verify" />
5670
</form>
5771
</div>

examples/consumer/try_auth.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ function run() {
3737
$auth_request->addExtension($sreg_request);
3838
}
3939

40+
$policy_uris = $_GET['policies'];
41+
42+
$pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
43+
if ($pape_request) {
44+
$auth_request->addExtension($pape_request);
45+
}
46+
4047
// Redirect the user to the OpenID server for authentication.
4148
// Store the token for this authentication so we can verify the
4249
// response.

0 commit comments

Comments
 (0)