Package: django-scatter-auth
django-scatter-auth is a pluggable Django app that enables login/signup via Scatter (EOS extension wallet). The user authenticates themselves by digitally signing the hostname with their wallet’s private key.DocumentationThe full documentation is athttps://django-scatter-auth.readthedocs.io.Example projecthttps://github.com/Bearle/django-scatter-auth/tree/master/exampleYou can check out our example project by cloning the repo and heading into example/ directory.
There is a README file for you to check, also.FeaturesScatter API login, signupScatter Django forms for signup, loginChecks signature (validation)Uses hostname signing as proof of private key posessionEasy to set up and use (just one click)Custom auth backendVERY customizable - uses Django settings, allows for custom User modelVanilla Javascript helpers includedQuickstartInstall django-scatter-auth with pip:pip install django-scatter-authAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'scatterauth.apps.scatterauthConfig',...)Set‘scatterauth.backend.ScatterAuthBackend’as your authentication backend:AUTHENTICATION_BACKENDS=['django.contrib.auth.backends.ModelBackend','scatterauth.backend.ScatterAuthBackend']Set your User model’s field to use as public key storage:SCATTERAUTH_USER_PUBKEY_FIELD='username'And if you have some other fields you want to be in the SignupForm, add them too:SCATTERAUTH_USER_SIGNUP_FIELDS=['email',]Add django-scatter-auth’s URL patterns:fromscatterauthimporturlsasscatterauth_urlsurlpatterns=[...url(r'^',include(scatterauth_urls)),...]Add some javascript to handle login:<scriptsrc="{% static 'scatterauth/js/scatterauth.js' %}"></script>varlogin_url='{% url 'scatterauth_login_api' %}';document.addEventListener('scatterLoaded',scatterExtension=>{console.log('scatter loaded');if(scatter.identity){console.log("Identity found");loginWithAuthenticate(login_url,console.log,console.log,console.log,console.log,function(resp){window.location.replace(resp.redirect_url);});}else{console.log('identity not found, have to signup');}});You can access signup using {% url ‘scatterauth_signup’ %} and API signup using {% url ‘scatterauth_signup_api’ %}.If you have any questions left, head to the example apphttps://github.com/Bearle/django-scatter-auth/tree/master/exampleImportant details and FAQIf you set a custom public key field (SCATTERAUTH_USER_PUBKEY_FIELD), it MUST be unique (unique=True).This is needed because if it’s not, the user can register a new account with the same public key as the other one,
meaning that the user can now login as any of those accounts (sometimes being the wrong one).How do i deal with user passwords or Password is not setThere should be some code in your project that generates a password usingUser.objects.make_random_passwordand sends it to a user email.
Or, even better, sends them a ‘restore password’ link.
Also, it’s possible to copy signup_view to your project, assign it a url, and add the corresponding lines to set some password for a user.Why don’t i have to sign a message? It’s needed in django-web3-auth, how this app is secure?This app uses scatter’sauthenticatefunction to handle message signing - hostname being the signed message.
This means that the user & the client share knowledge of the original message and the server can verify
client’s possession of the private key corresponding to the public key.Running TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.2.0 (2020-03-14)Added support for Scatter-Desktop0.1.1 (2018-09-10)Fixed signup bug in js - added ‘pubkey_field_name’ param0.1.0 (2018-08-13)First release on PyPi