This extension partially based on the ckanext-security
The extension provides a 2FA authentication mechanism and passkey (WebAuthn) support for CKAN.
There are two methods of 2FA available:
- TOTP (Time-based One-Time Password) with authenticator apps like Google Authenticator, Authy, etc.
In addition, users can register and log in with passkeys — a passwordless authentication method based on the WebAuthn standard (fingerprint, Face ID, hardware security keys, etc.).
Python 3.10+
This extension uses Redis, so it must be configured for CKAN.
Compatibility with core CKAN versions:
| CKAN version | Compatible? |
|---|---|
| 2.9 and earlier | no |
| 2.10 | yes |
| 2.11 | yes |
If you want to add compatibility with CKAN 2.9 and earlier, you can contact me and I'll help you with that.
To install ckanext-auth:
- Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate- Clone the source and install it on the virtualenv
git clone https://github.com/DataShades/ckanext-auth.git
cd ckanext-auth
pip install -e .-
Add
authto theckan.pluginssetting in your CKAN config file (by default the config file is located at/etc/ckan/default/ckan.ini). -
Apply database migrations:
ckan db upgrade
- Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
There are several configuration settings available for this extension. Check the config declaration file.
If you have the ckanext-admin-panel installed, the configuration settings will be available in the admin panel too.
| Setting | Default | Description |
|---|---|---|
ckanext.auth.passkey_enabled |
false |
Enable passkey (WebAuthn) authentication |
ckanext.auth.passkey_rp_name |
CKAN |
Relying party display name shown to users during passkey registration. |
ckanext.auth.passkey_rp_id |
(site hostname) | Relying party ID (domain) for passkey authentication. Defaults to the hostname of ckan.site_url. |
Note: The
passkey_rp_idmust match the domain (without port) of the site URL. For example, if your site URL ishttps://data.example.com, the RP ID should bedata.example.com.
- If you want to change the email for email 2FA, you can do it by creating a new template file at
auth/emails/verification_code.html.
When passkeys are enabled (ckanext.auth.passkey_enabled = true):
- A Sign in with a passkey button appears on the login page.
- Logged-in users can manage their passkeys (register new ones, delete existing ones) via the Passkeys tab on their user profile page (
/passkey/list/<username>). - Passkeys use the WebAuthn standard and support any authenticator the browser supports — biometrics (fingerprint, Face ID), device PINs, or hardware security keys.
Email OTP send and verification results are logged at INFO by ckanext.auth.middleware, with usernames and timing fields. Enable this logger in your CKAN logging configuration to collect these events; these events do not include codes, passwords, or secrets.
Summarize a log file with:
ckan -c /path/to/ckan.ini auth otp-stats /path/to/ckan.logThe report lists failed attempts, the overall verification failure percentage, and approximate delays since successful sends.
To run the tests, do:
pytest --ckan-ini=test.ini