-
Notifications
You must be signed in to change notification settings - Fork 39
/
index.html
executable file
·220 lines (192 loc) · 9.23 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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!--
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta name="referrer" content="no-referrer"/>
<title>Javascript Authentication Example - Using Asgardeo Auth Javascript UMD SDK</title>
<!-- <link href="https://unpkg.com/json-formatter-js@2.3.4/dist/json-formatter.css" rel="stylesheet" type="text/css" /> -->
<link href="app.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
.json-formatter-row .json-formatter-string,
.json-formatter-row .json-formatter-stringifiable {
white-space: unset !important;
}
.json-formatter-dark.json-formatter-row
.json-formatter-row {
line-height: 1.5;
}
.json-container {
background: #272822;
padding: 20px;
}
.json-formatter-string {
color: #fd971f !important;
}
.json-formatter-key,
.json-formatter-bracket {
color: #f9f8f5 !important;
letter-spacing: 0.5px;
}
.json-formatter-number {
color: #cc6633 !important;
}
.code {
line-height: 1.5;
}
</style>
</head>
<body>
<div id="root">
<div class="container">
<div class="header-title">
<h1>
JavaScript Authentication Sample
</h1>
</div>
<div class="content">
<div id="loading">Loading ...</div>
<div id="error" style="display: none;">
<div class="segment-form">
<div class="ui visible negative message">
<div class="header"><b>Authentication Error!</b></div>
<p>Something went wrong during the authentication process.</p>
</div>
</div>
</div>
<div id="missing-config" style="display:none;">
<h2>You need to update the Client ID to proceed.</h2>
<p>Please open the <b>index.html</b> file using an editor and scroll down to the <b>script</b>
tag at the the end of the <b>body</b> tag, find the <code>authConfig</code>, and
update the <code>clientID</code> value with the registered application's client ID.</p>
<p>Visit repo
<a href="https://github.com/asgardeo/asgardeo-auth-spa-sdk/tree/master/samples/asgardeo-html-js-app">
README
</a> for more details.</p>
</div>
<div id="logged-in-view" style="display:none;">
<h2>Authentication Response</h2>
<h4 className="sub-title">
Derived by the
<code className="inline-code-block">
<a href="https://www.npmjs.com/package/@asgardeo/auth-spa/v/latest"
target="_blank">
@asgardeo/auth-spa
</a>
</code> SDK
</h4>
<div class="json">
<div id="authentication-response" class="json-container"></div>
</div>
<h2 class="mb-0 mt-4">ID token</h2>
<div class="row">
<div class="column">
<h5><b>Encoded</b></h5>
<div class="code">
<code>
<span class="id-token-0" id="id-token-0"></span>.<span class="id-token-1" id="id-token-1"></span>.<span class="id-token-2" id="id-token-2"></span>
</code>
</div>
</div>
<div class="column">
<div class="json">
<h5><b>Decoded:</b> Header</h5>
<div id="id-token-header" class="json-container"></div>
</div>
<div class="json">
<h5><b>Decoded:</b> Payload</h5>
<div id="id-token-payload" class="json-container"></div>
</div>
<div class="json">
<h5>Signature</h5>
<div class="code">
<code>
HMACSHA256(
<br />
<span class="id-token-0">base64UrlEncode(
<span class="id-token-1">header</span>)</span> + "." + <br />
<span class="id-token-0">base64UrlEncode(
<span class="id-token-1">payload</span>)</span>,
<span class="id-token-1">your-256-bit-secret</span> <br />
);
</code>
</div>
</div>
</div>
</div>
<button class="btn primary mt-4" onClick="handleLogout()">Logout</button>
</div>
<div id="logged-out-view" style="display:none;">
<div class="home-image">
<img src="images/js-logo.png" class="js-logo-image logo" />
</div>
<h3>
Sample demo to showcase authentication for a Single Page Application <br />
via the OpenID Connect Authorization Code flow, <br />
which is integrated using the
<a href="https://github.com/asgardeo/asgardeo-auth-spa-sdk" target="_blank">
Asgardeo Auth SPA SDK</a>.
</h3>
<button class="btn primary" onClick="handleLogin()">Login</button>
</div>
<div id="user-denied-logout-view" style="display:none;" className="ui visible negative message">
<h3 className="mt-4 b">End User denied the logout request</h3>
<p className="my-4">
<a className="link-button pointer" onClick="handleLogin()" role="button">
Try Log in again
</a>
or
<a className="link-button pointer" onClick="handleLogout()" role="button">
Log out from the application.
</a>
</p>
</div>
<div id="error-authenticating-view" style="display:none;" className="ui visible negative message">
<div class="segment-form">
<div class="ui visible negative message">
<div class="header"><b>Authentication Error!</b></div>
<p>Please check application configuration and try login again!.</p>
</div>
</div>
<button class="btn primary" onClick="handleLogin()">Login</button>
</div>
</div>
</div>
<img src="images/footer.png" class="footer-image"/>
</div>
<!-- Add Asgardeo OIDC JS -->
<script src="https://unpkg.com/@asgardeo/auth-spa@latest/dist/asgardeo-spa.production.min.js"></script>
<script src="https://unpkg.com/json-formatter-js@latest/dist/json-formatter.umd.js"></script>
<!-- Asgardeo SDK Init Config -->
<script>
const authConfig = {
// ClientID generated for the application
clientID: "",
// After login redirect URL - We have use app root path, since this is a SPA
// (Add it in application OIDC settings "Authorized redirect Url")
signInRedirectURL: "https://localhost:3000",
// After logout redirect URL - We have use app root path, since this is a SPA
// Asgardeo base url - Contains domain with the tenant
baseUrl: "",
scope: [ "profile" ]
};
</script>
<script type="application/javascript" src="app.js"></script>
</body>
</html>