Git Product home page Git Product logo

django-warrant's Introduction

Django Warrant

Install

pip install django-warrant

Django Auth Backend

Using the CognitoBackend

  1. In your Django project settings file, add the dotted path of CognitoBackend to your list of AUTHENTICATION_BACKENDS. Keep in mind that Django will attempt to authenticate a user using each backend listed, in the order listed until successful.

    AUTHENTICATION_BACKENDS = [
        'django_warrant.backend.CognitoBackend',
        ...
    ]
  2. Set COGNITO_USER_POOL_ID and COGNITO_APP_ID in your settings file as well. Your User Pool ID can be found in the Pool Details tab in the AWS console. Your App ID is found in the Apps tab, listed as "App client id".

  3. Set COGNITO_ATTR_MAPPING in your settings file to a dictionary mapping a Cognito attribute name to a Django User attribute name. If your Cognito User Pool has any custom attributes, it is automatically prefixed with custom:. Therefore, you will want to add a mapping to your mapping dictionary as such {'custom:custom_attr': 'custom_attr'}. Defaults to:

    {
        'email': 'email',
        'given_name': 'first_name',
        'family_name': 'last_name',
    }
  4. Optional - Set COGNITO_CREATE_UNKNOWN_USERS to True or False, depending on if you wish local Django users to be created upon successful login. If set to False, only existing local Django users are updated. Defaults to True.

  5. Optional - Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to the AWS access keys you would like to use. Defaults to None, which will use the default credentials in your ~/.aws/credentials file.

CognitoBackend Behavior

Since the username of a Cognito User can never change, this is used by the backend to match a Cognito User with a local Django User.

If a Django user is not found, one is created using the attributes fetched from Cognito. If an existing Django user is found, their attributes are updated.

If the boto3 client comes back with either a NotAuthorizedException or UserNotFoundException, then None is returned instead of a User. Otherwise, the exception is raised.

Upon successful login, the three identity tokens returned from Cognito (ID token, Refresh token, Access token) are stored in the user's request session. In Django >= 1.11, this is done directly in the backend class. Otherwise, this is done via the user_logged_in signal.

Check the cdu directory for an example app with a login and user details page.

Customizing CognitoBackend Behavior

Setting the Django setting COGNITO_CREATE_UNKNOWN_USERS to False prevents the backend from creating a new local Django user and only updates existing users.

If you create your own backend class that inhereits from CognitoBackend, you may want to also create your own custom user_logged_in so that it checks for the name of your custom class.

API Gateway Integration

API Key Middleware

The APIKeyMiddleware checks for a HTTP_AUTHORIZATION_ID header in the request and attaches it to the request object as api_key.

django-warrant's People

Contributors

bjinwright avatar brianjinwright avatar ebpetway avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-warrant's Issues

Error: django.core.exceptions.ImproperlyConfigured

Hi

I am using django-warran as Authentication backend and using the django_warrant.UserObj as the
Auth_User_Model.When I try to run "python manage.py makemigrations" . I got this
"django.core.exceptions.ImproperlyConfigured" error.
I have created a new project and startapp django_warrant and copied the
code to the directory.I am looking use this UserObj as user model as a reference in
another app.

Any hacks or idea.?Is there any alternative.?

Thanks

