Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

APM customization - Verify password

Hello, Just wanted to share with all some extra code I added to the logon.inc so that my change password logon page can:

a. Enforce specific password creation criteria

b. Ensure new password and verify password fields match

My change password logon page has 3 fields:

Old Password, New Password, Verify Password

New passwords need to be 8-12 characters long and must include a single digit and a special character.

From the standard logon.inc code we see that the form calls the masterSubmit function when click to submit the form.

<form id="auth_form" name="e1" method="post" action="/my.policy" onsubmit="javascript: return masterSubmit(this);" autocomplete="off">

So I add the following lines of code (between the first pair of //) to this function to give me the inspections I required above:

function masterSubmit(form)
{
    if( !verifyNewPassword() /* || ... */){
        return false;
    }

    // added by ccb
    var characters = /^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{8,12}$/; 
    var inputs = form.getElementsByTagName("input");

    if ( !inputs[1].value.match(characters)) {
        alert("Password entered does not match the required criteria.");
        inputs[1].focus();
        return false;
    }

    if ( inputs[1].value != inputs[2].value ){
        alert("%[wrong_match]");
        inputs[2].focus();
        return false;
    }
    // --------------

    OnSubmit(); // this required by edge

    if (globalRestartOnSubmit) {
        try {
            window.external.WebLogonAutoLogon = (("" != globalInputs[0].value) && ("" != globalInputs[1].value));
        }
        catch (e) {}
        // restart session
        window.external.WebLogonResetSession();
        return false;
    }

    disableSubmit(form);
    return true;
}

The inputs count starts at 0 therefore inputs[1] and inputs[2] are the New Password and Verify New Password field respectively. Only tested so far with desktop browsers IE, Chrome and FireFox.

You will only be able to successfully submit the form if a. and b. pass the inspections successfully.

2
Rate this Discussion
Comments on this Discussion
Comment made 13-Sep-2018 by Adam Ingle 122

Seriously awesome! F5 should build-in the password validation for any 2 password fields in the APM!

0

Replies to this Discussion

placeholder+image

Thanks for your contribution ccb :-)

0
placeholder+image

That's just what I've been looking for. I've finally made it by changing the javascript code: link

0