Help please Web Debs with JS Experience

Soldato
Joined
26 Aug 2012
Posts
4,428
Location
North West
I'm using an identity provider to authenticate users to my Web App called Okta.

I'm using their Sign on Widget (please see links below) to sign in users).
  1. http://developer.okta.com/code/javascript/okta_sign-in_widget.html
  2. http://developer.okta.com/code/javascript/okta_sign-in_widget_ref#session-management

However, I'm struggling on how using this signin widget, I can save the sessionID created to be saved into a cookie or pasted back with the redirect so it can be used later to manage the users session. I can see there are two variables set in auth paramos surround response type id_tokens but not sure how to take advantage of it. Please see below my code.

Any help would be really appreciated this X-Mas :)


PHP:
<!DOCTYPE html>
<html>
<head>
<?php echo $MetaData['charset']."\n";?>
<?php echo $MetaData['viewport']."\n";?>
<?php echo $MetaData['description']."\n";?>
<?php echo $MetaData['author']."\n";?>
<?php echo $MetaData['title']."\n";?>

<link rel="shortcut icon" href="">
<script src="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/1.7.0/js/okta-sign-in.min.js" type="text/javascript"></script>
<link href="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/1.7.0/css/okta-sign-in.min.css" type="text/css" rel="stylesheet">
<link href="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/1.7.0/css/okta-theme.css" type="text/css" rel="stylesheet">
<link href="<?php echo base_url().'assets/css/custom.css' ?>"type="text/css" rel="stylesheet">
</head>
<body style="background-color:#f5f5f5;">
	<div id="okta-login-container"></div>
	<script type="text/javascript">
		var orgUrl = '<?php echo $OktaInstanceConfig['OktaInstanceURL'];?>';
    var redirectUrl = '<?php echo base_url().'index.php/Dashboard' ?>';
    var oktaSignIn = new OktaSignIn({
			baseUrl: orgUrl,
			logo: '<?php echo base_url()."assets/images/".$CompanyConfig["CompanyName"]."/logo.svg"?>',
			authParams: {
	 responseType: 'id_token',
	 responseMode: 'okta_post_message',
	 scope: [
		 'openid',
		 'email',
		 'profile',
		 'address',
		 'phone',
		 'groups'
	 				]
 									}
		});

		oktaSignIn.renderEl(
		  { el: '#okta-login-container' },
		  function (res) {
		    if (res.status === 'SUCCESS')
        {
          console.log('User %s successfully authenticated %o', res.user.profile.login, res.user);
          res.session.setCookieAndRedirect(redirectUrl);
        }
		  }
		);
	</script>
</body>
</html>
 
Back
Top Bottom