User Management
Starting from version 1.2.55
of the command-line tool, we have added support for user management. This feature checks user information in YAML configuration files and automatically creates the user in Edge Admin if the user does not exist. Additionally, after user creation, it 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 store user information in any directory, as long as you specify the path using the -U/--users-config-path
parameter when executing the tool. 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 7 configuration items are default settings. When users in the users
section do not specify corresponding configurations, these default settings will be used.
login_type
is the type of login, currently only Normal is supported. We will support more types in the future.change_pwd_on_login
indicates whether to require newly created users to change their password on first login.allow_login
indicates whether to allow the user to perform login operations.group
is the name of the group to which the user belongs, such as the default groupssuper-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 also needs to include theemail
configuration.- When you need to resend emails to users for some reason, you can turn on the
send_email_to_existing_user
switch.
The example includes 3 users named user-1
, user-2
, and user-3
. user-1
uses independent configuration information, while the other 2 use the default configuration.
Note that configuring only the above information is not sufficient to send emails, as the sender’s information has not been specified. For information on configuring the sender’s information, please refer to the Sending Emails documentation.
After preparing the sender’s email configuration, you can run the command-line tool as follows:
- Using 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
- Without using 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