2 ================================================================================
4 ================================================================================
5 Copyright (C) 2017 AT&T Intellectual Property
6 ================================================================================
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ================================================================================
20 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
21 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
22 <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
23 <%@ taglib prefix="o" tagdir="/WEB-INF/tags"%>
24 <o:header title="User"/>
25 <o:topbar pageName="User"/>
26 <div class="container-fluid main">
27 <div class="row-fluid">
28 <div class="span10 offset1">
30 <h1>Hello ${ userInfo.name }</h1>
33 <p>This page requires that the user be logged in with a valid account and the <code>ROLE_USER</code> Spring Security authority.
34 If you are reading this page, <span class="text-success">you are currently logged in</span>.</p>
36 <security:authentication var="user" property="principal" />
38 <p>The authorization provider will create a Principal object based on the <code>iss</code> and <code>sub</code>
39 claims associated with your ID token. This value can be used as a globally unique username within the application
40 (though it's not meant to be human-readable).
41 Your Principal is: <code>${ user }</code></p>
43 <p>The authorization provider will assign your account a set of authorities depending on how it's configured.
44 Your current login has the following Spring Security authorities:</p>
47 <security:authentication property="authorities" var="authorities" />
48 <c:forEach items="${authorities}" var="auth">
49 <li><code>${ auth }</code></li>
55 <p>Your ID Token has the following set of claims:</p>
57 <security:authentication property="idToken" var="idToken" />
58 <table class="table table-striped table-hover" id="idTokenTable">
61 <th class="span1">Name</th>
62 <th class="span11">Value</th>
69 <p>The ID Token header contains the following claims:</p>
71 <table class="table table-striped table-hover" id="idTokenHeader">
74 <th class="span1">Name</th>
75 <th class="span11">Value</th>
84 <p>The call to the User Info Endpoint returned the following set of claims:</p>
86 <table class="table table-striped table-hover" id="userInfoTable">
89 <th class="span1">Name</th>
90 <th class="span11">Value</th>
103 <script type="text/javascript">
104 $(document).ready(function () {
106 var idTokenString = "${ idToken.serialize() }";
107 var idToken = jwt.WebTokenParser.parse(idTokenString);
108 var idHeader = JSON.parse(jwt.base64urldecode(idToken.headerSegment));
109 var idClaims = JSON.parse(jwt.base64urldecode(idToken.payloadSegment));
111 _.each(idClaims, function(val, key, list) {
112 if (_.contains(["iat", "exp", "auth_time", "nbf"], key)) {
113 // it's a date field, parse and print it
114 var date = new Date(val * 1000);
115 $('#idTokenTable tbody').append('<tr><td>' + _.escape(key) + '</td><td><span title="' + _.escape(val) + '">' + date + '</span></td></tr>');
117 $('#idTokenTable tbody').append('<tr><td>' + _.escape(key) + '</td><td>' + _.escape(val) + '</td></tr>');
121 _.each(idHeader, function(val, key, list) {
122 if (_.contains(["iat", "exp", "auth_time", "nbf"], key)) {
123 // it's a date field, parse and print it
124 var date = new Date(val * 1000);
125 $('#idTokenHeader tbody').append('<tr><td>' + _.escape(key) + '</td><td><span title="' + _.escape(val) + '">' + date + '</span></td></tr>');
127 $('#idTokenHeader tbody').append('<tr><td>' + _.escape(key) + '</td><td>' + _.escape(val) + '</td></tr>');
131 var userInfo = ${ userInfoJson };
132 _.each(userInfo, function(val, key, list) {
133 $('#userInfoTable tbody').append('<tr><td>' + _.escape(key) + '</td><td>' + _.escape(val) + '</td></tr>');