Traceback (most recent call last):
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/apps/config.py", line 165, in get_model
return self.models[model_name.lower()]
KeyError: 'userobj'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/contrib/auth/init.py", line 193, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/apps/registry.py", line 202, in get_model
return app_config.get_model(model_name, require_ready=require_ready)
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/apps/config.py", line 168, in get_model
"App '%s' doesn't have a '%s' model." % (self.label, model_name))
LookupError: App 'django_warrant' doesn't have a 'UserObj' model.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "manage.py", line 15, in
execute_from_command_line(sys.argv)
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/core/management/init.py", line 371, in execute_from_command_line
utility.execute()
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/core/management/init.py", line 347, in execute
django.setup()
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 23, in ready
self.module.autodiscover()
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/contrib/admin/init.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/contrib/auth/admin.py", line 6, in
from django.contrib.auth.forms import (
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 20, in
UserModel = get_user_model()
File "/home/aayush/.virtualenvs/warrant3.6/lib/python3.6/site-packages/django/contrib/auth/init.py", line 198, in get_user_model
"AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'django_warrant.UserObj' that has not been installed

django 3

Are there any plans to support django 3.x?

User model mapping issue w/ get_user when User model uses "email" field as USERNAME_FIELD

Hi, in my user model I am using the email address field as the username, i.e. in my User model:
USERNAME_FIELD = 'email'

This means that my User has no 'username' property.

As such, when I call CognitoUser.get_user(), I am getting an error when it tries to reconstruct my User model from the database:

File "/Users/anye/bcve/lib/python3.5/site-packages/warrant/init.py", line 460, in get_user
metadata=user_metadata,attr_map=attr_map)
File "/Users/anye/bcve/lib/python3.5/site-packages/django_warrant/backend.py", line 37, in get_user_obj
defaults=user_attrs)
File "/Users/anye/bcve/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/anye/bcve/lib/python3.5/site-packages/django/db/models/query.py", line 476, in update_or_create
lookup, params = self._extract_model_params(defaults, **kwargs)
File "/Users/anye/bcve/lib/python3.5/site-packages/django/db/models/query.py", line 534, in _extract_model_params
"', '".join(sorted(invalid_params)),
django.core.exceptions.FieldError: Invalid field name(s) for model User: 'username'.

I tried adding a mapping between username and email but that did not help the issue. My mapping looks like:
COGNITO_ATTR_MAPPING={
'email': 'email',
'given_name': 'first_name',
'family_name': 'last_name',
'username': 'email'
}

Update:
I think the problem is actually twofold; it happens either when trying to create unknown users or get the User from cognito:
backend.py

it's the CognitoUser.user_class.objects.update_or_create() and CognitoUser.user_class.objects.get(username=username) methods that are throwing the exception because it assumes there is a username field on the user_class.

def get_user_obj(self,username=None,attribute_list=[],metadata={},attr_map={}):
user_attrs = cognito_to_dict(attribute_list,CognitoUser.COGNITO_ATTR_MAPPING)
django_fields = [f.name for f in CognitoUser.user_class._meta.get_fields()]
extra_attrs = {}
for k, v in user_attrs.items():
if k not in django_fields:
extra_attrs.update({k: user_attrs.pop(k, None)})
if getattr(settings, 'CREATE_UNKNOWN_USERS', True):
user, created = CognitoUser.user_class.objects.update_or_create(
username=username,
defaults=user_attrs)

else:
try:
user = CognitoUser.user_class.objects.get(username=username)
for k, v in iteritems(user_attrs):
setattr(user, k, v)
user.save()
except CognitoUser.user_class.DoesNotExist:
user = None
if user:
for k, v in extra_attrs.items():
setattr(user, k, v)
return user

I'm not sure if fixing this is going to require overriding these methods from the Warrant library, since those are assuming a username field, or whether you can simply add conditional logic here to either get/update_or_create by either username or USERNAME_FIELD?

Is this project still maintained?

PyPI version doesn't work with Django 2.0, and several issues have no comments from contributors.

I want to know if this will be a robust, long-term solution for building something in a production environment.

Pycryptodome setup.py fails during installation (Python 3.6)

I am trying to install django-warrant using pip, but it will always fail due to an obscure pycryptodome setup error. I am attempting to use django-warrant with Django 2.0.4 and Python 3.6.

Pip Output

Running setup.py install for pycryptodome ... error
    Complete output from command C:\Users\<username>\project\python\Planner\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\<username>\\AppData\\Local\\Temp\\pip-build-mm2ovfy_\\pycryptodome\\setup.py';f=getattr(tokenize
, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\<username>\AppData\Local\Temp\pip-ma26u5v3-record\install-record.txt --single-version-externally-managed --comp
ile --install-headers C:\Users\<username>\project\python\Planner\venv\include\site\python3.6\pycryptodome:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\Crypto
    copying lib\Crypto\pct_warnings.py -> build\lib.win-amd64-3.6\Crypto
    copying lib\Crypto\__init__.py -> build\lib.win-amd64-3.6\Crypto
    creating build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\AES.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\ARC2.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\ARC4.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\Blowfish.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\CAST.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\ChaCha20.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\DES.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\DES3.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\PKCS1_OAEP.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\PKCS1_v1_5.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\Salsa20.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_cbc.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_ccm.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_cfb.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_ctr.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_eax.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_ecb.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_gcm.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_ocb.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_ofb.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_openpgp.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\_mode_siv.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    copying lib\Crypto\Cipher\__init__.py -> build\lib.win-amd64-3.6\Crypto\Cipher
    creating build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\BLAKE2b.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\BLAKE2s.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\CMAC.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\HMAC.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\keccak.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\MD2.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\MD4.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\MD5.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\RIPEMD.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\RIPEMD160.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA1.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA224.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA256.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA384.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA3_224.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA3_256.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA3_384.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA3_512.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHA512.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHAKE128.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\SHAKE256.py -> build\lib.win-amd64-3.6\Crypto\Hash
    copying lib\Crypto\Hash\__init__.py -> build\lib.win-amd64-3.6\Crypto\Hash
    creating build\lib.win-amd64-3.6\Crypto\IO
    copying lib\Crypto\IO\PEM.py -> build\lib.win-amd64-3.6\Crypto\IO
    copying lib\Crypto\IO\PKCS8.py -> build\lib.win-amd64-3.6\Crypto\IO
    copying lib\Crypto\IO\_PBES.py -> build\lib.win-amd64-3.6\Crypto\IO
    copying lib\Crypto\IO\__init__.py -> build\lib.win-amd64-3.6\Crypto\IO
    creating build\lib.win-amd64-3.6\Crypto\PublicKey
    copying lib\Crypto\PublicKey\DSA.py -> build\lib.win-amd64-3.6\Crypto\PublicKey
    copying lib\Crypto\PublicKey\ElGamal.py -> build\lib.win-amd64-3.6\Crypto\PublicKey
    copying lib\Crypto\PublicKey\RSA.py -> build\lib.win-amd64-3.6\Crypto\PublicKey
    copying lib\Crypto\PublicKey\__init__.py -> build\lib.win-amd64-3.6\Crypto\PublicKey
    creating build\lib.win-amd64-3.6\Crypto\Protocol
    copying lib\Crypto\Protocol\KDF.py -> build\lib.win-amd64-3.6\Crypto\Protocol
    copying lib\Crypto\Protocol\SecretSharing.py -> build\lib.win-amd64-3.6\Crypto\Protocol
    copying lib\Crypto\Protocol\__init__.py -> build\lib.win-amd64-3.6\Crypto\Protocol
    creating build\lib.win-amd64-3.6\Crypto\Random
    copying lib\Crypto\Random\random.py -> build\lib.win-amd64-3.6\Crypto\Random
    copying lib\Crypto\Random\__init__.py -> build\lib.win-amd64-3.6\Crypto\Random
    creating build\lib.win-amd64-3.6\Crypto\Signature
    copying lib\Crypto\Signature\DSS.py -> build\lib.win-amd64-3.6\Crypto\Signature
    copying lib\Crypto\Signature\pkcs1_15.py -> build\lib.win-amd64-3.6\Crypto\Signature
    copying lib\Crypto\Signature\PKCS1_PSS.py -> build\lib.win-amd64-3.6\Crypto\Signature
    copying lib\Crypto\Signature\PKCS1_v1_5.py -> build\lib.win-amd64-3.6\Crypto\Signature
    copying lib\Crypto\Signature\pss.py -> build\lib.win-amd64-3.6\Crypto\Signature
    copying lib\Crypto\Signature\__init__.py -> build\lib.win-amd64-3.6\Crypto\Signature
    creating build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\asn1.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\Counter.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\number.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\Padding.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\py3compat.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\RFC1751.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\strxor.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\_number_new.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\_raw_api.py -> build\lib.win-amd64-3.6\Crypto\Util
    copying lib\Crypto\Util\__init__.py -> build\lib.win-amd64-3.6\Crypto\Util
    creating build\lib.win-amd64-3.6\Crypto\Math
    copying lib\Crypto\Math\Numbers.py -> build\lib.win-amd64-3.6\Crypto\Math
    copying lib\Crypto\Math\Primality.py -> build\lib.win-amd64-3.6\Crypto\Math
    copying lib\Crypto\Math\_Numbers_gmp.py -> build\lib.win-amd64-3.6\Crypto\Math
    copying lib\Crypto\Math\_Numbers_int.py -> build\lib.win-amd64-3.6\Crypto\Math
    copying lib\Crypto\Math\__init__.py -> build\lib.win-amd64-3.6\Crypto\Math
    creating build\lib.win-amd64-3.6\Crypto\SelfTest
    copying lib\Crypto\SelfTest\st_common.py -> build\lib.win-amd64-3.6\Crypto\SelfTest
    copying lib\Crypto\SelfTest\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest
    copying lib\Crypto\SelfTest\__main__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\common.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_AES.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_ARC2.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_ARC4.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_Blowfish.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_CAST.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_ChaCha20.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_DES.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_DES3.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_OCB.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_pkcs1_15.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_pkcs1_oaep.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\test_Salsa20.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    copying lib\Crypto\SelfTest\Cipher\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Cipher
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\common.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\loader.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_BLAKE2.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_CMAC.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_HMAC.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_keccak.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_MD2.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_MD4.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_MD5.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_RIPEMD160.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA1.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA224.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA256.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA384.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA3_224.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA3_256.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA3_384.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA3_512.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHA512.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\test_SHAKE.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    copying lib\Crypto\SelfTest\Hash\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\IO
    copying lib\Crypto\SelfTest\IO\test_PBES.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\IO
    copying lib\Crypto\SelfTest\IO\test_PKCS8.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\IO
    copying lib\Crypto\SelfTest\IO\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\IO
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Protocol
    copying lib\Crypto\SelfTest\Protocol\test_KDF.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Protocol
    copying lib\Crypto\SelfTest\Protocol\test_rfc1751.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Protocol
    copying lib\Crypto\SelfTest\Protocol\test_SecretSharing.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Protocol
    copying lib\Crypto\SelfTest\Protocol\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Protocol
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\PublicKey
    copying lib\Crypto\SelfTest\PublicKey\test_DSA.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\PublicKey
    copying lib\Crypto\SelfTest\PublicKey\test_ElGamal.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\PublicKey
    copying lib\Crypto\SelfTest\PublicKey\test_import_DSA.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\PublicKey
    copying lib\Crypto\SelfTest\PublicKey\test_import_RSA.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\PublicKey
    copying lib\Crypto\SelfTest\PublicKey\test_RSA.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\PublicKey
    copying lib\Crypto\SelfTest\PublicKey\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\PublicKey
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Random
    copying lib\Crypto\SelfTest\Random\test_random.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Random
    copying lib\Crypto\SelfTest\Random\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Random
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Signature
    copying lib\Crypto\SelfTest\Signature\nist.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature
    copying lib\Crypto\SelfTest\Signature\test_dss.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature
    copying lib\Crypto\SelfTest\Signature\test_pkcs1_15.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature
    copying lib\Crypto\SelfTest\Signature\test_pss.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature
    copying lib\Crypto\SelfTest\Signature\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Util
    copying lib\Crypto\SelfTest\Util\test_asn1.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Util
    copying lib\Crypto\SelfTest\Util\test_Counter.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Util
    copying lib\Crypto\SelfTest\Util\test_number.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Util
    copying lib\Crypto\SelfTest\Util\test_Padding.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Util
    copying lib\Crypto\SelfTest\Util\test_strxor.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Util
    copying lib\Crypto\SelfTest\Util\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Util
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Math
    copying lib\Crypto\SelfTest\Math\test_Numbers.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Math
    copying lib\Crypto\SelfTest\Math\test_Primality.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Math
    copying lib\Crypto\SelfTest\Math\__init__.py -> build\lib.win-amd64-3.6\Crypto\SelfTest\Math
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\SHA3
    copying lib\Crypto\SelfTest\Hash\test_vectors\SHA3\ShortMsgKAT_SHA3-224.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\SHA3
    copying lib\Crypto\SelfTest\Hash\test_vectors\SHA3\ShortMsgKAT_SHA3-256.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\SHA3
    copying lib\Crypto\SelfTest\Hash\test_vectors\SHA3\ShortMsgKAT_SHA3-384.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\SHA3
    copying lib\Crypto\SelfTest\Hash\test_vectors\SHA3\ShortMsgKAT_SHA3-512.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\SHA3
    copying lib\Crypto\SelfTest\Hash\test_vectors\SHA3\ShortMsgKAT_SHAKE128.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\SHA3
    copying lib\Crypto\SelfTest\Hash\test_vectors\SHA3\ShortMsgKAT_SHAKE256.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\SHA3
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\ExtremelyLongMsgKAT_224.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\ExtremelyLongMsgKAT_256.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\ExtremelyLongMsgKAT_384.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\ExtremelyLongMsgKAT_512.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\LongMsgKAT_224.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\LongMsgKAT_256.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\LongMsgKAT_384.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\LongMsgKAT_512.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\readme.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\ShortMsgKAT_224.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\ShortMsgKAT_256.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\ShortMsgKAT_384.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    copying lib\Crypto\SelfTest\Hash\test_vectors\keccak\ShortMsgKAT_512.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\keccak
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\BLAKE2s
    copying lib\Crypto\SelfTest\Hash\test_vectors\BLAKE2s\blake2s-test.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\BLAKE2s
    copying lib\Crypto\SelfTest\Hash\test_vectors\BLAKE2s\tv1.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\BLAKE2s
    copying lib\Crypto\SelfTest\Hash\test_vectors\BLAKE2s\tv2.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\BLAKE2s
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\BLAKE2b
    copying lib\Crypto\SelfTest\Hash\test_vectors\BLAKE2b\blake2b-test.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\BLAKE2b
    copying lib\Crypto\SelfTest\Hash\test_vectors\BLAKE2b\tv1.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\BLAKE2b
    copying lib\Crypto\SelfTest\Hash\test_vectors\BLAKE2b\tv2.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Hash\test_vectors\BLAKE2b
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\DSA
    copying lib\Crypto\SelfTest\Signature\test_vectors\DSA\FIPS_186_3_SigGen.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\DSA
    copying lib\Crypto\SelfTest\Signature\test_vectors\DSA\FIPS_186_3_SigVer.rsp -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\DSA
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\PKCS1-v1.5
    copying lib\Crypto\SelfTest\Signature\test_vectors\PKCS1-v1.5\SigGen15_186-2.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\PKCS1-v1.5
    copying lib\Crypto\SelfTest\Signature\test_vectors\PKCS1-v1.5\SigGen15_186-3.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\PKCS1-v1.5
    copying lib\Crypto\SelfTest\Signature\test_vectors\PKCS1-v1.5\SigVer15_186-3.rsp -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\PKCS1-v1.5
    creating build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\PKCS1-PSS
    copying lib\Crypto\SelfTest\Signature\test_vectors\PKCS1-PSS\SigGenPSS_186-2.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\PKCS1-PSS
    copying lib\Crypto\SelfTest\Signature\test_vectors\PKCS1-PSS\SigGenPSS_186-3.txt -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\PKCS1-PSS
    copying lib\Crypto\SelfTest\Signature\test_vectors\PKCS1-PSS\SigVerPSS_186-3.rsp -> build\lib.win-amd64-3.6\Crypto\SelfTest\Signature\test_vectors\PKCS1-PSS
    Skipping optional fixer: buffer
    Skipping optional fixer: idioms
    Skipping optional fixer: set_literal
    Skipping optional fixer: ws_comma
    running build_ext

    ----------------------------------------
  Rolling back uninstall of pycryptodome
