-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcb-implicit.html
184 lines (156 loc) · 6.26 KB
/
cb-implicit.html
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Copyright 2013-2017 ForgeRock AS. All Rights Reserved
Use of this code requires a commercial software license with ForgeRock AS.
or with one of its affiliates. All use shall be exclusively subject
to such license between the licensee and ForgeRock AS.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Implicit Client Profile Response Page</title>
<link rel="shortcut icon" href="http://forgerock.com/favicon.ico">
<link type="text/css" rel="stylesheet" href="style.css">
<script type="text/javascript"
src="///code.jquery.com/jquery-latest.min.js"></script>
<!-- Used by validateSignature() -->
<script type="text/javascript"
src="///crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha256.js"></script>
<script type="text/javascript"
src="///crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script>
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="implicit.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var params = getParamsFromFragment();
if (params.id_token != undefined) {
$("#code").html("<h3>Response From Provider</h3>"
+ "<pre>"
+ JSON.stringify(params, undefined, 2)
+ "</pre>"
);
} else {
var error = parseQueryString();
$("#info").html("<h3>Response From Provider</h3>"
+ "<pre>"
+ JSON.stringify(error, undefined, 2)
+ "</pre>"
);
return;
}
var idToken = params["id_token"];
idToken = idToken.split(/\./);
var header = JSON.parse(atob(idToken[0]));
$("#header").html("<h3>Decoded ID Token Header</h3>"
+ "<pre>"
+ JSON.stringify(header, undefined, 2)
+ "</pre>"
);
var payload = JSON.parse(atob(idToken[1]));
$("#decoded").html("<h3>Decoded ID Token Content</h3>"
+ "<pre>"
+ JSON.stringify(payload, undefined, 2)
+ "</pre>"
);
var signature = idToken[2];
$("#signature").html("<h3>ID Token Signature</h3>"
+ "<pre>"
+ signature
+ "</pre>"
);
// Validate signature.
var isValid = validateSignature(idToken[0], idToken[1], signature);
if (!isValid) {
$("#info").html("Invalid id_token signature");
return;
}
// Validate id_token.
if (
(payload.aud instanceof Array
&& payload.aud.indexOf(client_id) == -1)
|| (payload.aud != client_id)
) {
$("#info").html("Invalid id_token audience: " + payload.aud);
return;
}
if (payload.aud instanceof Array
&& payload.azp != client_id) {
$("#info").html("Invalid id_token authorized party: "
+ payload.azp);
return;
}
// In 12, issuer path is /openam. In 13, issuer path is /openam/oauth2.
if (payload.iss.lastIndexOf(server + openam, 0) !== 0) { // ~ startsWith
$("#info").html("Invalid id_token issuer: " + payload.iss);
return;
}
var now = new Date().getTime() / 1000;
if (now >= payload.exp) {
$("#info").html("The id_token has expired.");
return;
}
if (now < payload.iat) {
$("#info").html("The id_token was issued in the future.");
return;
}
if (payload.nonce != nonce) {
$("#info").html("Invalid id_token nonce: " + payload.nonce);
return;
}
// acr (Authentication Context Class Reference) not requested
// max_age not requested
$.ajax({
url: server + openam + info,
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization",
"Bearer " + params["access_token"]);
},
data: {
"scope": "openid profile",
"realm": client_realm
}
}).done(function (data) {
$("#info").html(
"<h3>Profile Information</h3>"
+ "<pre>"
+ JSON.stringify(data, undefined, 2)
+ "</pre>"
);
}).fail(function (data) {
$("#info").html(
"<p>Error obtaining token info:</p>"
+ "<pre>"
+ JSON.stringify(data, undefined, 2)
+ "</pre>"
);
});
});
</script>
</head>
<body>
<div>
<a href="http://openam.forgerock.org/">
<img src="forgerock-logo.svg" width="131" height="83" align="right" alt="ForgeRock Logo">
</a>
</div>
<h3>Implicit Client Profile Response Page</h3>
<p>
Concerning signature validation, see <a href="common.js">common.js</a>.
</p>
<hr>
<div id="code"><!-- code goes here --></div>
<div id="header"><!-- decoded id_token header goes here --></div>
<div id="decoded"><!-- decoded id_token goes here --></div>
<div id="signature"><!-- id_token signature goes here --></div>
<div id="info"><!-- info goes here --></div>
<div>
<hr>
<p align="center">
<a href="implicit.html">Try implicit profile again</a> |
<a href="basic.html">Try basic profile</a> |
<a href="index.html">Start over</a>
</p>
</div>
</body>
</html>