Setting up Gateway Autologin module scripts - Platform - BlueCat Gateway - 24.1

Gateway Administration Guide

Locale
English
Product name
BlueCat Gateway
Version
24.1

Gateway's Autologin feature lets you configure Gateway to automatically log users in when Gateway is accessed. To use this feature, you must do the following:

  1. Create an autologin module Python script that implements the functions get_autologin_user and get_autologin_password, described below.

    These functions must return the username and password (respectively) of the user to be logged in. For more details, see Autologin module requirements below.

  2. Enable Autologin in the General settings and upload this script to Gateway.

    You can do so from the Customization section of the General settings workflow. For more details, see Enabling Autologin and uploading an Autologin module. You must restart the Gateway container for Autologin changes to take effect.

If Autologin is enabled, Gateway will call these functions whenever a Gateway endpoint is accessed and a user is not logged in. It will then attempt to log in to Gateway using the retrieved credentials.

Tip: The autologin module and its functions can perform other custom actions needed for your system and proc, as long as they fulfil the requirements below.

Autologin module requirements

The Autologin module must be written in Python (typically a *.py file). It must implement both the get_autologin_user and get_autologin_password functions, which retrieve the username and password (respectively) of the user to be logged in.

Attention: For security reasons, BlueCat strongly recommends that passwords never be hardcoded within the configuration file. For example, you can store autologin credentials in a JSON file within the workspace directory (optionally encrypting it), then retrieve those values in helper functions.

get_autologin_user

Gateway calls this function as follows:

get_autologin_user: Callable[[bool], Optional[str]]
Parameter Description
[bool]

A bool value that indicates whether or not Autologin is enabled. If True, The function must return an appropriate string (see Return value below).

Optional

Reserved for future use.

Return value A string value.

If the [bool] value is True, Autologin is enabled. The function must return a string value with the username of the account to automatically log in.

If the [bool] value is False, the function must return None.

get_autologin_password

Gateway calls this function as follows:

get_autologin_password: Callable[[bool], Optional[str]]
Parameter Description
[bool]

A bool value that indicates whether or not Autologin is enabled. If True, The function must return an appropriate string (see Return value below).

Optional

Reserved for future use.

Return value A string value.

If the [bool] value is True, Autologin is enabled. The function must return a string value with the password of the account to automatically log in.

If the [bool] value is False, the function must return None.

Sample Autologin code

It illustrates a possible test implementation of get_autologin_user and get_autologin_password function, for internal use.

Attention: This code hardcodes test values for the username and password within the script itself as unencrypted text. For Production use, BlueCat strongly recommends that passwords be stored externally, then retrieved with the use of helper functions.
def get_autologin_user(autologin):
    if autologin:
        return 'testname'
    else:
        return None 

def get_autologin_password(autologin):
    if autologin:
        return 'testpassword'
    else:
        return None