Command "C:\Users\<username>\project\python\Planner\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\<username>\\AppData\\Local\\Temp\\pip-build-mm2ovfy_\\pycryptodome\\setup.py';f=getattr(tokenize, 'open', open)(__file__
);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\<username>\AppData\Local\Temp\pip-ma26u5v3-record\install-record.txt --single-version-externally-managed --compile --install-headers C:
\Users\<username>\project\python\Planner\venv\include\site\python3.6\pycryptodome" failed with error code 1 in C:\Users\<username>\AppData\Local\Temp\pip-build-mm2ovfy_\pycryptodome\

Attribute Error: login

Please update the "urls.py" file as in newer versions of django, it's auth_login and auth_logout instead of login and logout. When I try to include the urls in my project I got this error:

AttributeError: module 'django.contrib.auth.views' has no attribute 'login'.

NoRegionError

After deploying my application to AWS Elastic Beanstalk, I have been getting a NoRegionError. Everything works fine when I run my Django server locally. I am not sure if this is a bug or if I am doing something wrong. There is no mentioning of a "region_name" in the readme file.

Error Output

Environment:


Request Method: POST
Request URL: http://******************/authenticate/

Django Version: 1.11.6
Python Version: 3.4.3
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'dashboard',
 'registration']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/opt/python/current/app/registration/views.py" in authentication
  54.                 user = authenticate(request, username=email, password=password)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/contrib/auth/__init__.py" in authenticate
  70.             user = _authenticate_with_backend(backend, backend_path, request, credentials)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/contrib/auth/__init__.py" in _authenticate_with_backend
  115.     return backend.authenticate(*args, **credentials)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/warrant/django/backend.py" in authenticate
  102.                 username=username, password=password)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/warrant/django/backend.py" in authenticate
  71.             username=username)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/warrant/__init__.py" in __init__
  172.         self.client = boto3.client('cognito-idp', **boto3_client_kwargs)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/boto3/__init__.py" in client
  83.     return _get_default_session().client(*args, **kwargs)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/boto3/session.py" in client
  263.             aws_session_token=aws_session_token, config=config)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/botocore/session.py" in create_client
  861.             client_config=config, api_version=api_version)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/botocore/client.py" in create_client
  76.             verify, credentials, scoped_config, client_config, endpoint_bridge)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/botocore/client.py" in _get_client_args
  288.             verify, credentials, scoped_config, client_config, endpoint_bridge)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/botocore/args.py" in get_client_args
  45.             endpoint_url, is_secure, scoped_config)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/botocore/args.py" in compute_client_args
  111.             service_name, region_name, endpoint_url, is_secure)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/botocore/client.py" in resolve
  361.             service_name, region_name)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/botocore/regions.py" in construct_endpoint
  122.                 partition, service_name, region_name)

