This feature can be used for importing users from a csv file. There are many features included in it such as:
- Importing users in batches: all of the users of a particular csv file would be stored in batches and can be retrieved/ deleted easily using the batch functions.
- Set an expiration date: Expiration date can be set for a batch after which the users would not able to authenticate to the RADIUS Server.
- Autogenerate usernames and passwords: The usernames and passwords are automatically generated if they aren’t provided in the csv file. Usernames are generated from the email address whereas passwords are generated randomly and their lengths can be customized.
- Passwords are accepted in both cleartext and hash formats from the CSV.
- Send mails to users whose passwords have been generated automatically.
It can be done using both a management command and the admin interface.
This command imports users from a csv file. Usage is as shown below.
./manage.py batch_add_users --name <name_of_batch> \ --file <filepath> \ --expiration <expiration_date> \ --password-length <password_length>
Note that the expiration and password-length are optional parameters which default to never and 8 respectively.
Using the admin interface¶
Selecting the CSV as the strategy and uploading the CSV file is all one will have to do to import the CSV file from the admin interface. It can be checked at /admin/radiusbatch/add.
It is important to take care of the following when importing users from the CSV.
The CSV shall be of the format:
Imported users with hashed passwords¶
The hashes are directly stored in the database if they are of the django hash format.
For example, a password myPassword123, hashed using salted SHA1 algorithm, will look like:
So a full CSV line containing that password would be:
Importing users with clear-text passwords¶
Clear-text passwords must be flagged with the prefix
For example, if we want to use the password
we must use:
Autogeneration of usernames and passwords¶
Email is the only mandatory field of the CSV file.
Other fields like username and password will be auto-generated if omitted.
Batch mail settings¶
Emails can be sent to users whose usernames or passwords have been autogenerated and contents of these emails can be customized too. Here are some defined settings for doing that: