You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Okta Sign-In Widget is a powerful tool that allows developers to integrate Okta authentication into their web applications seamlessly. But did you know you can also customize the widget's look and feel to match your application's design, even if hosted on Okta? Whether you want to modify colors, add custom branding, or adjust the layout, Okta provides flexibility to make the widget fit your brand's identity.
17
18
@@ -130,7 +131,7 @@ insert the following code that points to the Font Awesome library, which is host
Next, let's add some general styles to achieve the desired look. Within the `<style>...</style>` ,
134
+
Next, let's add some general styles to achieve the desired look. Within the `<style>...</style>` block,
134
135
135
136
{% raw %}
136
137
```html
@@ -623,11 +624,11 @@ With the following code:
623
624
## Enhancing the experience with Okta Custom Sign-In Widget
624
625
Now, let's get into the meat and potatoes. We first need to hide some unwanted pieces of the widget (logo, header, links, etc.). Then, we must apply CSS to the existing HTML objects by replacing the classes (e.g., making the social button round). Easier said than done!
625
626
626
-
To manipulate the pieces of the widget, we need to know what those HTML elements are and to find out; you can utilize the developer tools of the browser you are using. After figuring out what CSS classes and objects I needed to modify, I created the following code. So replace the entire default `<script>` section of the widget with the code below. I commented on almost every line; there is A LOT, but it'll make this step straightforward. There is one **IMPORTANT** piece of information to note. It is in the comments, but I will call it out here.
627
+
To manipulate the pieces of the widget, we need to know what those HTML elements are, and to find out, you can utilize the developer tools of the browser you are using. After figuring out what CSS classes and objects I needed to modify, I created the following code. So, replace the widget's default `<script>` section with the code below. I commented on almost every line; there is A LOT, but it'll make this step straightforward. There is one **IMPORTANT** piece of information to note. It is in the comments, but I will call it out here.
627
628
628
629
>**IMPORTANT**: Setting the Routing Rule in the admin interface for external IdPs will break this code, so instead, set the identity providers here in the config object.
629
630
630
-
Additionally, I've included some extra code to showcase how you can style or manipulate the widget based on the client id, making perapplication customizations possible.
631
+
Additionally, I've included some extra code to showcase how you can style or manipulate the widget based on the client id, making per-application customizations possible.
631
632
632
633
Below the OktaUtil object,
633
634
@@ -645,15 +646,15 @@ Add the following code:
645
646
646
647
{% raw %}
647
648
```html
648
-
<!-- Let's add a reference to JQuery for easy object manipulation. You do not have to do this, you can use vanila JS instead -->
649
+
<!-- Let's add a reference to JQuery for easy object manipulation. You do not have to do this; you can use vanila JS instead -->
FOR IMPORTANT DETAILS ABOUT MODIFYING THE WIDGET IF YOU ARE USING THE V3,
653
654
PLEASE SEE THE FOLLOWING LINK: https://developer.okta.com/docs/guides/custom-widget-gen3/main/
654
655
*****/
655
656
656
-
// if you are interested in seeing what all is in the setttings object log it here and use your browser's dev tools to look at it
657
+
//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
657
658
console.log("OKTAUTIL object: ", OktaUtil);
658
659
659
660
// 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
@@ -692,9 +693,9 @@ Add the following code:
692
693
}
693
694
/****** END BONUS CODE ******/
694
695
695
-
// You can either create a Routing Rule to enable external IdPs or you can set the identity providers here in the config object
696
-
// 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
697
-
// To learn how to set up external idps in your Okta tenant visit this link:
696
+
// You can either create a Routing Rule to enable external IdPs, or you can set the identity providers here in the config object
697
+
// 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
698
+
// To learn how to set up external IdPs in your Okta tenant, visit this link:
/********* END TRANSFORM SOCIAL BUTTONS ************/
787
788
788
-
// 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
789
+
//If a user is trying to access the Okta dashboard or came here by other means, hide the reg form and social buttons. Please remember that this merely hides the reg form via frontend (js/css). If the user is crafty, they could still access the form
789
790
if(clientid == ["CLIENT ID OF YOUR OKTA DASHBOARD APP"]){
790
-
//hide the registration panel
791
+
//Hide the registration panel
791
792
$("#reg-overlay").css("display","none");
792
-
//display the text if this is an Admin user trying to access the dashboard
793
+
//Display the text if this is an Admin user trying to access the dashboard
Feel free to preview your work by clicking the **Save to draft** button and then the **Preview** button at the top, but just know there is one last step before we can see the final result.
805
806
806
807
## Content Security Policy to allow trusted external resources
807
-
The remaining task to do is to customize the default Content Security Policy (CSP) to allow trusted external resources and prevent violations. This will enable us to use external resources, such as the Font Awesome library, Google Fonts, and jQuery. You must add the URLs in the CSP if you use additional libraries or resources.
808
+
The remaining task is to customize the default Content Security Policy (CSP) to allow trusted external resources and prevent violations. This will enable us to use external resources, such as the Font Awesome library, Google Fonts, and jQuery. You must add the URLs in the CSP if you use additional libraries or resources.
808
809
809
810
>**SECURE BEST PRACTICE**:
810
811
- ✅ Remember to use trusted, well-maintained libraries, and pin specific versions you've used for future reference and troubleshooting issues.
@@ -819,7 +820,7 @@ CSP is located under the **Settings** tab on the **Sign-in page** section, **Cus
819
820
And that should be all! After you've added the necessary CSP information and have previewed your sign-in page, you can now click the **Publish** button under the **Page Design** tab to see your changes live. If you copied/pasted everything correctly, you should now have a sign-in widget that looks and functions like the one showcased at the beginning of this tutorial.
820
821
821
822
## Troubleshooting your Okta hosted sign in widget
822
-
Before publishing live to production be sure to test on your preview org or developer org first. To target specific elements/attributes, you can refer to this [Okta doc on modifying CSS](https://developer.okta.com/docs/guides/custom-widget/main/#modify-the-css).
823
+
Before publishing live to production, be sure to test it on your preview org or developer org first. To target specific elements/attributes, refer to this [Okta doc on modifying CSS](https://developer.okta.com/docs/guides/custom-widget/main/#modify-the-css).
823
824
824
825
## More ways to customize your sign-in page
825
826
The manipulation and styling were only done for login and registration. As bonus practice, I suggest you try to modify the MFA screens. To recap what I have demonstrated, customizing the Okta Sign-In Widget allows you to make authentication an integrated part of your app's user experience. From simple color changes to more complex UI tweaks, Okta's flexibility allows you to maintain your brand's visual identity while ensuring a secure and seamless login process.
0 commit comments