Zweifach
Zweifach (german for “two times”) is an app to make integration of django-otp a bit more biased.
Integration of two factor auth is enforced by a middleware which will ensure two things:
make sure a user who is required to enable 2FA for its account will be redirected to the setup-view until setup is done.
make sure a user who has 2FA enabled will be redirected to verify-view for token input after login until verified.
Quickstart
Install packages by running ‘pip install zweifach django-otp qrcode’
Add ‘zweifach’ to INSTALLED_APPS.
Add ‘zweifach.middleware.ZweifachMiddleware’ to MIDDLEWARE, after AuthenticationMiddleware.
Inlcude ‘zweifach.urls’ somewhere in your url-config.
Configure django-otp as described further down below
Settings
settings.ZWEIFACH_AUTH_REQUIRED
default: []
A list of checks which determine, if a user needs 2FA to use its account.
examaple:
ZWEIFACH_AUTH_REQUIRED = [ lambda user: user.is_staff, # all staff unsers must use two factor auth lambda user: '2fa' in user.groups.values_list("name", flat=True), # all users in group '2fa' must use two factor auth ]
settings.ZWEIFACH_URL_EXCLUDES
default: []
A list of url which are always accessible without 2FA. Verify and Setup views are always excluded as well as settings.LOGIN_URL and the admin login view, if admin is enabled.
example:
ZWEIFACH_URL_EXCLUDES = [ '/imprint/', '/faq/how-to-setup-2fa/', ]
Note: If a url is accessible without login, it can of course still be viewed without any 2FA interaction.
Notes about django-otp configuration
A compatible installation of django-otp should be setup as follows:
Add to INSTALLED_APPS:
'django_otp', 'django_otp.plugins.otp_totp', 'django_otp.plugins.otp_static',
Add to MIDDLEWARE (between AuthenticationMiddleware and ZweifachMiddleware):
'django_otp.middleware.OTPMiddleware'
Configure issuer:
OTP_TOTP_ISSUER = 'MyProject'
Usage
To generate static recovery tokens (also useful for first login on freshly installed systems) use:
./manage.py addstatictoken <username>
Development
Ensure basic code style with:
tox
Build package with:
python3 -m build
Upload package to PyPI:
python3 -m twine upload dist/zweifach-x.x.x*
Metadata
Release files for zweifach 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zweifach-1.0.3.tar.gz | 6.6 kB | Without provenance | Details for zweifach-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zweifach-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for zweifach-1.0.3-py3-none-any.whl |
Total release size: 13.8 kB
Release files / zweifach-1.0.3.tar.gz
| Download URL | zweifach-1.0.3.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e654839b218d1140f247d02a1cc8721ff69e697202814eb7465bf8f6d3ae980c
|
|
BLAKE2b-256 checksum How to use checksums |
851f8093eeec7196bab205f6500018bef6084a059f92c2585988d11d708f3e33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.6
|
Release files / zweifach-1.0.3-py3-none-any.whl
| Download URL | zweifach-1.0.3-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccd548e398aedfdc551684d440c216b13df7f0aae424d7128bd5ca6bbb325d9d
|
|
BLAKE2b-256 checksum How to use checksums |
6395812ccd3ba83c32a3c9418ec4cf6b09a17c7737af53e04c63f1db7cbed5f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.6
|
Security for zweifach 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.