Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The Shared Login plugin works by accepting a GET request to a specially crated crafted URL, which then initializes a session within Blesta. Users can either be redirected to the specially crafted URL, or an AJAX request can be made from the user's browser.

...

Note

If you have issues authenticating, ensure the time is correct on both your Blesta server and the server the user is connected to. The shared login system will tolerate up to 30 minutes of clock drift.

...

Redirect Example

Code Block
languagephp
<?php
// The key from [Settings] > [Company] > [Plugins] > [Shared Login]
$key = "0123456789abcdef0123456789abcde";
$t = time();
$u = "client_username";
$r = "http://mydomain.com/";
$h = hash_hmac("sha256", $t . $u . $r, $key);

header("Location: " . "https://yourdomain.com/path_to_blesta/plugin/shared_login/?u=" . $u . "&t=" . $t . "&r=" . $r . "&h=" . $hhttp_build_query(compact("t", "u", "r", "h")));
exit;
?>

AJAX Example

Code Block
languagejavascript
<?php
// The key from [Settings] > [Company] > [Plugins] > [Shared Login]
$key = "0123456789abcdef0123456789abcde";
$t = time();
$u = "client_username";
$r = "http://mydomain.com/";
$h = hash_hmac("sha256", $t . $u . $r, $key);

$url = "https://yourdomain.com/path_to_blesta/plugin/shared_login/";
?>

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	    $.get(
		        '<?php echo htmlentities($url, ENT_QUOTES);?>', 
		
        {u: '<?php echo htmlentities($u, ENT_QUOTES);?>', t: '<?php echo htmlentities($t, ENT_QUOTES);?>', h: '<?php echo htmlentities($h, ENT_QUOTES);?>'}, 
		
        function(data) {
			            if (data.success)
				                alert('logged into Blesta');
			
            else
                alert('login failed!');
		        },
		        'json'
	    );
});
</script>