Allows users to login with email as well as username.
Project description
ckanext-emailasusername
We have have found that many of our users quickly forget their CKAN username. We have also observed several users assume they should use their email to login. This fails with a bad login error message, which causes some confusion.
This CKAN extension allows users to login or reset their password with either their email address or their username. It doesn't do away with the username but just offers the option to use email instead.
Out of the box, CKAN allows multiple accounts to be registered with the same email address. This causes a problem for using email to identify the user. This extension therefore adds a validator to the registration form to stop new accounts being created if there already exists an account with the same email.
If multiple accounts are registered to your email, then identifying the user by email fails - you must use your username to login/reset your password instead. It's recommended, if feasible, to work with your userbase to phase out multiple accounts with the same email.
Requirements
This extension is tested with CKAN 2.9 for python3 only.
Installation
To install ckanext-emailasusername:
-
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
-
Install the ckanext-emailasusername Python package into your virtual environment::
pip install ckanext-emailasusername
-
Add
emailasusername
to theckan.plugins
setting in your CKAN config file (by default the config file is located at/etc/ckan/default/production.ini
). -
Configure CKAN to use the authenticator provided in this plugin. Add
ckanext.emailasusername.authenticator:EmailAsUsernameAuthenticator
to the[authenticators] plugins
configuration in CKAN's who.ini file. In ckan core, thise who.ini file is stored inckan/ckan/config
and linked to fromckan/
:[authenticators] plugins = auth_tkt ckanext.emailasusername.authenticator:EmailAsUsernameAuthenticator
-
Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
Configuration
Ensure you have read and completed step 4 of the Installation section above. This step is essential CKAN configuration required for this plugin to work.
The plugin also offers the following default configuration settings that can be changed in your ckan.ini
config file:
ckanext.emailasusername.search_by_username_and_email = True
ALtering this config parameter will allow users to search for other users by entering an email address, wherever the user_autocomplete
action is called. For security reasons all users except sysadmins must enter the entire email address in order to match the user account (otherwise the feature could be used to infer the email addresses of other users). This may be useful, for example, when org admins are adding a new member to their org and do not know the username of the user they wish to add.
ckanext.emailasusername.auto_generate_username_from_email = False
Altering this parameter will allow creation of users without specifying a username. Instead the username is autogenerated from the email address using some logic taken from CKAN core. It only affects user_create
where no name
field is given. WARNING: This CKAN core logic reveals a small part of the user's email to other CKAN users (everything prior to the @ character). Fjelltopp does not recommend using this default logic in public CKAN instances. We have provided a plugin interface IEmailAsUsername
to enable you to override the default username generation logic with your own logic meeting your own requirements.
ckanext.emailasusername.auto_generate_username_from_fullname = False
Altering this parameter will change the user registration form Jinja2 template, so that the "Username" field is auto-populated from the contents of the "Full Name" field.
ckanext.emailasusername.require_user_email_input_confirmation = True
Altering this parameter will determine whether the user is required to enter their email twice when filling in the registration form. This double-entry of their email acts as a crude form of validation to reduce the risk of accidental errors. Ideally we would implement proper email address validation, but have not yet found the funding or time to do this. Double-entry is enabled by default, but if you don't like it, use this config parameter to get rid of it.
Running the Tests
To run the tests, do::
pytest --ckan-ini=test.ini
Releasing a New Version of ckanext-emailasusername
ckanext-emailasusername is availabe on PyPI as https://pypi.python.org/pypi/ckanext-emailasusername. To publish a new version to PyPI follow these steps:
-
Update the version number in the
setup.py
file. SeePEP 440 <http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers>
_ for how to choose version numbers. -
Create a source distribution of the new version::
python setup.py sdist bdist_wheel
-
Upload the source distribution to PyPI::
python -m twine upload dist/*
-
Tag the new release of the project on GitHub with the version number from the
setup.py
file. For example if the version number insetup.py
is 0.0.2 then do::git tag 0.0.2 git push --tags
With thanks...
This extension has been built by Fjelltopp with funding from UNAIDS as part of the AIDS Data Repository project: https://adr.unaids.org
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ckanext-emailasusername-1.2.1.tar.gz
.
File metadata
- Download URL: ckanext-emailasusername-1.2.1.tar.gz
- Upload date:
- Size: 31.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b2c9128aab57c793e151c74a580611faccdf30a8d25146f915d7b1b14cf1f88 |
|
MD5 | 863f3c3a386d402395afee963cd97589 |
|
BLAKE2b-256 | d973cebcdd3602b3d7b2b557df386ce57311919283c41ed2baf07cf6705e65d0 |
File details
Details for the file ckanext_emailasusername-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: ckanext_emailasusername-1.2.1-py3-none-any.whl
- Upload date:
- Size: 34.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6475e43e32d7dfbbdb4bcbd7a59d775c0762a672b6fb659a075faaf6e902ef0 |
|
MD5 | fe43229c96fcd15df4fa7254aa392dac |
|
BLAKE2b-256 | e322a28317a2ddda951f2512739900ba897d6c1e74708cd02d80722b3fe49a2e |