Skip to main content

Testing and Debugging SecureAuth Extension Scripts

Creating new Extension Scripts may sometimes require additional testing and debugging in order to make the script work as required. SecureAuth provides developers with rich Extension Debugging capabilities to make it a lot easier!

Basic Extension Scripts Testing Using Test Mode

  1. Run the script in test mode to check if it works as expected.

    In the video below, we are checking a simple script returning a secret value.

  2. Check the data in the INPUT section.

    It is meant to mimic a real request processed by SecureAuth. Modify the parameters if necessary for the purpose of your test.

    If needed, you may save your input for later use by selecting the three dots button next to the Select input type dropdown.

  3. Select RUN.

    Your script runs against the input data. The result is printed in the OUTPUT section. Runtime information is printed in the CONSOLE section.

    In a real world scenario, attribute values from OUTPUT:

    • Override the original authentication context for the Extensions that modify the authentication context (provided they exist in the authentication context - new attributes are NOT created).

    • Override claims within the security token and/or create new claims within the security token issued by the SecureAuth platform for Extensions used to enrich token claims.

    For Extensions modifying the login flow for users, there is no sample output.

Unit Test Extensions

SecureAuth provides a Sample Script Extensions Test GitHub that can be forked within the Extensions. You can add unit/integration tests for more complex scripts. For more information, see the READ.ME

Debug Extensions Scripts

SecureAuth provides an Extension Script Debugger that allows to see detailed logs for the executed Extension Script.

To debug Extension Scripts:

  1. Select LOGS in the Extension Scripts Editor.

  2. Enable the Debugger for a selected time period.

    You can enable the Debugger for any period between 1 minute and 60 minutes. Enabling the Debugger for a selected time period results in SecureAuth providing extended and rich logs for the given script whenever it is executed within the defined time period.

    It is possible to enable the Debugger for multiple Extension Scripts at the same time. If you wish to get rich logs for multiple Extension Scripts, just repeat the process for any additional Extension Script.

  3. Execute your Extension Script.

    Executing a script does not mean running it in the Test Mode. To see detailed logs, you need to actually execute the script the same way it is invoked. For example, if your Extension execution happens after user authentication, you need to first authenticate a user to see a detailed log for this script execution.

    Tip

    If you wish to simply test your Extension script and debug it, you may, for example, Assign the extension to IDP as a post authentication extension. It may be, for example, assigned to a Sandbox IDP. Then, log into the SecureAuth Demo Application. You should see the logs for the script in the LOGS tab for your extension. If you enabled the debugger, the logs will be extended.

  4. Once your Extension is executed, you can see the detailed logs for it.

    You can browse logs live in real time, or select a date range between which a particular extension was executed.

    Below, you can find examples of standard logs and extended logs with the Debugger enabled:

    As you can see in the example above, the extended logs contain, for example, information about requested scopes, user authentication context, and more.