-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
127 lines (116 loc) · 4.29 KB
/
index.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
<html lang="en">
<head>
<title>TheUsher Test Client App</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="/style.css" />
<script>
// Authentication service (Auth0) configuration
const AUTH0_DOMAIN = "dmgt-test.auth0.com"; // replace with your Auth0 tenant domain
const AUTH0_CLIENT_ID = "nPoIVTfaaXJwqLqWVYG6AFRikXWCqeMX"; // replace with your client ID
const AUTH0_REDIRECT_URI = "http://localhost:8000"; // replace with the URI to this hosted app
// Authorization service (TheUsher) configuration
const THEUSHER_URL =
"http://localhost:3001/";
const THEUSHER_CLIENT_ID = "test-client1"
// Backend Resources to Use (needs to include trailing slash)
const BACKEND_RESOURCE_BASEURL =
"http://localhost:9000/"
// Internal client app configuration
const IDP_TOKEN_COOKIE_NAME = "idp_token";
const THEUSHER_TOKEN_COOKIE_NAME = "theusher_token";
const IMG_BLANK_PIXEL =
"https://cdn.glitch.com/a86b7d50-d4dd-4637-a680-cbba8665a07d%2F1x1.png?v=1585262144161";
const IMG_WAITING =
"https://cdn.glitch.com/a86b7d50-d4dd-4637-a680-cbba8665a07d%2Fwaiting.gif?v=1585261956156";
</script>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js"></script>
<script src="https://cdn.auth0.com/js/auth0-spa-js/1.2/auth0-spa-js.production.js"></script>
<script src="/jwt-decode.min.js"></script>
<script src="/authn-auth0.js"></script>
<script src="/authz-theusher.js"></script>
<script src="/backend-layer.js"></script>
</head>
<body>
<section>
<h1>Example Client App using The Usher</h1>
<p>
This is a simple client application that can get authorization from
TheUsher to perform computations on a backend resource.
</p>
<p>
If you want to be able to <b>add numbers together</b>, the backend
resource requires you have scope <tt>test-permission1</tt>.
<br />
If you want to be able to <b>divide two numbers by each other</b>, the
backend resource requires you have scope <tt>test-permission9</tt> ;)
</p>
<div
class="glitchButton"
style="position:fixed;top:20px;right:20px;"
></div>
<script src="https://button.glitch.me/button.js"></script>
<button onclick="javascript:theusherDeauthorize();idpLogout();">
Log out
</button>
</section>
<section>
<h2>Perform computations using the backend resource</h2>
<br />
<p>
<i>(Only works after you've gotten authorized by TheUsher)</i>
</p>
<hr />
<div id="messages"></div>
<hr />
<button onclick="javascript:getTheUsherToken();">
Get Authorization from TheUsher
</button>
<form>
<table border="0">
<tr valign="center">
<td valign="center"><input type="text" size="10" id="left" /></td>
<td>•</td>
<td><input type="text" size="10" id="right" /></td>
<td>=</td>
<td><input type="text" size="10" id="result" /></td>
<td>
<img
width="50px"
src="https://cdn.glitch.com/a86b7d50-d4dd-4637-a680-cbba8665a07d%2F1x1.png?v=1585262144161"
id="waitingIconImage"
/>
</td>
</tr>
<tr valign="center">
<td align="center"> </td>
<td> </td>
<td align="center"> </td>
<td> </td>
<td align="center">
<button
type="button"
onclick="javascript:runSubtractBackendResource()"
>
Subtract
</button>
<button
type="button"
onclick="javascript:runAddBackendResource()"
>
Add
</button>
<button
type="button"
onclick="javascript:runDivideBackendResource()"
>
Divide
</button>
</td>
</tr>
</table>
</form>
</section>
</body>
</html>