Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- signIn.renderEl(
- // Assumes there is an empty element on the page with an id of 'widget-container'
- {el: '#widget-container'},
- function success(res){
- if (res.status === 'SUCCESS') {
- if (res.type === 'SESSION_STEP_UP') {
- // Session step up response
- // If the widget is not configured for OIDC and the authentication type is SESSION_STEP_UP,
- // the response will contain user metadata and a stepUp object with the url of the resource
- // and a 'finish' function to navigate to that url
- console.log(res.type);
- console.log(res.user);
- console.log('Target resource url: ' + res.stepUp.url);
- res.stepUp.finish();
- return;
- }
- }
- else if (res.status === 'IDP_DISCOVERY') {
- var username = document.getElementById("idp-discovery-username").value;
- var xhttp = new XMLHttpRequest();
- var orgUrl = "https://{{YOUR_OKTA_DOMAIN}}.com/";
- var webFingerUrl = orgUrl+".well-known/webfinger?resource="+encodeURIComponent("okta:acct:"+username);
- var finalRedirectUrl = {{SAML_APP_EMBEDDED_LINK}};
- xhttp.open("GET", webFingerUrl, true);
- xhttp.responseType = "json";
- xhttp.send();
- xhttp.onload = function(){
- var response = xhttp.response;
- var link = response.links[0].href;
- var idp = link.slice(0, (link.length - 1)); // slincing is required to remove the '#' from the end of the idp link.
- window.location.href = idp+"&fromURI="+encodeURIComponent(finalRedirectUrl);
- }
- }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement