2023-10-04 21:53:20 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2024-02-09 15:25:56 +00:00
|
|
|
<title>Test Client</title>
|
|
|
|
<script src="pop2.js"></script>
|
|
|
|
<script>
|
|
|
|
const ssoService = "http://localhost:9090";
|
2023-10-04 21:53:20 +01:00
|
|
|
|
2024-02-14 21:04:52 +00:00
|
|
|
POP2.init(ssoService + "/authorize", "f4cdb93d-fe28-427b-b037-f03f44c86a16", "openid profile age email", 500, 600);
|
2023-12-05 18:10:47 +00:00
|
|
|
|
2024-02-10 16:23:50 +00:00
|
|
|
window.addEventListener("load", function () {
|
|
|
|
doThisThing(false);
|
|
|
|
})
|
|
|
|
|
2024-02-09 15:25:56 +00:00
|
|
|
function updateTokenInfo(data) {
|
|
|
|
document.getElementById("someTextArea").textContent = JSON.stringify(data, null, 2);
|
2024-02-10 16:23:50 +00:00
|
|
|
POP2.getToken(function (x) {
|
|
|
|
document.getElementById("tokenValues").textContent = JSON.stringify(parseJwt(x), null, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseJwt(token) {
|
|
|
|
const base64Url = token.split('.')[1];
|
|
|
|
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
|
|
const jsonPayload = decodeURIComponent(window.atob(base64).split('').map(function (c) {
|
|
|
|
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
|
|
}).join(''));
|
|
|
|
return JSON.parse(jsonPayload);
|
2024-02-09 15:25:56 +00:00
|
|
|
}
|
2023-10-04 21:53:20 +01:00
|
|
|
|
2024-02-10 16:23:50 +00:00
|
|
|
function doThisThing(popup) {
|
|
|
|
POP2.clientRequest(ssoService + "/userinfo", {}, popup).then(function (x) {
|
2024-02-10 02:53:58 +00:00
|
|
|
return x.json();
|
|
|
|
}).then(function (x) {
|
|
|
|
updateTokenInfo(x);
|
2024-02-09 15:25:56 +00:00
|
|
|
}).catch(function (x) {
|
|
|
|
console.error(x);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
:root {
|
|
|
|
color-scheme: light dark;
|
|
|
|
}
|
2023-10-04 21:53:20 +01:00
|
|
|
|
2024-02-09 15:25:56 +00:00
|
|
|
#someTextArea {
|
|
|
|
width: 400px;
|
|
|
|
height: 400px;
|
|
|
|
}
|
2023-10-04 21:53:20 +01:00
|
|
|
|
2024-02-09 15:25:56 +00:00
|
|
|
#tokenValues {
|
|
|
|
width: 400px;
|
|
|
|
height: 400px;
|
|
|
|
}
|
|
|
|
</style>
|
2023-10-04 21:53:20 +01:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<header>
|
2024-02-09 15:25:56 +00:00
|
|
|
<h1>Test Client</h1>
|
2023-10-04 21:53:20 +01:00
|
|
|
</header>
|
|
|
|
<main>
|
2024-02-09 15:25:56 +00:00
|
|
|
<div>
|
2024-02-10 16:23:50 +00:00
|
|
|
<button onclick="doThisThing(true);">Login</button>
|
2024-02-09 15:25:56 +00:00
|
|
|
</div>
|
|
|
|
<div style="display:flex; gap: 2em;">
|
2023-10-04 21:53:20 +01:00
|
|
|
<div>
|
2024-02-09 15:25:56 +00:00
|
|
|
<div>
|
|
|
|
<label for="someTextArea"></label><textarea id="someTextArea"></textarea>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label for="tokenValues"></label><textarea id="tokenValues"></textarea>
|
|
|
|
</div>
|
2023-10-04 21:53:20 +01:00
|
|
|
</div>
|
2024-02-09 15:25:56 +00:00
|
|
|
<div>
|
|
|
|
<p>Permissions:</p>
|
|
|
|
<ul id="somePerms"></ul>
|
2023-10-04 21:53:20 +01:00
|
|
|
</div>
|
2024-02-09 15:25:56 +00:00
|
|
|
</div>
|
2023-10-04 21:53:20 +01:00
|
|
|
</main>
|
|
|
|
</body>
|
|
|
|
</html>
|