Combining DiscoJuice with local authentication

The typical configuration of DiscoJuice is to use it as a way of selecting which of a number of external login providers to use.

Sometimes a service would like to combine this with local user/password dialog authentication for some of the users.

Let’s walk through the configuration of a such setup:

Let’s start by getting a configuration object for the DiscoJuice hosted at (see Advanced Configuration).

var djc = DiscoJuice.Hosted.getConfig(
    "Demo of local auth",
    "", ["edugain"], ""

Let’s use the inlinemetadata entry to add a entry for the option of authenticating locally. The entityID does not really matter, but MUST be set to something unique. We also need to set the auth value to something that we can catch in the callback later on. We use the value local.

djc.inlinemetadata = [
        'entityID': 'local://',
        'auth': 'local',
        'title': 'Local authentication',

Next, we create a HTML form for local authentication:

var localauth = 
    '<form method="post" action=""> '+
    '<p>Sign in using account at <strong></strong>.</p>' +
    '<p style="margin: 5px; color: #888" ><input type="text" name="Name" style="font-size: 160%; width: 100%" id="lu" /> <label for="lu">Username</label></p>' +
    '<p style="margin: 5px; color: #888" ><input type="password" name="Name" style="font-size: 160%; width: 100%" id="lp" /> <label for="lp">Password</label></p>' +
    '<p  style="" ><input type="submit" style="margin: 20px 2px" name="smt"value="Login ยป" /></p>' +

Now, the important part, we define the callback to do a special catch on the local authentication type, and to present the local login form in DiscoJuice:

djc.callback = function(e) {

    var auth = e.auth || null;
    var returnto = window.location.href || '';
    switch(auth) {

        case 'local':

        case 'saml':
            window.location = '' + escape(returnto) + '&saml:idp=' + escape(e.entityID);


And we run DiscoJuice with the configuration above.


Now, local authentication will show up together with the other alternatives:

When the user selects this, the login form is shown inline in DiscoJuice.

Leave a Reply