This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assisted.html
89 lines (79 loc) · 2.9 KB
/
assisted.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
<!--
~ Copyright (C) 2020 Curity AB. All rights reserved.
~
~ The contents of this file are the property of Curity AB.
~ You may not copy or use this file, in either source code
~ or executable form, except in compliance with terms
~ set by Curity AB.
~
~ For further information, please contact Curity AB.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Assisted Authorize</title>
<script type="text/javascript" $!nonceAttr>
// Should be the origin where the app is running
const origin = window.origin;
function postUp(msg, origin) {
var channel = undefined;
//It's undefined in IE and null in Chrome...
if ((window.opener !== undefined) && (window.opener !== null)) {
channel = window.opener;
}
else {
channel = window.parent;
}
channel.postMessage(msg, origin);
}
if (window.location.search) {
const args = new URLSearchParams(window.location.search);
const error = args.get("error");
const code = args.get("code");
const state = args.get("state");
const session_state = args.get("session_state");
if (code !== null) {
postUp({session_state, code, state, status: "ok"}, origin);
}
else if (error !== null) {
postUp({"status" : "error", "error" : error, error_description: args.get("error_description")}, origin);
} else if (Array.from(args).length === 1 && state) {
// user logout success case
postUp({
logout_successful: true,
state
}, origin);
}
}
else if (window.location.hash) {
const fragment = window.location.hash.substr(1, window.location.hash.length);
const args = new URLSearchParams(fragment);
const access_token = args.get("access_token");
const expires_in = args.get("expires_in");
const state = args.get("state");
const session_state = args.get("session_state");
const scope = args.get("scope");
const id_token = args.get("id_token");
const error = args.get("error");
if (error !== null) {
postUp({"status" : "error", "error" : error, error_description: args.get("error_description")}, origin);
}
else if (access_token !== null && expires_in !== null) {
postUp({
access_token,
expires_in,
state,
session_state,
scope,
id_token,
status: "ok"
}, origin);
}
}
</script>
</head>
<body>
<h1>Hello!</h1>
</body>
</html>