User Management

Starting from version 1.2.55 of the command-line tool, we have added support for user management. This feature can check user information in the YAML configuration file, and when a user does not exist, it will automatically create the user in Edge Admin. In addition, after the user creation is completed, it also supports sending email notifications to the user.

The following is the directory structure of the configuration file:

|-- /path/of/your-edge-users/
  |-- user-list-1.yaml
  |-- user-list-2.yaml
  |-- ...

You can save your user information in any directory. When running the tool, simply specify the path using the -U/--users-config-path option. For example, edge-config [...] -U /path/of/your-edge-users.

Example

---
password: DEFAULT PASSWORD
login_type: Normal
change_pwd_on_login: true
allow_login: true
group: super-admin
send_email_to_new_user: true
send_email_to_existing_user: false
users:
  - username: user-1
    email: oredge-user1@openresty.com
    group: normal user
    password: USER-1 PASSWORD
    change_pwd_on_login: false
    allow_login: true
    send_email_to_new_user: false
    send_email_to_existing_user: true
  - username: user-2
    email: oredge-user2@openresty.com
  - username: user-3
    email: oredge-user3@openresty.com

In this example, the first seven configuration items are default configurations. When a user in users does not specify the corresponding configuration, these default configurations will be used.

  • login_type is the login type; currently, only Normal is supported. We will support more types in the future.
  • change_pwd_on_login indicates whether newly created users must change their password on their first login.
  • allow_login indicates whether the user is allowed to perform login operations.
  • group is the name of the group to which the user belongs, such as the default groups super-admin(super admin), admin(normal admin), user(normal user).
  • send_email_to_new_user controls whether to send emails to new users. Of course, in addition to this switch, the user information must include the email configuration.
  • When it is necessary to resend emails to users for some reason, you can turn on the send_email_to_existing_user switch.

The example includes three users, named user-1, user-2, and user-3. user-1 uses independent configuration information, while the other two use the default configuration.

It should be noted that configuring the above information alone is not enough to send emails, because the sender’s information has not been specified. For information on configuring the sender’s information, please refer to the Sending Emails document.

After preparing the configuration of the email sender, you can run the command-line tool as follows:

  1. Use the -l option to perform only user management-related operations:
edge-config -t 6cc1cf09-1a39-4c17-8ed6-c11838edac12 \
    -u https://192.168.1.1 -s -i /path/of/configs -n default -d test.com -l users -U /path/of/users
  1. Do not use the -l option to perform all operations:
edge-config -t 6cc1cf09-1a39-4c17-8ed6-c11838edac12 \
    -u https://192.168.1.1 -s -i /path/of/configs -n default -d test.com -U /path/of/users