hub.eb?material_id=566&track_id=567

Custom Authentication


Custom authentication can authenticate users by passing information within an HTTP request as:

  • Headers
  • Cookies
  • URL parameters

For example, a user's email and a hashed password may be passed as URL parameters (Note: We don't recommend using URL parameters to pass user credentials):

https://example.com/apps/logon.eb?email=example@example.com&hash=5f4dcc3b5aa765d61d8327deb882cf99

To use custom authentication, enable the Use Custom Authentication option in the User Authentication section of the Server Admin App. First select the Logon Service to use and then specify which parameters will be passed to it. At least one parameter must be specified, although more are often useful.

The source and value of the first parameter are mapped to the PARAM1_SOURCE and PARAM1_VALUE fields of the Logon Service respectively. The source and value of the second and third parameters also have corresponding fields.

For example, to extract the email and hash values from the URL given above, the following settings would be used:

The following code snippet shows how to handle URL parameters in the Integration Event script of a Logon Service:

if (fields.PARAM1_SOURCE.value == "URL" && fields.PARAM2_SOURCE.value == "URL"){
   var email = fields.PARAM1_VALUE.value;
   var passwordHash = fields.PARAM2_VALUE.value;
}

Steps


1

Create a Logon Service and set its Web Service Name to myCustomLogonService.

Attach a script to the Integration Event and paste the following code into it:

var email = fields.PARAM1_VALUE.value;
var passwordHash = fields.PARAM2_VALUE.value;

// You would usually validate the email address and password here

// Then set the userid field
fields.USERID.value = email;

 

2

Open the Server Admin App and configure Custom Authentication as shown above.

3

Create a form called myForm.

Add a field called username and drag it onto the page.

Attach a script to the Before Page event and paste the following code:

fields.username.value = system.securityManager.getUserName();
4

Go to http://localhost:3050/ebasetest/myForm.eb?email=example@example.com&hash=5f4dcc3b5aa765d61d8327deb882cf99

Note: Your port number may be different to the one above. You can check which port you are using by running the form.

Notice that the user is logged in and the username field has been populated.

Current Module

Related