File "/opt/python/run/venv/local/lib/python3.4/site-packages/botocore/regions.py" in _endpoint_for_partition
  135.                 raise NoRegionError()

Exception Type: NoRegionError at /authenticate/
Exception Value: You must specify a region.

COGNITO_APP_ID

Hey - no idea where the Apps tab is - I think the AWS console might have been updated.

Any chance you could update the description?

Example django app missing

It is mentioned in the readme file that -

"Check the django/demo directory for an example app with a login and user details page."

This directory is not present in the repository. Would be awesome if this could be added.
Thanks.

Error during template rendering

Error during template rendering

In template /home/md56/.local/lib/python2.7/site-packages/django_extensions/templates/warrant/base.html, error at line 47
u'dw' is not a registered namespace

  • My Profile
  • Cannot find or access user tokens

    Really appreciate the effort on this project. I've not spent much time in Django and this has been super helpful.

    I'm trying to access the user tokens.

    I see that the tokens are being added to the session here.

    However, looking at the session I don't see them e.g.:

    class UserDetail(generics.RetrieveAPIView):
        queryset = User.objects.all()
        serializer_class = UserSerializer
        def def get(self, request, *args, **kwargs):
            return Response(dir(request.session))

    This is a good start. I don't know if your team has any further cycles to spare on maintaining this. If not my team and I are happy to jump in. Let me know how I can be helpful.

    Struggling with cdu example app

    I am not for sure how to integrate this into our application or how to run the cdu example app.

    I created a venv, installed django-warrant as a package that brought in django et all.

    Then when I run the django app I can visit localhost:8000/admin, but localhost:8000/accounts/login returns

    django.template.exceptions.TemplateDoesNotExist: warrant/login.html
    [29/Jun/2018 19:41:16] "GET /accounts/login/?next=/accounts/profile/ HTTP/1.1" 500 85973
    

    and debug page for django.

    Am I doing something wrong?

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.