myDBR enables the use of an external server for user authentication. The Single Sign-On server must implement the Authentication protocol specified below, with no restrictions on its specific implementation. A secret token shared between the server and myDBR ensures the validity of requests originating from both entities. This secret token is defined in myDBR Environmental settings.
myDBR also offers SSO implementation for Google authentication.
In this setup, SSO is selected as an authentication method in Environmental settings.
url
The URL to which the user should be redirected once login has been completedtoken
A random token which is used by the SSO server to calculate a verification hashhash
A hash value calculated as sha1(url + token + secret) so you can verify the call comes from myDBR. If the hash does not match, one can abort the process (other than myDBR made the call)user
Login of the username
Full name of the usergroups
Optional list of groups the user belongs to separated by '|'
email
Optional user's email addresstelephone
Optional user's telephone numberadmin
A flag 1 / 0 indicating if the user is an admin or not
extra1
Optional extra parameters (extra1, extra2, extra3...). Will be concatenated in hash calculation. extras = extra1+extra2+extra3.
hash
A verification hash calculated as sha1( user + name + groups + email + telephone + admin + extras + token + secret )
SSO authentication in myDBR allows you to pass on additional parameters. These extra parameters can include any information you want to include in the user's context via SSO, such as user organization or other relevant details from your application. These parameters will automatically become part of myDBR's context. To add an extra parameter:
$mydbr_defaults['automatic_parameters']['sso_extra1'] = 'in_SSO_OrganizationID';
if you have more than five extra parameters, increase the $mydbr_defaults['parameters']['max_sso_extra_parameters']
in
The authentication protocol contains optional parameter groups
that can be used to define SSO user's groups
separated by '|'.
The parameter contains a list of groups the user belongs to. When logging in myDBR will do the following things:
groups
-parametergroups
-parameter is empty, the user is removed from all groups
An example standalone SSO Server has been included in the user/sso/sso_example.php.
If SSO is set as a login method, you can still log in with myDBR login by adding &local=1
to the login URL. For example,
if you have installed myDBR at localhost/mydbr
you would log in locally using http://localhost/mydbr/index.php?a=login&local=1
To prevent users from logging in with the myDBR login when SSO is being used, remove unnecessary myDBR logins and secure the admin password.
When using SSO, both login and logout need to be done simultaneously from both the main application and in myDBR. You can make myDBR log out and redirect the user's browser to the desired location by defining the $mydbr_defaults['logout']['url'] variable in the .
If you need to define the redirect destination dynamically, you can use the 'url'-parameter in
myDBR's logout-call (/mydbr/logout.php?url=https%3A%2F%2Fmyserver.com%2Fservice
). In order to protect myDBR
from open redirect vulnerability, the possible values of the 'url'-parameter needs to be defined in the $mydbr_defaults['logout']['allowed_redirect_urls_in_url_parameter'] array in the .
The third way of defining the redirect destination is to define an automatic parameter logout_url_redirect
which will be used when the user logs out in case no url-parameter is passed to logout.php. This method can be used if the redirect destination depends varies.
To override myDBR logout link text and location in autologin and SSO, change the $mydbr_defaults['logout'] parameters.
The following example has been tested with SugarCRM CE 5.5 and makes the following assumptions:
/var/www/htdocs/mydbr
and accessible from your web-browser via http://localhost/mydbr
/var/www/htdocs/sugar
and accessible from your web-browser via http://localhost/sugar
/var/www/htdocs/sugar/modules/mydbr
controller.php
controller.php
and save the file.
<?php require_once('include/MVC/Controller/SugarController.php'); define( 'MYDBR_SECRET', 'secret-token-defined-in-mydbr-environmental-parameters'); class myDBRController extends SugarController { function action_login() { global $current_user; $role = new ACLRole(); $roles = $role->getUserRoles( $current_user->id ); $separator = ''; $groups = ''; foreach( $roles as $role ) { $groups .= $separator . $role; $separator = '|'; } $user = $current_user->user_name; $name = $current_user->title; $token = $_REQUEST['token']; $url = $_REQUEST['mobile']; $hash = $_REQUEST['hash']; if ($hash!=sha1($url.$token.MYDBR_SECRET)) { die(); } $hash = sha1( $user . $name . $groups . $token . MYDBR_SECRET ); $url = $url . '?user=' . urlencode($user) . '&name=' . urlencode($name) . '&hash=' . $hash .'&groups=' . urlencode($groups); header('Location:' . $url); die(); } }
$mydbr_defaults['single_sign_on']['url_parameter'] = 'mobile'; // For SugarCRM 6.x which does not allow the default 'url' parameter
SSO secret token
http://localhost/sugar/index.php?module=mydbr&action=login
myDBR is now accessible with-in SugarCRM. If you are logged in to SugarCRM and visit http://localhost/mydbr
you will be automatically logged in
to myDBR as well
The SSO's Google authentication allows authentication using Google login. Assuming your myDBR install location is https://yourserver/mydbr, to enable google login to do following:
myDBR
→ Admin Tools
→ Environment settings
→ Single Sign-On settings
https://yourserver/mydbr/lib/sso/google/
https://yourserver/mydbr/lib/sso/google/index.php
myDBR has the ability, in the OEM version, to define user organization in SSO protocol. This allows report/folder privileges to be assigned per organization and use the same user groups among different organizations and to create an automatic parameter for user's organization ID.
The optional external organization ID is passed on in the SSO extra parameters. If the name for SSO's extra parameter (sso_extra*
) matches the defined automatic parameter value for the $mydbr_defaults['organization']['external_id_automatic_parameter']
, the passed value will be matched in SSO login against external_id
-column in the mydbr_organizations
-table and the matched organization id is updated to myDBR's user table.
The default name (defined in defaults.php
) for organization ID parameter is in_SSO_OrganizationID
. To make SSO to treat an extra parameter as organization ID define the extra parameter with same name in and pass the user's organization ID as extra paramerer in your SSO protocol implementation.
$mydbr_defaults['automatic_parameters']['sso_extra1'] = 'in_SSO_OrganizationID';