This repository was archived by the owner on Mar 19, 2025. It is now read-only.
forked from marcopolox/Custom_Okta_Sign-In_Widget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomOktaSign-InWidget.html
More file actions
562 lines (528 loc) · 20.1 KB
/
CustomOktaSign-InWidget.html
File metadata and controls
562 lines (528 loc) · 20.1 KB
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="noindex,nofollow" name="robots"><!-- Styles generated from theme -->
<link href="{{themedStylesUrl}}" rel="stylesheet" type="text/css"><!-- Favicon from theme -->
<link href="{{faviconUrl}}" rel="shortcut icon" type="image/x-icon">
<title>{{pageTitle}}</title>
</head>
<body>
{{{SignInWidgetResources}}}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" rel="stylesheet" type="text/css">
<style>
#login-bg-image-id {
background-image: {{bgImageUrl}}
}
/********* custom css ************/
@import url('https://fonts.googleapis.com/css?family=Montserrat:400,800');
* {
box-sizing: border-box;
}
body {
background: linear-gradient(-135deg,#ffffff,#4158d0);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
font-family: 'Montserrat', sans-serif;
height: 100vh;
margin: -20px 0 50px;
}
h1 {
font-weight: bold;
margin: 0;
text-align: center;
padding: 20px;
}
h2 {
text-align: center;
}
p {
font-size: 14px;
font-weight: 100;
line-height: 20px;
letter-spacing: 0.5px;
margin: 20px 0 30px;
}
span {
font-size: 12px;
}
a {
color: #333;
font-size: 14px;
text-decoration: none;
margin: 15px 0;
}
button {
border-radius: 20px;
border: 1px solid #c850c0;
background-color: #c850c0;
color: #FFFFFF;
font-size: 12px;
font-weight: bold;
padding: 12px 45px;
letter-spacing: 1px;
text-transform: uppercase;
transition: transform 80ms ease-in;
}
button:active {
transform: scale(0.95);
}
button:focus {
outline: none;
}
button.ghost {
background-color: transparent;
border-color: #FFFFFF;
}
form {
background-color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 0 50px;
height: 100%;
text-align: center;
}
input {
background-color: #eee;
border: none;
padding: 12px 15px;
margin: 8px 0;
width: 100%;
}
.container {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 14px 28px rgba(0,0,0,0.25),
0 10px 10px rgba(0,0,0,0.22);
position: relative;
overflow: hidden;
width: 768px;
max-width: 100%;
min-height: 550px;
}
.form-container {
position: absolute;
top: 0;
height: 100%;
transition: all 0.6s ease-in-out;
}
.sign-in-container {
left: 0;
width: 50%;
z-index: 2;
}
.container.right-panel-active .sign-in-container {
transform: translateX(100%);
}
.sign-up-container {
left: 0;
width: 50%;
opacity: 0;
z-index: 1;
}
.container.right-panel-active .sign-up-container {
transform: translateX(100%);
opacity: 1;
z-index: 5;
animation: show 0.6s;
}
@keyframes show {
0%, 49.99% {
opacity: 0;
z-index: 1;
}
50%, 100% {
opacity: 1;
z-index: 5;
}
}
.overlay-container {
position: absolute;
top: 0;
left: 50%;
width: 50%;
height: 100%;
overflow: hidden;
transition: transform 0.6s ease-in-out;
z-index: 100;
}
.container.right-panel-active .overlay-container{
transform: translateX(-100%);
}
.overlay {
background: #c850c0;
background: -webkit-linear-gradient(to right, #4158d0, #c850c0);
background: linear-gradient(to right, #4158d0, #c850c0);
background-repeat: no-repeat;
background-size: cover;
background-position: 0 0;
color: #FFFFFF;
position: relative;
left: -100%;
height: 100%;
width: 200%;
transform: translateX(0);
transition: transform 0.6s ease-in-out;
}
.container.right-panel-active .overlay {
transform: translateX(50%);
}
.overlay-panel {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 0 40px;
text-align: center;
top: 0;
height: 100%;
width: 50%;
transform: translateX(0);
transition: transform 0.6s ease-in-out;
}
.overlay-left {
transform: translateX(-20%);
}
.container.right-panel-active .overlay-left {
transform: translateX(0);
}
.overlay-right {
right: 0;
transform: translateX(0);
}
.container.right-panel-active .overlay-right {
transform: translateX(20%);
}
footer {
background-color: #222;
color: #fff;
font-size: 14px;
bottom: 0;
position: fixed;
left: 0;
right: 0;
text-align: center;
z-index: 999;
}
footer p {
margin: 10px 0;
}
footer i {
color: red;
}
footer a {
color: #3c97bf;
text-decoration: none;
}
/* end custom css */
/* modified Okta css */
#okta-sign-in {
border-radius: 10px;
background:#ffffff;
width: 100%;
margin: 20px auto 8px;
}
#okta-sign-in .auth-header {
padding: 0px;
}
#okta-sign-in .auth-content {
padding: 20px 22px 20px;
}
#okta-sign-in.no-beacon .auth-content {
padding-top: 5px;
}
#okta-sign-in .siw-main-view .siw-main-body .o-form-content {
width: 100%;
}
#okta-sign-in .focused-input, #okta-sign-in .link.help:focus, okta-form-input-field:focus {
box-shadow: none;
}
#okta-sign-in .o-form .input-fix, #okta-sign-in .o-form .textarea-fix {
border: none;
}
#okta-sign-in .o-form .input-fix input[type="text"],
#okta-sign-in .o-form .input-fix input[type="textbox"],
#okta-sign-in .o-form .input-fix input[type="number"],
#okta-sign-in .o-form .input-fix input[type="password"] {
font-size: 15px;
line-height: 1.5;
color: #666;
display: block;
width: 100%;
background: #f7f7f7;
height: 50px;
border-radius: 5px;
/*padding: 0 30px 0 68px;*/
box-shadow: none;
}
#okta-sign-in .focused-input {
box-shadow: none;
}
#okta-sign-in .o-form-button-bar {
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: center;
padding-top: 13px;
border: none;
}
#okta-sign-in.auth-container.main-container {
background-color: #ffffff;
border: none;
border-color: none;
color: #000;
box-shadow: none;
}
#okta-sign-in .auth-divider .auth-divider-text {
color: #000;
}
#okta-sign-in.auth-container .okta-form-input-field {
background-color: transparent;
}
#okta-sign-in.auth-container .button-primary,
#okta-sign-in.auth-container input[type=button],
#okta-sign-in.auth-container input[type=submit] {
font-family:Montserrat-Bold;
font-size:15px;
line-height:1.5;
color:#ffffff !important;
text-transform:uppercase;
text-align: center;
width:100%;
height:50px;
border-radius:25px;
display:flex;
justify-content:center;
align-items:center;
transition:all .4s
background: #c850c0 !important;
border: #c850c0 1px solid !important;
border-bottom-color: #c850c0;
box-shadow: none;
width: 80%;
}
#okta-sign-in.auth-container h2, #okta-sign-in.auth-container h3 {
color: #000;
font-size: x-large;
font-weight: bold;
font-family: 'Montserrat', sans-serif;
}
#okta-sign-in.auth-container .okta-form-label {
color: #000;
}
#okta-sign-in.auth-container.main-container .o-form .o-form-input .o-form-control .input-icon-divider {
height: 50px;
}
#okta-sign-in .registration-container .content-container { text-align: center; }
#okta-sign-in .enroll-sms .enroll-sms-phone {
width: auto;
}
#okta-sign-in .siw-main-footer .footer-info {
border-top: none;
display: flex;
margin-top: 0rem;
padding-top: 0rem;
}
#okta-sign-in .o-form .o-form-label,
#okta-sign-in .o-form input,
#okta-sign-in .o-form label,
#okta-sign-in .o-form textarea{
text-align: left;
}
#okta-sign-in .siw-main-view .siw-main-body .o-form-content .o-form-label label {
font-size: medium;
}
#okta-sign-in .siw-main-view .siw-main-body .o-form-content .o-form-label .o-form-explain {
color: #c250c1;
}
#okta-sign-in .sign-in-with-idp .social-container {
margin: 20px 0;
}
#okta-sign-in .sign-in-with-idp .social-container a {
border: 1px solid #DDDDDD;
border-radius: 50%;
display: inline-flex;
justify-content: center;
align-items: center;
margin: 0 5px;
height: 40px;
width: 40px;
}
#okta-sign-in .sign-in-with-idp .social-container i {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
line-height: 1;
font-family: "Font Awesome 5 Brands";
font-weight: 400;
}
</style>
<!-- custom login -->
<div class="container" id="container">
<div class="form-container sign-up-container">
<div id="okta-signup-container"></div>
</div>
<div class="form-container sign-in-container">
<div id="okta-login-container"></div>
</div>
<div class="overlay-container">
<div class="overlay">
<div class="overlay-panel overlay-left">
<h1>Already have an account?</h1>
<p>Please use the button below</p><button class="ghost" id="signIn">Sign In</button>
</div>
<div class="overlay-panel overlay-right" id="reg-overlay">
<h1>No account yet?</h1>
<p>Click below to start your journey with us</p><button class="ghost" id="signUp">Sign Up</button>
</div>
<div class="overlay-panel overlay-right" id="admin-overlay" style="display: none">
<h1>Hello Admin</h1>
<p>This login is for Admins only</p>
<p>Not an Admin? Go to the application you are trying to access</p>
</div>
</div>
</div>
</div>
<!-- end custom login -->
<!--
"OktaUtil" defines a global OktaUtil object
that contains methods used to complete the Okta login flow.
-->
{{{OktaUtil}}} <!-- Let's add a reference to jQuery for easy object manipulation. You do not have to do this, you can use vanila JS instead -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js">
</script>
<script type="text/javascript">
/*****
FOR IMPORTANT DETAILS ABOUT MODIFYING THE WIDGET IF YOU ARE USING THE V3,
PLEASE SEE THE FOLLOWING LINK: https://developer.okta.com/docs/guides/custom-widget-gen3/main/
*****/
// if you are interested in seeing what all is in the settings object log it here and use your browser's dev tools to look at it
console.log("OKTAUTIL object: ", OktaUtil);
// get request context - this allows us to get access to any data that was passed in the /authorize request...see BONUS CODE section later on for a sample code
var requestContext = OktaUtil.getRequestContext();
console.log("REQUEST CONTEXT: ",requestContext);
// "config" object contains default widget configuration
// with any custom overrides defined in your admin settings.
var config = OktaUtil.getSignInWidgetConfig();
console.log("CONFIG object: ", config);
/****** BONUS CODE *******/
/******
* Did you know you can change the widget (styling, features, behavior, etc) based on the application?
* See the below code on how to do just that
* *******/
// Per-application customization... let's get the client id from the request context
function getClientId() {
if (!OktaUtil) return undefined;
if (requestContext && requestContext.app && requestContext.app.value.id) {
return requestContext.app.value.id;
}
}
const clientid = getClientId();
console.log("Client id from the request: ", clientid);
// if client id matches the app that I want to have a customized appearance for then use it here
if(clientid == '[YOUR SPECIAL APP CLIENT ID'){
//disable registration
config.features.registration = false;
// you could also change the logo for example
// config.logo = "[URL LINK TO YOUR LOGO]";
}
/****** END BONUS CODE ******/
// You can either create a Routing Rule to enable external IdPs or you can set the identity providers here in the config object
// I have mine set up in the Okta Admin console via Routing Rule but here is the code if you'd like to set them here
// To learn how to set up external idps in your Okta tenant visit this link:
// https://developer.okta.com/docs/guides/identity-providers/#social-logins
config.idps = [
{type: 'Google', id: '[ID OF YOUR GOOGLE IDP FROM OKTA]'},
{type: 'Microsoft', id: '[ID OF YOUR MICROSOFT IDP FROM OKTA]'}
];
// display the social buttons first, before the username/password form
config.idpDisplay ="PRIMARY";
// enable registration
config.features.registration = true;
// Initialize the Okta Sign-In Widget object
var oktaSignIn = new OktaSignIn(config);
// Render the Okta Sign-In Widget
oktaSignIn.renderEl({ el: '#okta-login-container' },
OktaUtil.completeLogin,
function(error) {
// Logs errors that occur when configuring the widget.
// Remove or replace this with your own custom error handler if desired.
console.log(error.message, error);
}
);
// Initialize another Okta widget object and bootstrap into the Signup part...
// this is needed so we can flip between login and registration as only one instance can be rendered at a time.
var oktaSignUp = new OktaSignIn({
issuer: config.baseUrl,
flow: 'signup'
}
);
// WHEN THE WIDGET IS FULLY RENDERED START MANIPULATING ITS OBJECTS
oktaSignIn.on('afterRender', function (context) {
manipulateObjects();
});
// make the panels move left-right to show/hide the login and reg forms
const signUpButton = document.getElementById('signUp');
const signInButton = document.getElementById('signIn');
const container = document.getElementById('container');
signUpButton.addEventListener('click', () => {
console.log("Switch to sign up");
oktaSignIn.remove();
oktaSignUp.renderEl({ el: '#okta-signup-container' });
container.classList.add("right-panel-active");
});
signInButton.addEventListener('click', () => {
console.log("Switch to sign in");
oktaSignUp.remove();
oktaSignIn = new OktaSignIn(config);
oktaSignIn.renderEl({ el: '#okta-login-container' });
container.classList.remove("right-panel-active");
});
// This is where we manipulate the widget via Javascript
function manipulateObjects() {
//console.log("Trying to manipulate the widget...");
// Depending on the config, footer contains links for sign-up, "Forgot password", "Back to Sign in" and possibly
// other self-service options. We'll hide the sign-up option since we're dealing with it separately but will leave the rest.
// If you did want to hide it entirely you can use the following code, you can either hide the entire footer or just the pieces of it
// $("div.siw-main-footer").css("display","none");
$("div.auth-footer div.signup-info").css("display","none");
// same for the header, let's hide it
$("div.okta-sign-in-header").css("display","none");
// we want to add the placeholder for the username which is in the email format for my Okta tenant
$("input[name='identifier']").attr('placeholder', 'Email');
$("input[name='userProfile.email']").attr('placeholder', 'Email');
/******* TRANSFORM SOCIAL BUTTONS **************/
// we need the social buttons to look completely different from the default ones, we will make use of the FontAwesome library for icons
$("#okta-login-container div.okta-idps-container").wrapAll('<div class="social-container">');
// modify the google button
$("a[data-se='social-auth-google-button']").html('<i class="fab fa-google-plus-g"><\/i>');
$("a[data-se='social-auth-google-button']").removeClass();
$("a[data-se='social-auth-google-button']").addClass('social');
// modify the microsoft button
$("a[data-se='social-auth-microsoft-button']").html('<i class="fab fa-microsoft"><\/i>');
$("a[data-se='social-auth-microsoft-button']").removeClass();
$("a[data-se='social-auth-microsoft-button']").addClass('social');
/********* END TRANSFORM SOCIAL BUTTONS ************/
// if a user is trying to access Okta dashboard or they came here by some other means, hide the reg form and social buttons. Please keep in mind, this is merely hiding the reg form via frontend (js/css), if the user is crafty they could still access the form
if(clientid == ["CLIENT ID OF YOUR OKTA DASHBOARD APP"]){
// hide the registration panel
$("#reg-overlay").css("display","none");
// display the text if this is an Admin user trying to access the dashboard
$("#admin-overlay").css("display","flex");
// hide the social buttons container
$("#okta-login-container div.sign-in-with-idp").css("display","none");
}
//console.log("Finished manipulating the widget");
};
</script>
</body>
</html>