With the help of the client-side Single Sign On (SSO) solution of E-Golf4U it is easy to create an SSO connection between the website and the E-Golf4U products. This SSO solution works in all modern browsers, including Safari.

Update 7-2-2012: Version 2.2 released. Version 2.2 has an automatic credential check and a possibility to load the response in an element. You can check the updated functions below.

Javascript includes


https://api.e-golf4u.nl/static/sso.2.2.js

Now you have to connect the SSO library to the login form on the website, because the library catches the onsubmit event and login to the E-Golf4U products first before submitting in the website. The code below for example can be used in combination with jQuery, but of course you can combine it with native javascript as well.


Important: because of the validation call the login can only occur on the submit.

 

$(function(){
    var sso = new EGSSO({
        environment : '[name of egolf4u environment]',
        form : 'egolf4u_login_form', //Id of the login form
        username_field : 'egolf4u_login_username', //Id of username input field
        password_field : 'egolf4u_login_password', //Id of password input field
        logout_url : '[url to logout script in website]', //This is the url that will be called by the .logout() function
        message_placeholder : 'egolf4u_login_message' //Optional placeholder for messages of the server. When undefined, an alert will be presented
    });
   
    $('#egolf4u_login_submit').click(function(){ //An onclick of the submit for example
        return sso.login();
    });

    sso.start();

    $('.logout_button').click(function(){
        return sso.logout();
    });
});

 


Explanation how it works
  1. The SSO code hooks in onto the login form by changing the action temporary to the E-Golf4U API
  2. When the user enters his credentials those data will be submitted to the E-Golf4U API en validated against the E-Golf4U database of the club
  3. Depending on the E-Golf4U products the club is using, there will be several redirects, through all products
  4. At the end of the redirect cycle, the API will redirect the user back to the original referrer url with an unique GET parameter egolf4u_login_callback
  5. The SSO library recognizes this callback and will fill the login form again with the original values and will submit the form to the original action

Validate users

It is possible to validate the login credentials, before starting the login procedure. You can do this by sending a GET request to the endpoint below. This endpoint supports JSONP as well for client side requests.

https://api.e-golf4u.nl/auth/validate?username=USERNAME&password=PASSWORD&environment=ENVIRONMENT

Of course you can do this from server side code as well to validate an user server side again and if necessary log him in server side.

E-Golf4U Member iframe include

Instructions for including the E-Golf4U iframe and which parameters are available and needed can be found in the help article in the link below.
To make the iframe resize automatically based on the content, you will have to load the resizehandler.js and helper.html. More details can be found in this help article as well:

http://help.e-golf4u.nl/solution/articles/227852-how-to-include-the-e-golf4u-iframe-in-a-website-en-