This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django_otp.oath import TOTP | |
| from django_otp.util import random_hex | |
| from unittest import mock | |
| import time | |
| class TOTPVerification: | |
| def __init__(self): | |
| # secret key that will be used to generate a token, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ldap | |
| def check_credentials(username, password): | |
| """Verifies credentials for username and password. | |
| Returns None on success or a string describing the error on failure | |
| # Adapt to your needs | |
| """ | |
| LDAP_SERVER = 'ldap://xxx' | |
| # fully qualified AD user name | |
| LDAP_USERNAME = '%[email protected]' % username |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db.models.signals import post_init | |
| def track_data(*fields): | |
| """ | |
| Tracks property changes on a model instance. | |
| The changed list of properties is refreshed on model initialization | |
| and save. | |
| >>> @track_data('name') |