├── tests ├── __init__.py ├── urls.py ├── test_models.py └── settings.py ├── example ├── example │ ├── __init__.py │ ├── wsgi.py │ ├── urls.py │ └── settings.py ├── requirements.txt ├── manage.py ├── templates │ └── web3auth │ │ ├── signup.html │ │ ├── login.html │ │ ├── autologin.html │ │ └── base.html └── README.md ├── web3auth ├── static │ └── web3auth │ │ ├── css │ │ └── web3auth.css │ │ ├── img │ │ └── .gitignore │ │ └── js │ │ └── web3auth.js ├── __init__.py ├── apps.py ├── templates │ └── web3auth │ │ ├── signup.html │ │ └── base.html ├── urls.py ├── backend.py ├── settings.py ├── forms.py ├── utils.py └── views.py ├── docs ├── authors.rst ├── history.rst ├── readme.rst ├── contributing.rst ├── requirements.txt ├── modules.rst ├── _static │ └── web3_auth_test.gif ├── index.rst ├── web3auth.rst ├── settings.rst ├── overview.rst ├── Makefile ├── make.bat └── conf.py ├── requirements_dev.txt ├── requirements.txt ├── requirements_test.txt ├── .coveragerc ├── MANIFEST.in ├── AUTHORS.rst ├── tox.ini ├── manage.py ├── setup.cfg ├── .github └── ISSUE_TEMPLATE.md ├── .editorconfig ├── runtests.py ├── .travis.yml ├── HISTORY.rst ├── Makefile ├── LICENSE ├── setup.py ├── .gitignore ├── CONTRIBUTING.rst └── README.rst /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/example/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /web3auth/static/web3auth/css/web3auth.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /web3auth/static/web3auth/img/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /web3auth/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.1.6' 2 | -------------------------------------------------------------------------------- /docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | -r ../requirements.txt 2 | -r ../requirements_dev.txt 3 | Django>=2.0 4 | -------------------------------------------------------------------------------- /docs/modules.rst: -------------------------------------------------------------------------------- 1 | web3auth 2 | ======== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | web3auth 8 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | bumpversion==0.5.3 2 | wheel==0.30.0 3 | sphinx==1.7.5 4 | sphinx-rtd-theme==0.4.0 5 | -------------------------------------------------------------------------------- /docs/_static/web3_auth_test.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bearle/django-web3-auth/HEAD/docs/_static/web3_auth_test.gif -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | 2 | # Additional requirements go here 3 | coincurve 4 | rlp>=2.0.0 5 | eth_utils>=1.0.3 6 | Django>=2.0 7 | -------------------------------------------------------------------------------- /web3auth/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class Web3AuthConfig(AppConfig): 5 | name = 'web3auth' 6 | -------------------------------------------------------------------------------- /example/requirements.txt: -------------------------------------------------------------------------------- 1 | # Your app requirements. 2 | -r ../requirements_test.txt 3 | 4 | # Your app in editable mode. 5 | -e ../ 6 | Django==2.0.6 7 | packaging==16.8 8 | -------------------------------------------------------------------------------- /requirements_test.txt: -------------------------------------------------------------------------------- 1 | coverage==4.4.1 2 | mock>=1.0.1 3 | flake8>=2.1.0 4 | tox>=1.7.0 5 | codecov>=2.0.0 6 | tox-travis>=0.12 7 | 8 | # Additional test requirements go here 9 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = true 3 | 4 | [report] 5 | omit = 6 | *site-packages* 7 | *tests* 8 | *.tox* 9 | show_missing = True 10 | exclude_lines = 11 | raise NotImplementedError 12 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include HISTORY.rst 4 | include LICENSE 5 | include README.rst 6 | recursive-include web3auth *.html *.png *.gif *js *.css *jpg *jpeg *svg *py 7 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Denis Bobrov 9 | 10 | Contributors 11 | ------------ 12 | 13 | * Alexander Tereshkin 14 | -------------------------------------------------------------------------------- /tests/urls.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals, absolute_import 3 | 4 | from django.conf.urls import url, include 5 | 6 | 7 | urlpatterns = [ 8 | url(r'^', include('web3auth.urls', namespace='web3auth')), 9 | ] 10 | -------------------------------------------------------------------------------- /example/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /example/templates/web3auth/signup.html: -------------------------------------------------------------------------------- 1 | {% extends 'web3auth/base.html' %} 2 | {% block content %} 3 |
4 |
5 | {% csrf_token %} 6 | {{ form.as_p }} 7 | 8 |
9 |
10 | {% endblock content %} 11 | -------------------------------------------------------------------------------- /web3auth/templates/web3auth/signup.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | {% csrf_token %} 10 | {{ form.as_p }} 11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = 3 | django-22 4 | django-31 5 | 6 | [testenv] 7 | setenv = 8 | PYTHONPATH = {toxinidir}:{toxinidir}/web3auth 9 | commands = 10 | flake8 . 11 | coverage run --source web3auth runtests.py 12 | deps = 13 | django-22: Django>=2.2,<3 14 | django-31: Django>=3.1,<4 15 | -r{toxinidir}/requirements_test.txt 16 | -------------------------------------------------------------------------------- /web3auth/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | 3 | from web3auth import views 4 | 5 | app_name = 'web3auth' 6 | 7 | urlpatterns = [ 8 | url(r'^login_api/$', views.login_api, name='web3auth_login_api'), 9 | url(r'^signup_api/$', views.signup_api, name='web3auth_signup_api'), 10 | url(r'^signup/$', views.signup_view, name='web3auth_signup'), 11 | ] 12 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from __future__ import unicode_literals, absolute_import 4 | 5 | import os 6 | import sys 7 | 8 | if __name__ == "__main__": 9 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings") 10 | from django.core.management import execute_from_command_line 11 | 12 | execute_from_command_line(sys.argv) 13 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.1.6 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | 8 | [bumpversion:file:web3auth/__init__.py] 9 | 10 | [wheel] 11 | universal = 1 12 | 13 | [flake8] 14 | ignore = D203 15 | exclude = 16 | web3auth/migrations, 17 | example, 18 | .git, 19 | .tox, 20 | docs/conf.py, 21 | build, 22 | dist 23 | max-line-length = 119 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | * Django-Web3-Auth version: 2 | * Django version: 3 | * Python version: 4 | * Operating System: 5 | 6 | ### Description 7 | 8 | Describe what you were trying to get done. 9 | Tell us what happened, what went wrong, and what you expected to happen. 10 | 11 | ### What I Did 12 | 13 | ``` 14 | Paste the command(s) you ran and the output. 15 | If there was a crash, please include the traceback here. 16 | ``` 17 | -------------------------------------------------------------------------------- /tests/test_models.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | test_django-web3-auth 6 | ------------ 7 | 8 | Tests for `django-web3-auth` models module. 9 | """ 10 | 11 | from django.test import TestCase 12 | 13 | 14 | class TestWeb3auth(TestCase): 15 | 16 | def setUp(self): 17 | pass 18 | 19 | def test_something(self): 20 | pass 21 | 22 | def tearDown(self): 23 | pass 24 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.{py,rst,ini}] 12 | indent_style = space 13 | indent_size = 4 14 | 15 | [*.{html,css,scss,json,yml}] 16 | indent_style = space 17 | indent_size = 2 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [Makefile] 23 | indent_style = tab 24 | -------------------------------------------------------------------------------- /example/example/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for example project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. complexity documentation master file, created by 2 | sphinx-quickstart on Tue Jul 9 22:26:36 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Django-Web3-Auth's documentation! 7 | ================================================================= 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | readme 15 | overview 16 | settings 17 | contributing 18 | authors 19 | history 20 | -------------------------------------------------------------------------------- /runtests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 3 | from __future__ import unicode_literals, absolute_import 4 | 5 | import os 6 | import sys 7 | 8 | import django 9 | from django.conf import settings 10 | from django.test.utils import get_runner 11 | 12 | 13 | def run_tests(*test_args): 14 | if not test_args: 15 | test_args = ['tests'] 16 | 17 | os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' 18 | django.setup() 19 | TestRunner = get_runner(settings) 20 | test_runner = TestRunner() 21 | failures = test_runner.run_tests(test_args) 22 | sys.exit(bool(failures)) 23 | 24 | 25 | if __name__ == '__main__': 26 | run_tests(*sys.argv[1:]) 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Config file for automatic testing at travis-ci.org 2 | 3 | language: python 4 | 5 | python: 6 | - "3.6.12" 7 | - "3.7.9" 8 | - "3.8.7" 9 | - "3.9.1" 10 | 11 | env: 12 | - TOX_ENV=django-22 13 | - TOX_ENV=django-22 14 | - TOX_ENV=django-22 15 | - TOX_ENV=django-22 16 | - TOX_ENV=django-31 17 | - TOX_ENV=django-31 18 | - TOX_ENV=django-31 19 | - TOX_ENV=django-31 20 | 21 | matrix: 22 | fast_finish: true 23 | 24 | # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors 25 | install: pip install -r requirements_test.txt 26 | 27 | # command to run tests using coverage, e.g. python setup.py test 28 | script: tox -e $TOX_ENV 29 | 30 | after_success: 31 | - codecov -e TOX_ENV 32 | -------------------------------------------------------------------------------- /tests/settings.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 2 | from __future__ import unicode_literals, absolute_import 3 | 4 | import django 5 | 6 | DEBUG = True 7 | USE_TZ = True 8 | 9 | # SECURITY WARNING: keep the secret key used in production secret! 10 | SECRET_KEY = "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk" 11 | 12 | DATABASES = { 13 | "default": { 14 | "ENGINE": "django.db.backends.sqlite3", 15 | "NAME": ":memory:", 16 | } 17 | } 18 | 19 | ROOT_URLCONF = "tests.urls" 20 | 21 | INSTALLED_APPS = [ 22 | "django.contrib.auth", 23 | "django.contrib.contenttypes", 24 | "django.contrib.sites", 25 | "web3auth", 26 | ] 27 | 28 | SITE_ID = 1 29 | 30 | if django.VERSION >= (1, 10): 31 | MIDDLEWARE = () 32 | else: 33 | MIDDLEWARE_CLASSES = () 34 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | Example Project for web3auth 2 | 3 | This example is provided as a convenience feature to allow potential users to try the app straight from the app repo without having to create a django project. 4 | 5 | It can also be used to develop the app in place. 6 | 7 | To run this example, follow these instructions: 8 | 9 | 1. Clone the repository 10 | 2. Navigate to the `example` directory 11 | 3. Install the requirements for the package (probably in a virtualenv): 12 | 13 | pip install -r requirements.txt 14 | 15 | 4. Make and apply migrations 16 | 17 | python manage.py makemigrations 18 | 19 | python manage.py migrate 20 | 21 | 5. Run the server 22 | 23 | python manage.py runserver 24 | 25 | 6. Access from the browser at `http://127.0.0.1:8000` 26 | -------------------------------------------------------------------------------- /web3auth/templates/web3auth/base.html: -------------------------------------------------------------------------------- 1 | {% comment %} 2 | As the developer of this package, don't place anything here if you can help it 3 | since this allows developers to have interoperability between your template 4 | structure and their own. 5 | 6 | Example: Developer melding the 2SoD pattern to fit inside with another pattern:: 7 | 8 | {% extends "base.html" %} 9 | {% load static %} 10 | 11 | 12 | {% block extra_js %} 13 | 14 | 15 | {% block javascript %} 16 | 17 | {% endblock javascript %} 18 | 19 | {% endblock extra_js %} 20 | {% endcomment %} 21 | 22 | -------------------------------------------------------------------------------- /web3auth/backend.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import get_user_model, backends 2 | 3 | from web3auth.settings import app_settings 4 | from web3auth.utils import recover_to_addr 5 | 6 | 7 | class Web3Backend(backends.ModelBackend): 8 | def authenticate(self, request, address=None, token=None, signature=None): 9 | # get user model 10 | User = get_user_model() 11 | # check if the address the user has provided matches the signature 12 | if not address == recover_to_addr(token, signature): 13 | return None 14 | else: 15 | # get address field for the user model 16 | address_field = app_settings.WEB3AUTH_USER_ADDRESS_FIELD 17 | kwargs = { 18 | f"{address_field}__iexact": address 19 | } 20 | # try to get user with provided data 21 | user = User.objects.filter(**kwargs).first() 22 | return user 23 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | .. :changelog: 2 | 0.1.6 (2021-09-06) 3 | ++++++++++++++++++ 4 | 5 | * Update from PR#6 by @hiporox 6 | * Resolve's issue #4 - Example app has missing url configuration 7 | 8 | 9 | 0.1.5 (2021-09-06) 10 | ++++++++++++++++++ 11 | 12 | * Update from PR#5 by @hiporox 13 | * Updated .gitignore to include missing file types 14 | * Added script tag to the base.html that imports web3 since MetaMask no longer auto imports (https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3) 15 | 16 | History 17 | ------- 18 | 19 | 0.1.4 (2021-05-06) 20 | ++++++++++++++++++ 21 | 22 | * Try fix rlp 23 | 24 | 25 | 0.1.3 (2021-03-23) 26 | ++++++++++++++++++ 27 | 28 | * Try fix ethereum 29 | 30 | 31 | 0.1.2 (2021-03-16) 32 | ++++++++++++++++++ 33 | 34 | * Flake8, tox fixes in PR#2 by SukiCZ 35 | 36 | 0.1.1 (2021-03-16) 37 | ++++++++++++++++++ 38 | 39 | * Bump 'rlp' - PR#1 by SukiCZ 40 | 41 | 0.1.0 (2018-06-29) 42 | ++++++++++++++++++ 43 | 44 | * First release on PyPi 45 | -------------------------------------------------------------------------------- /example/templates/web3auth/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'web3auth/base.html' %} 2 | {% block content %} 3 |
4 | 5 |
6 | {% endblock content %} 7 | {% block javascript %} 8 | {{ block.super }} 9 | 28 | {% endblock javascript %} 29 | -------------------------------------------------------------------------------- /web3auth/settings.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings as django_settings 2 | 3 | 4 | class AppSettings(object): 5 | @property 6 | def WEB3AUTH_USER_ADDRESS_FIELD(self): 7 | """ 8 | Field on the User model, which has ethereum address to check against. 9 | This allows you to store it somewhere in arbitrary place other than just username. 10 | """ 11 | return getattr(django_settings, 'WEB3AUTH_USER_ADDRESS_FIELD', 'username') 12 | 13 | @property 14 | def WEB3AUTH_USER_SIGNUP_FIELDS(self): 15 | """ 16 | Specifies field to be used in signup form for a new User model 17 | """ 18 | return getattr(django_settings, "WEB3AUTH_USER_SIGNUP_FIELDS", ['email']) 19 | 20 | @property 21 | def WEB3AUTH_SIGNUP_ENABLED(self): 22 | """ 23 | Makes it possible to disable signups (similar to allauth) 24 | """ 25 | return getattr(django_settings, "WEB3AUTH_SIGNUP_ENABLED", True) 26 | 27 | 28 | app_settings = AppSettings() 29 | -------------------------------------------------------------------------------- /example/templates/web3auth/autologin.html: -------------------------------------------------------------------------------- 1 | {% extends 'web3auth/base.html' %} 2 | {% block content %} 3 |
4 |

You will be logged in soon.

5 |
6 | {% endblock content %} 7 | {% block javascript %} 8 | {{ block.super }} 9 | 36 | {% endblock javascript %} 37 | -------------------------------------------------------------------------------- /example/example/urls.py: -------------------------------------------------------------------------------- 1 | """example URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.9/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import url, include 17 | from django.contrib import admin 18 | from django.shortcuts import render, redirect 19 | from django.views.generic import RedirectView 20 | 21 | 22 | def login(request): 23 | if not request.user.is_authenticated: 24 | return render(request, 'web3auth/login.html') 25 | else: 26 | return redirect('/admin/login') 27 | 28 | 29 | def auto_login(request): 30 | if not request.user.is_authenticated: 31 | return render(request, 'web3auth/autologin.html') 32 | else: 33 | return redirect('/admin/login') 34 | 35 | 36 | urlpatterns = [ 37 | url(r'^admin/', admin.site.urls), 38 | url(r'^$', RedirectView.as_view(url='/login')), 39 | url(r'^login/', login, name='login'), 40 | url(r'^auto_login/', auto_login, name='autologin'), 41 | url(r'', include('web3auth.urls')), 42 | ] 43 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean-pyc clean-build docs help 2 | .DEFAULT_GOAL := help 3 | define BROWSER_PYSCRIPT 4 | import os, webbrowser, sys 5 | try: 6 | from urllib import pathname2url 7 | except: 8 | from urllib.request import pathname2url 9 | 10 | webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) 11 | endef 12 | export BROWSER_PYSCRIPT 13 | BROWSER := python -c "$$BROWSER_PYSCRIPT" 14 | 15 | help: 16 | @grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' 17 | 18 | clean: clean-build clean-pyc 19 | 20 | clean-build: ## remove build artifacts 21 | rm -fr build/ 22 | rm -fr dist/ 23 | rm -fr *.egg-info 24 | 25 | clean-pyc: ## remove Python file artifacts 26 | find . -name '*.pyc' -exec rm -f {} + 27 | find . -name '*.pyo' -exec rm -f {} + 28 | find . -name '*~' -exec rm -f {} + 29 | 30 | lint: ## check style with flake8 31 | flake8 web3auth tests 32 | 33 | test: ## run tests quickly with the default Python 34 | python runtests.py tests 35 | 36 | test-all: ## run tests on every Python version with tox 37 | tox 38 | 39 | coverage: ## check code coverage quickly with the default Python 40 | coverage run --source web3auth runtests.py tests 41 | coverage report -m 42 | coverage html 43 | open htmlcov/index.html 44 | 45 | docs: ## generate Sphinx HTML documentation, including API docs 46 | rm -f docs/django-web3-auth.rst 47 | rm -f docs/modules.rst 48 | sphinx-apidoc -o docs/ web3auth 49 | $(MAKE) -C docs clean 50 | $(MAKE) -C docs html 51 | $(BROWSER) docs/_build/html/index.html 52 | 53 | release: clean ## package and upload a release 54 | python setup.py sdist 55 | python -m twine upload --verbose dist/* 56 | 57 | sdist: clean ## package 58 | python setup.py sdist 59 | ls -l dist 60 | -------------------------------------------------------------------------------- /docs/web3auth.rst: -------------------------------------------------------------------------------- 1 | web3auth package 2 | ================ 3 | 4 | Submodules 5 | ---------- 6 | 7 | web3auth\.admin module 8 | ---------------------- 9 | 10 | .. automodule:: web3auth.admin 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | web3auth\.apps module 16 | --------------------- 17 | 18 | .. automodule:: web3auth.apps 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | web3auth\.backend module 24 | ------------------------ 25 | 26 | .. automodule:: web3auth.backend 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | web3auth\.forms module 32 | ---------------------- 33 | 34 | .. automodule:: web3auth.forms 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | web3auth\.models module 40 | ----------------------- 41 | 42 | .. automodule:: web3auth.models 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | 47 | web3auth\.settings module 48 | ------------------------- 49 | 50 | .. automodule:: web3auth.settings 51 | :members: 52 | :undoc-members: 53 | :show-inheritance: 54 | 55 | web3auth\.tests module 56 | ---------------------- 57 | 58 | .. automodule:: web3auth.tests 59 | :members: 60 | :undoc-members: 61 | :show-inheritance: 62 | 63 | web3auth\.urls module 64 | --------------------- 65 | 66 | .. automodule:: web3auth.urls 67 | :members: 68 | :undoc-members: 69 | :show-inheritance: 70 | 71 | web3auth\.utils module 72 | ---------------------- 73 | 74 | .. automodule:: web3auth.utils 75 | :members: 76 | :undoc-members: 77 | :show-inheritance: 78 | 79 | web3auth\.views module 80 | ---------------------- 81 | 82 | .. automodule:: web3auth.views 83 | :members: 84 | :undoc-members: 85 | :show-inheritance: 86 | 87 | 88 | Module contents 89 | --------------- 90 | 91 | .. automodule:: web3auth 92 | :members: 93 | :undoc-members: 94 | :show-inheritance: 95 | -------------------------------------------------------------------------------- /docs/settings.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Settings 3 | ======== 4 | 5 | You should specify settings in your settings.py like this:: 6 | 7 | WEB3AUTH_USER_ADDRESS_FIELD = 'address' 8 | WEB3AUTH_USER_SIGNUP_FIELDS = ['email', 'username'] 9 | 10 | 11 | In the above example the following User model is used: 12 | 13 | .. code-block:: python 14 | 15 | from django.contrib.auth.models import AbstractUser 16 | from django.db import models 17 | from django.utils.translation import ugettext_lazy as _ 18 | from web3auth.utils import validate_eth_address 19 | 20 | class User(AbstractUser): 21 | address = models.CharField(max_length=42, verbose_name=_("Ethereum wallet address"), unique=True, 22 | validators=[validate_eth_address], null=True, blank=True) 23 | 24 | def __str__(self): 25 | return self.username 26 | 27 | Here's a list of available settings: 28 | 29 | +--------------------------------+------------+-------------------------------------------------------------------------+ 30 | | Setting | Default | Description | 31 | +================================+============+=========================================================================+ 32 | | WEB3AUTH_SIGNUP_ENABLED | True | If False, new users won't be able to sign up (used in ``signup_view``) | 33 | +--------------------------------+------------+-------------------------------------------------------------------------+ 34 | | WEB3AUTH_USER_SIGNUP_FIELDS | ['email'] | Specifies field to be used in signup form for a new User model | 35 | +--------------------------------+------------+-------------------------------------------------------------------------+ 36 | | WEB3AUTH_USER_ADDRESS_FIELD | 'username' | Field on the User model, which has ethereum address to check against. | 37 | +--------------------------------+------------+-------------------------------------------------------------------------+ 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alexander Tereshkin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | MIT License 24 | 25 | Copyright (c) 2018 Bearle 26 | 27 | Permission is hereby granted, free of charge, to any person obtaining a copy 28 | of this software and associated documentation files (the "Software"), to deal 29 | in the Software without restriction, including without limitation the rights 30 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 31 | copies of the Software, and to permit persons to whom the Software is 32 | furnished to do so, subject to the following conditions: 33 | 34 | The above copyright notice and this permission notice shall be included in all 35 | copies or substantial portions of the Software. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 38 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 39 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 40 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 42 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 43 | SOFTWARE. 44 | -------------------------------------------------------------------------------- /web3auth/forms.py: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | from django import forms 4 | from django.contrib.auth import get_user_model 5 | from django.utils.translation import ugettext_lazy as _ 6 | 7 | from web3auth.settings import app_settings 8 | from .utils import validate_eth_address 9 | 10 | 11 | class LoginForm(forms.Form): 12 | signature = forms.CharField(widget=forms.HiddenInput, max_length=132) 13 | address = forms.CharField(widget=forms.HiddenInput, max_length=42, validators=[validate_eth_address]) 14 | 15 | def __init__(self, token, *args, **kwargs): 16 | self.token = token 17 | super(LoginForm, self).__init__(*args, **kwargs) 18 | 19 | def clean_signature(self): 20 | sig = self.cleaned_data['signature'] 21 | if any([ 22 | len(sig) != 132, 23 | sig[130:] != '1b' and sig[130:] != '1c', 24 | not all(c in string.hexdigits for c in sig[2:]) 25 | ]): 26 | raise forms.ValidationError(_('Invalid signature')) 27 | return sig 28 | 29 | 30 | # list(set()) here is to eliminate the possibility of double including the address field 31 | signup_fields = list(set(app_settings.WEB3AUTH_USER_SIGNUP_FIELDS + [app_settings.WEB3AUTH_USER_ADDRESS_FIELD])) 32 | 33 | 34 | class SignupForm(forms.ModelForm): 35 | 36 | def __init__(self, *args, **kwargs): 37 | # first call parent's constructor 38 | super().__init__(*args, **kwargs) 39 | 40 | # make sure to make email required, because password is not set 41 | # and if the user loses private key he can get 'reset' password link to email 42 | if 'email' in app_settings.WEB3AUTH_USER_SIGNUP_FIELDS: 43 | self.fields['email'].required = True 44 | self.fields[app_settings.WEB3AUTH_USER_ADDRESS_FIELD].required = True 45 | 46 | def clean_address_field(self): 47 | validate_eth_address(self.cleaned_data[app_settings.WEB3AUTH_USER_ADDRESS_FIELD]) 48 | return self.cleaned_data[app_settings.WEB3AUTH_USER_ADDRESS_FIELD].lower() 49 | 50 | class Meta: 51 | model = get_user_model() 52 | fields = signup_fields 53 | 54 | 55 | # hack to set the method for cleaning address field 56 | setattr(SignupForm, 'clean_' + app_settings.WEB3AUTH_USER_ADDRESS_FIELD, SignupForm.clean_address_field) 57 | -------------------------------------------------------------------------------- /docs/overview.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Overview 3 | ======== 4 | 5 | Django-web3-auth features 1 view for login (with JSON responses) 6 | and 2 views for Signup (one with JSON responses, and the other - using Django Forms and rendered templates). 7 | 8 | It also has 2 forms, SignupForm (rendered) and LoginForm (uses hidden inputs, used to validate data only). 9 | 10 | Possible configuration includes customizable address field (``WEB3AUTH_USER_ADDRESS_FIELD``), additional fields for User model (``WEB3AUTH_USER_SIGNUP_FIELDS``) and on/off switch for registration (``WEB3AUTH_SIGNUP_ENABLED``). 11 | You can read more on that in the Configuration section. 12 | 13 | Sign up 14 | ------- 15 | 16 | The signup process is as follows (signup_view example, signup_api is similar): 17 | 18 | 1. User heads to the signup URL (``{% url 'web3auth:web3auth_signup' %}``) 19 | 2. The signup view is rendered with a ``SignupForm`` which includes ``WEB3AUTH_USER_SIGNUP_FIELDS`` and ``WEB3AUTH_USER_ADDRESS_FIELD`` 20 | 3. The user enters required data and clicks the submit button and the POST request fires to the same URL with ``signup_view`` 21 | 4. Signup view does the following: 22 | 4.1. Creates an instance of a ``SignupForm``. 23 | 4.2. Checks if the registration is enabled. 24 | 4.3. If the registration is closed or form has errors, returns form with errors 25 | 4.4 If the form is valid, saves the user without saving to DB 26 | 4.5. Sets the user address from the form, saves it to DB 27 | 4.6. Logins the user using ``web3auth.backend.Web3Backend`` 28 | 4.7. Redirects the user to ``LOGIN_REDIRECT_URL`` or 'next' in get or post params 29 | 5. The user is signed up and logged in 30 | 31 | Login 32 | ----- 33 | 34 | The login process is as follows (login_api example): 35 | 36 | 1. On some page of the website, there is Javascript which fires a GET request to the ``{% url 'web3auth:web3auth_login_api' %}`` 37 | 2. The ``login_api`` view returns 32-char length login token 38 | 3. Javascript on the page invites user to sign the token using web3 instance (probably Metamask) 39 | 4. If the token is signed, the signature and address are sent ot he same ``login_api`` view 40 | 5. The view validates signature & address against ``LoginForm`` to check that the token is signed correctly 41 | 6. If the form is valid, the view tries to ``authenticate`` the user with given token,address and signature 42 | 7. If the user is found, the user is signed in and the view responds with a ``redirect_url`` for Javascript to handle 43 | 8. If the user is not found, the corresponding error is returned 44 | 45 | 46 | The Javascript is included in the app, also you can check out example app if you are struggling with logging in the user. 47 | -------------------------------------------------------------------------------- /web3auth/utils.py: -------------------------------------------------------------------------------- 1 | import sha3 2 | from eth_utils import is_hex_address 3 | from django import forms 4 | from django.utils.translation import ugettext_lazy as _ 5 | from py_ecc.secp256k1 import ecdsa_raw_recover 6 | from rlp.utils import ALL_BYTES 7 | try: 8 | import coincurve 9 | except ImportError: 10 | import warnings 11 | warnings.warn('could not import coincurve', ImportWarning) 12 | coincurve = None 13 | 14 | def encode_int32(v): 15 | return v.to_bytes(32, byteorder='big') 16 | 17 | def bytearray_to_bytestr(value): 18 | return bytes(value) 19 | 20 | def int_to_32bytearray(i): 21 | o = [0] * 32 22 | for x in range(32): 23 | o[31 - x] = i & 0xff 24 | i >>= 8 25 | return o 26 | 27 | def ascii_chr(n): 28 | return ALL_BYTES[n] 29 | 30 | def zpad(x, l): 31 | """ Left zero pad value `x` at least to length `l`. 32 | 33 | >>> zpad('', 1) 34 | '\x00' 35 | >>> zpad('\xca\xfe', 4) 36 | '\x00\x00\xca\xfe' 37 | >>> zpad('\xff', 1) 38 | '\xff' 39 | >>> zpad('\xca\xfe', 2) 40 | '\xca\xfe' 41 | """ 42 | return b'\x00' * max(0, l - len(x)) + x 43 | 44 | 45 | def ecrecover_to_pub(rawhash, v, r, s): 46 | if coincurve and hasattr(coincurve, "PublicKey"): 47 | try: 48 | pk = coincurve.PublicKey.from_signature_and_message( 49 | zpad(bytearray_to_bytestr(int_to_32bytearray(r)), 32) + zpad(bytearray_to_bytestr(int_to_32bytearray(s)), 32) + 50 | ascii_chr(v - 27), 51 | rawhash, 52 | hasher=None, 53 | ) 54 | pub = pk.format(compressed=False)[1:] 55 | except BaseException: 56 | pub = b"\x00" * 64 57 | else: 58 | result = ecdsa_raw_recover(rawhash, (v, r, s)) 59 | if result: 60 | x, y = result 61 | pub = encode_int32(x) + encode_int32(y) 62 | else: 63 | raise ValueError('Invalid VRS') 64 | assert len(pub) == 64 65 | return pub 66 | 67 | def sig_to_vrs(sig): 68 | # sig_bytes = bytes.fromhex(sig[2:]) 69 | r = int(sig[2:66], 16) 70 | s = int(sig[66:130], 16) 71 | v = int(sig[130:], 16) 72 | return v, r, s 73 | 74 | 75 | def hash_personal_message(msg): 76 | padded = "\x19Ethereum Signed Message:\n" + str(len(msg)) + msg 77 | return sha3.keccak_256(bytes(padded, 'utf8')).digest() 78 | 79 | 80 | def recover_to_addr(msg, sig): 81 | msghash = hash_personal_message(msg) 82 | vrs = sig_to_vrs(sig) 83 | return '0x' + sha3.keccak_256(ecrecover_to_pub(msghash, *vrs)).hexdigest()[24:] 84 | 85 | 86 | def validate_eth_address(value): 87 | if not is_hex_address(value): 88 | raise forms.ValidationError( 89 | _('%(value)s is not a valid Ethereum address'), 90 | params={'value': value}, 91 | ) 92 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import os 4 | import re 5 | import sys 6 | 7 | try: 8 | from setuptools import setup 9 | except ImportError: 10 | from distutils.core import setup 11 | 12 | 13 | def get_version(*file_paths): 14 | """Retrieves the version from web3auth/__init__.py""" 15 | filename = os.path.join(os.path.dirname(__file__), *file_paths) 16 | version_file = open(filename).read() 17 | version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", 18 | version_file, re.M) 19 | if version_match: 20 | return version_match.group(1) 21 | raise RuntimeError('Unable to find version string.') 22 | 23 | 24 | version = get_version("web3auth", "__init__.py") 25 | 26 | if sys.argv[-1] == 'publish': 27 | try: 28 | import wheel 29 | 30 | print("Wheel version: ", wheel.__version__) 31 | except ImportError: 32 | print('Wheel library missing. Please run "pip install wheel"') 33 | sys.exit() 34 | os.system('python setup.py sdist upload') 35 | os.system('python setup.py bdist_wheel upload') 36 | sys.exit() 37 | 38 | if sys.argv[-1] == 'tag': 39 | print("Tagging the version on git:") 40 | os.system("git tag -a %s -m 'version %s'" % (version, version)) 41 | os.system("git push --tags") 42 | sys.exit() 43 | 44 | readme = open('README.rst').read() 45 | history = open('HISTORY.rst').read().replace('.. :changelog:', '') 46 | 47 | setup( 48 | name='django-web3-auth', 49 | version=version, 50 | description="""django-web3-auth is a pluggable Django app that enables login/signup via an Ethereum wallet (a la CryptoKitties). The user authenticates themselves by digitally signing the session key with their wallet's private key.""", # noqa: E501 51 | long_description=readme + '\n\n' + history, 52 | author='Bearle', 53 | author_email='tech@bearle.ru', 54 | url='https://github.com/Bearle/django-web3-auth', 55 | packages=[ 56 | 'web3auth', 57 | ], 58 | include_package_data=True, 59 | install_requires=['coincurve>=18.0.0', 'rlp>=2.0.0', 'eth_utils>=1.0.3', 'Django>=2.0'], 60 | license="MIT", 61 | zip_safe=False, 62 | keywords='django-web3-auth', 63 | classifiers=[ 64 | 'Development Status :: 3 - Alpha', 65 | 'Framework :: Django :: 1.11', 66 | 'Framework :: Django :: 2.0', 67 | 'Intended Audience :: Developers', 68 | 'License :: OSI Approved :: BSD License', 69 | 'Natural Language :: English', 70 | 'Programming Language :: Python :: 2', 71 | 'Programming Language :: Python :: 2.7', 72 | 'Programming Language :: Python :: 3', 73 | 'Programming Language :: Python :: 3.4', 74 | 'Programming Language :: Python :: 3.5', 75 | 'Programming Language :: Python :: 3.6', 76 | ], 77 | ) 78 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | __pycache__ 6 | 7 | # C extensions 8 | *.so 9 | 10 | # If you are using PyCharm # 11 | .idea/**/workspace.xml 12 | .idea/**/tasks.xml 13 | .idea/dictionaries 14 | .idea/**/dataSources/ 15 | .idea/**/dataSources.ids 16 | .idea/**/dataSources.xml 17 | .idea/**/dataSources.local.xml 18 | .idea/**/sqlDataSources.xml 19 | .idea/**/dynamic.xml 20 | .idea/**/uiDesigner.xml 21 | .idea/**/gradle.xml 22 | .idea/**/libraries 23 | *.iws /out/ 24 | 25 | # Distribution / packaging 26 | .Python 27 | build/ 28 | develop-eggs/ 29 | dist/ 30 | downloads/ 31 | eggs/ 32 | .eggs/ 33 | lib/ 34 | lib64/ 35 | parts/ 36 | sdist/ 37 | var/ 38 | wheels/ 39 | pip-wheel-metadata/ 40 | share/python-wheels/ 41 | *.egg-info/ 42 | .installed.cfg 43 | *.egg 44 | MANIFEST 45 | 46 | # PyInstaller 47 | # Usually these files are written by a python script from a template 48 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 49 | *.manifest 50 | *.spec 51 | 52 | # Installer logs 53 | pip-log.txt 54 | pip-delete-this-directory.txt 55 | 56 | # Unit test / coverage reports 57 | htmlcov/ 58 | .tox/ 59 | .nox/ 60 | .coverage 61 | .coverage.* 62 | .cache 63 | nosetests.xml 64 | coverage.xml 65 | *.cover 66 | *.py,cover 67 | .hypothesis/ 68 | .pytest_cache/ 69 | 70 | # Translations 71 | *.mo 72 | *.pot 73 | 74 | # Django stuff: 75 | *.log 76 | local_settings.py 77 | db.sqlite3 78 | db.sqlite3-journal 79 | 80 | # Flask stuff: 81 | instance/ 82 | .webassets-cache 83 | 84 | # Scrapy stuff: 85 | .scrapy 86 | 87 | # Sphinx documentation 88 | docs/_build/ 89 | 90 | # PyBuilder 91 | target/ 92 | 93 | # Jupyter Notebook 94 | .ipynb_checkpoints 95 | 96 | # IPython 97 | profile_default/ 98 | ipython_config.py 99 | 100 | # pyenv 101 | .python-version 102 | 103 | # pipenv 104 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 105 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 106 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 107 | # install all needed dependencies. 108 | #Pipfile.lock 109 | 110 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 111 | __pypackages__/ 112 | 113 | # Celery stuff 114 | celerybeat-schedule 115 | celerybeat.pid 116 | 117 | # SageMath parsed files 118 | *.sage.py 119 | 120 | # Environments 121 | .env 122 | .venv 123 | env/ 124 | venv/ 125 | ENV/ 126 | env.bak/ 127 | venv.bak/ 128 | 129 | # Spyder project settings 130 | .spyderproject 131 | .spyproject 132 | 133 | # Rope project settings 134 | .ropeproject 135 | 136 | # mkdocs documentation 137 | /site 138 | 139 | # mypy 140 | .mypy_cache/ 141 | .dmypy.json 142 | dmypy.json 143 | 144 | # Pyre type checker 145 | .pyre/ 146 | 147 | -# Mr Developer 148 | -.mr.developer.cfg 149 | -.project 150 | -.pydevproject 151 | 152 | -# Sphinx 153 | -docs/_build 154 | 155 | -# Complexity 156 | -output/*.html 157 | -output/*/index.html 158 | 159 | -example/db.sqlite3 160 | -------------------------------------------------------------------------------- /example/templates/web3auth/base.html: -------------------------------------------------------------------------------- 1 | {% load staticfiles i18n %} 2 | 3 | 4 | 5 | 6 | {% block title %}Django-Web3-Auth{% endblock title %} 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | {% block css %} 17 | 18 | 20 | 21 | 22 | 23 | {% endblock %} 24 | 25 | 26 | 27 | 28 |
29 | 51 | 52 |
53 |
54 | 55 | {% if messages %} 56 | {% for message in messages %} 57 |
{{ message }}
58 | {% endfor %} 59 | {% endif %} 60 | 61 | {% block content %} 62 |
63 |

Use this document as a way to quick start any new project.

64 |

The current template is loaded from 65 | django-web3-auth/example/templates/base.html.

66 |

Whenever you overwrite the contents of django-web3-auth/web3auth/urls.py with your 67 | own content, you should see it here.

68 |
69 | {% endblock content %} 70 | 71 |
72 | 73 | {% block modal %}{% endblock modal %} 74 | 75 | 77 | 78 | {% block javascript %} 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | {% endblock javascript %} 92 | 93 | 94 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Contributing 3 | ============ 4 | 5 | Contributions are welcome, and they are greatly appreciated! Every 6 | little bit helps, and credit will always be given. 7 | 8 | You can contribute in many ways: 9 | 10 | Types of Contributions 11 | ---------------------- 12 | 13 | Report Bugs 14 | ~~~~~~~~~~~ 15 | 16 | Report bugs at https://github.com/Bearle/django-web3-auth/issues. 17 | 18 | If you are reporting a bug, please include: 19 | 20 | * Your operating system name and version. 21 | * Any details about your local setup that might be helpful in troubleshooting. 22 | * Detailed steps to reproduce the bug. 23 | 24 | Fix Bugs 25 | ~~~~~~~~ 26 | 27 | Look through the GitHub issues for bugs. Anything tagged with "bug" 28 | is open to whoever wants to implement it. 29 | 30 | Implement Features 31 | ~~~~~~~~~~~~~~~~~~ 32 | 33 | Look through the GitHub issues for features. Anything tagged with "feature" 34 | is open to whoever wants to implement it. 35 | 36 | Write Documentation 37 | ~~~~~~~~~~~~~~~~~~~ 38 | 39 | Django-Web3-Auth could always use more documentation, whether as part of the 40 | official Django-Web3-Auth docs, in docstrings, or even on the web in blog posts, 41 | articles, and such. 42 | 43 | Submit Feedback 44 | ~~~~~~~~~~~~~~~ 45 | 46 | The best way to send feedback is to file an issue at https://github.com/Bearle/django-web3-auth/issues. 47 | 48 | If you are proposing a feature: 49 | 50 | * Explain in detail how it would work. 51 | * Keep the scope as narrow as possible, to make it easier to implement. 52 | * Remember that this is a volunteer-driven project, and that contributions 53 | are welcome :) 54 | 55 | Get Started! 56 | ------------ 57 | 58 | Ready to contribute? Here's how to set up `django-web3-auth` for local development. 59 | 60 | 1. Fork the `django-web3-auth` repo on GitHub. 61 | 2. Clone your fork locally:: 62 | 63 | $ git clone git@github.com:your_name_here/django-web3-auth.git 64 | 65 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 66 | 67 | $ mkvirtualenv django-web3-auth 68 | $ cd django-web3-auth/ 69 | $ python setup.py develop 70 | 71 | 4. Create a branch for local development:: 72 | 73 | $ git checkout -b name-of-your-bugfix-or-feature 74 | 75 | Now you can make your changes locally. 76 | 77 | 5. When you're done making changes, check that your changes pass flake8 and the 78 | tests, including testing other Python versions with tox:: 79 | 80 | $ flake8 web3auth tests 81 | $ python setup.py test 82 | $ tox 83 | 84 | To get flake8 and tox, just pip install them into your virtualenv. 85 | 86 | 6. Commit your changes and push your branch to GitHub:: 87 | 88 | $ git add . 89 | $ git commit -m "Your detailed description of your changes." 90 | $ git push origin name-of-your-bugfix-or-feature 91 | 92 | 7. Submit a pull request through the GitHub website. 93 | 94 | Pull Request Guidelines 95 | ----------------------- 96 | 97 | Before you submit a pull request, check that it meets these guidelines: 98 | 99 | 1. The pull request should include tests. 100 | 2. If the pull request adds functionality, the docs should be updated. Put 101 | your new functionality into a function with a docstring, and add the 102 | feature to the list in README.rst. 103 | 3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check 104 | https://travis-ci.org/Bearle/django-web3-auth/pull_requests 105 | and make sure that the tests pass for all supported Python versions. 106 | 107 | Tips 108 | ---- 109 | 110 | To run a subset of tests:: 111 | 112 | $ python -m unittest tests.test_web3auth 113 | -------------------------------------------------------------------------------- /example/example/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for example project. 3 | 4 | Generated by Cookiecutter Django Package 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.9/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | # Quick-start development settings - unsuitable for production 19 | # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ 20 | 21 | # SECURITY WARNING: keep the secret key used in production secret! 22 | SECRET_KEY = "11111111111111111111111111111111111111111111111111" 23 | 24 | # SECURITY WARNING: don't run with debug turned on in production! 25 | DEBUG = True 26 | 27 | ALLOWED_HOSTS = [] 28 | 29 | # Application definition 30 | 31 | INSTALLED_APPS = [ 32 | 'django.contrib.admin', 33 | 'django.contrib.auth', 34 | 'django.contrib.contenttypes', 35 | 'django.contrib.sessions', 36 | 'django.contrib.messages', 37 | 'django.contrib.staticfiles', 38 | 39 | 'web3auth', 40 | 41 | # if your app has other dependencies that need to be added to the site 42 | # they should be added here 43 | ] 44 | 45 | l = [ 46 | 'django.middleware.security.SecurityMiddleware', 47 | 'django.contrib.sessions.middleware.SessionMiddleware', 48 | 'django.middleware.common.CommonMiddleware', 49 | 'django.middleware.csrf.CsrfViewMiddleware', 50 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 51 | 'django.contrib.messages.middleware.MessageMiddleware', 52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 53 | ] 54 | 55 | from django import get_version 56 | from packaging import version 57 | 58 | if version.parse(get_version()) < version.parse("1.10"): 59 | MIDDLEWARE_CLASSES = l 60 | MIDDLEWARE_CLASSES += ['django.contrib.auth.middleware.SessionAuthenticationMiddleware', ] 61 | else: 62 | MIDDLEWARE = l 63 | 64 | ROOT_URLCONF = 'example.urls' 65 | 66 | TEMPLATES = [ 67 | { 68 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 69 | 'DIRS': [os.path.join(BASE_DIR, 'templates'), ], 70 | 'APP_DIRS': True, 71 | 'OPTIONS': { 72 | 'context_processors': [ 73 | 'django.template.context_processors.debug', 74 | 'django.template.context_processors.request', 75 | 'django.contrib.auth.context_processors.auth', 76 | 'django.contrib.messages.context_processors.messages', 77 | ], 78 | }, 79 | }, 80 | ] 81 | 82 | WSGI_APPLICATION = 'example.wsgi.application' 83 | 84 | # Database 85 | # https://docs.djangoproject.com/en/1.9/ref/settings/#databases 86 | 87 | DATABASES = { 88 | 'default': { 89 | 'ENGINE': 'django.db.backends.sqlite3', 90 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 91 | } 92 | } 93 | 94 | # Password validation 95 | # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators 96 | 97 | AUTH_PASSWORD_VALIDATORS = [ 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 106 | }, 107 | { 108 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 109 | }, 110 | ] 111 | 112 | AUTHENTICATION_BACKENDS = [ 113 | 'django.contrib.auth.backends.ModelBackend', 114 | 'web3auth.backend.Web3Backend' 115 | ] 116 | # Internationalization 117 | # https://docs.djangoproject.com/en/1.9/topics/i18n/ 118 | 119 | LANGUAGE_CODE = 'en-us' 120 | 121 | TIME_ZONE = 'UTC' 122 | 123 | USE_I18N = True 124 | 125 | USE_L10N = True 126 | 127 | USE_TZ = True 128 | 129 | # Static files (CSS, JavaScript, Images) 130 | # https://docs.djangoproject.com/en/1.9/howto/static-files/ 131 | 132 | STATIC_URL = '/static/' 133 | LOGIN_REDIRECT_URL = '/admin/login' 134 | -------------------------------------------------------------------------------- /web3auth/views.py: -------------------------------------------------------------------------------- 1 | import json 2 | import random 3 | import string 4 | 5 | from django.conf import settings 6 | from django.contrib.auth import login, authenticate 7 | from django.http import JsonResponse 8 | from django.shortcuts import render, redirect, reverse 9 | from django.urls.exceptions import NoReverseMatch 10 | from django.utils.translation import ugettext_lazy as _ 11 | from django.views.decorators.http import require_http_methods 12 | 13 | from web3auth.forms import LoginForm, SignupForm 14 | from web3auth.settings import app_settings 15 | 16 | 17 | def get_redirect_url(request): 18 | if request.GET.get('next'): 19 | return request.GET.get('next') 20 | elif request.POST.get('next'): 21 | return request.POST.get('next') 22 | elif settings.LOGIN_REDIRECT_URL: 23 | try: 24 | url = reverse(settings.LOGIN_REDIRECT_URL) 25 | except NoReverseMatch: 26 | url = settings.LOGIN_REDIRECT_URL 27 | return url 28 | 29 | 30 | @require_http_methods(["GET", "POST"]) 31 | def login_api(request): 32 | if request.method == 'GET': 33 | token = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for i in range(32)) 34 | request.session['login_token'] = token 35 | return JsonResponse({'data': token, 'success': True}) 36 | else: 37 | token = request.session.get('login_token') 38 | if not token: 39 | return JsonResponse({'error': _( 40 | "No login token in session, please request token again by sending GET request to this url"), 41 | 'success': False}) 42 | else: 43 | form = LoginForm(token, request.POST) 44 | if form.is_valid(): 45 | signature, address = form.cleaned_data.get("signature"), form.cleaned_data.get("address") 46 | del request.session['login_token'] 47 | user = authenticate(request, token=token, address=address, signature=signature) 48 | if user: 49 | login(request, user, 'web3auth.backend.Web3Backend') 50 | 51 | return JsonResponse({'success': True, 'redirect_url': get_redirect_url(request)}) 52 | else: 53 | error = _("Can't find a user for the provided signature with address {address}").format( 54 | address=address) 55 | return JsonResponse({'success': False, 'error': error}) 56 | else: 57 | return JsonResponse({'success': False, 'error': json.loads(form.errors.as_json())}) 58 | 59 | 60 | @require_http_methods(["POST"]) 61 | def signup_api(request): 62 | if not app_settings.WEB3AUTH_SIGNUP_ENABLED: 63 | return JsonResponse({'success': False, 'error': _("Sorry, signup's are currently disabled")}) 64 | form = SignupForm(request.POST) 65 | if form.is_valid(): 66 | user = form.save(commit=False) 67 | addr_field = app_settings.WEB3AUTH_USER_ADDRESS_FIELD 68 | setattr(user, addr_field, form.cleaned_data[addr_field]) 69 | user.save() 70 | login(request, user, 'web3auth.backend.Web3Backend') 71 | return JsonResponse({'success': True, 'redirect_url': get_redirect_url(request)}) 72 | else: 73 | return JsonResponse({'success': False, 'error': json.loads(form.errors.as_json())}) 74 | 75 | 76 | @require_http_methods(["GET", "POST"]) 77 | def signup_view(request, template_name='web3auth/signup.html'): 78 | """ 79 | 1. Creates an instance of a SignupForm. 80 | 2. Checks if the registration is enabled. 81 | 3. If the registration is closed or form has errors, returns form with errors 82 | 4. If the form is valid, saves the user without saving to DB 83 | 5. Sets the user address from the form, saves it to DB 84 | 6. Logins the user using web3auth.backend.Web3Backend 85 | 7. Redirects the user to LOGIN_REDIRECT_URL or 'next' in get or post params 86 | :param request: Django request 87 | :param template_name: Template to render 88 | :return: rendered template with form 89 | """ 90 | form = SignupForm() 91 | if not app_settings.WEB3AUTH_SIGNUP_ENABLED: 92 | form.add_error(None, _("Sorry, signup's are currently disabled")) 93 | else: 94 | if request.method == 'POST': 95 | form = SignupForm(request.POST) 96 | if form.is_valid(): 97 | user = form.save(commit=False) 98 | addr_field = app_settings.WEB3AUTH_USER_ADDRESS_FIELD 99 | setattr(user, addr_field, form.cleaned_data[addr_field]) 100 | user.save() 101 | login(request, user, 'web3auth.backend.Web3Backend') 102 | return redirect(get_redirect_url(request)) 103 | return render(request, 104 | template_name, 105 | {'form': form}) 106 | -------------------------------------------------------------------------------- /web3auth/static/web3auth/js/web3auth.js: -------------------------------------------------------------------------------- 1 | function getCookie(name) { 2 | var cookieValue = null; 3 | if (document.cookie && document.cookie != '') { 4 | var cookies = document.cookie.split(';'); 5 | for (var i = 0; i < cookies.length; i++) { 6 | var cookie = jQuery.trim(cookies[i]); 7 | // Does this cookie string begin with the name we want? 8 | if (cookie.substring(0, name.length + 1) == (name + '=')) { 9 | cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 10 | break; 11 | } 12 | } 13 | } 14 | return cookieValue; 15 | } 16 | 17 | function loginWithSignature(address, signature, login_url, onLoginRequestError, onLoginFail, onLoginSuccess) { 18 | var request = new XMLHttpRequest(); 19 | request.open('POST', login_url, true); 20 | request.onload = function () { 21 | if (request.status >= 200 && request.status < 400) { 22 | // Success! 23 | var resp = JSON.parse(request.responseText); 24 | if (resp.success) { 25 | if (typeof onLoginSuccess == 'function') { 26 | onLoginSuccess(resp); 27 | } 28 | } else { 29 | if (typeof onLoginFail == 'function') { 30 | onLoginFail(resp); 31 | } 32 | } 33 | } else { 34 | // We reached our target server, but it returned an error 35 | console.log("Autologin failed - request status " + request.status); 36 | if (typeof onLoginRequestError == 'function') { 37 | onLoginRequestError(request); 38 | } 39 | } 40 | }; 41 | 42 | request.onerror = function () { 43 | console.log("Autologin failed - there was an error"); 44 | if (typeof onLoginRequestError == 'function') { 45 | onLoginRequestError(request); 46 | } 47 | // There was a connection error of some sort 48 | }; 49 | request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 50 | request.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); 51 | var formData = 'address=' + address + '&signature=' + signature; 52 | request.send(formData); 53 | } 54 | 55 | function checkWeb3(callback) { 56 | web3.eth.getAccounts(function (err, accounts) { // Check for wallet being locked 57 | if (err) { 58 | throw err; 59 | } 60 | callback(accounts.length !== 0); 61 | }); 62 | } 63 | 64 | function web3Login(login_url, onTokenRequestFail, onTokenSignFail, onTokenSignSuccess, // used in this function 65 | onLoginRequestError, onLoginFail, onLoginSuccess) { 66 | // used in loginWithSignature 67 | 68 | // 1. Retrieve arbitrary login token from server 69 | // 2. Sign it using web3 70 | // 3. Send signed message & your eth address to server 71 | // 4. If server validates that you signature is valid 72 | // 4.1 The user with an according eth address is found - you are logged in 73 | // 4.2 The user with an according eth address is NOT found - you are redirected to signup page 74 | 75 | 76 | var request = new XMLHttpRequest(); 77 | request.open('GET', login_url, true); 78 | 79 | request.onload = function () { 80 | if (request.status >= 200 && request.status < 400) { 81 | // Success! 82 | var resp = JSON.parse(request.responseText); 83 | var token = resp.data; 84 | console.log("Token: " + token); 85 | var msg = web3.toHex(token); 86 | var from = web3.eth.accounts[0]; 87 | web3.personal.sign(msg, from, function (err, result) { 88 | if (err) { 89 | if (typeof onTokenSignFail == 'function') { 90 | onTokenSignFail(err); 91 | } 92 | console.log("Failed signing message \n" + msg + "\n - " + err); 93 | } else { 94 | console.log("Signed message: " + result); 95 | if (typeof onTokenSignSuccess == 'function') { 96 | onTokenSignSuccess(result); 97 | } 98 | loginWithSignature(from, result, login_url, onLoginRequestError, onLoginFail, onLoginSuccess); 99 | } 100 | }); 101 | 102 | } else { 103 | // We reached our target server, but it returned an error 104 | console.log("Autologin failed - request status " + request.status); 105 | if (typeof onTokenRequestFail == 'function') { 106 | onTokenRequestFail(request); 107 | } 108 | } 109 | }; 110 | 111 | request.onerror = function () { 112 | // There was a connection error of some sort 113 | console.log("Autologin failed - there was an error"); 114 | if (typeof onTokenRequestFail == 'function') { 115 | onTokenRequestFail(request); 116 | } 117 | }; 118 | request.send(); 119 | } 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ============================= 2 | Django-Web3-Auth 3 | ============================= 4 | 5 | .. image:: https://badge.fury.io/py/django-web3-auth.svg 6 | :target: https://badge.fury.io/py/django-web3-auth 7 | 8 | .. image:: https://travis-ci.org/Bearle/django-web3-auth.svg?branch=master 9 | :target: https://travis-ci.org/Bearle/django-web3-auth 10 | 11 | .. image:: https://codecov.io/gh/Bearle/django-web3-auth/branch/master/graph/badge.svg 12 | :target: https://codecov.io/gh/Bearle/django-web3-auth 13 | 14 | django-web3-auth is a pluggable Django app that enables login/signup via an Ethereum wallet (a la CryptoKitties). The user authenticates themselves by digitally signing the session key with their wallet's private key. 15 | 16 | .. image:: https://github.com/Bearle/django-web3-auth/blob/master/docs/_static/web3_auth_test.gif?raw=true 17 | 18 | Documentation 19 | ------------- 20 | 21 | The full documentation is at https://django-web3-auth.readthedocs.io. 22 | 23 | Example project 24 | --------------- 25 | 26 | https://github.com/Bearle/django-web3-auth/tree/master/example 27 | 28 | You can check out our example project by cloning the repo and heading into example/ directory. 29 | There is a README file for you to check, also. 30 | 31 | 32 | Features 33 | -------- 34 | 35 | * Web3 API login, signup 36 | * Web3 Django forms for signup, login 37 | * Checks ethereum address validity 38 | * Uses random token signing as proof of private key posession 39 | * Easy to set up and use (just one click) 40 | * Custom auth backend 41 | * VERY customizable - uses Django settings, allows for custom User model 42 | * Vanilla Javascript helpers included 43 | 44 | Quickstart 45 | ---------- 46 | Install Django-Web3-Auth with pip:: 47 | 48 | pip install django-web3-auth 49 | 50 | Add it to your `INSTALLED_APPS`: 51 | 52 | .. code-block:: python 53 | 54 | INSTALLED_APPS = ( 55 | ... 56 | 'web3auth.apps.Web3AuthConfig', 57 | ... 58 | ) 59 | 60 | Set `'web3auth.backend.Web3Backend'` as your authentication backend: 61 | 62 | .. code-block:: python 63 | 64 | AUTHENTICATION_BACKENDS = [ 65 | 'django.contrib.auth.backends.ModelBackend', 66 | 'web3auth.backend.Web3Backend' 67 | ] 68 | 69 | Set your User model's field to use as ETH address provider: 70 | 71 | .. code-block:: python 72 | 73 | WEB3AUTH_USER_ADDRESS_FIELD = 'username' 74 | 75 | And if you have some other fields you want to be in the SignupForm, add them too: 76 | 77 | .. code-block:: python 78 | 79 | WEB3AUTH_USER_SIGNUP_FIELDS = ['email',] 80 | 81 | 82 | Add Django-Web3-Auth's URL patterns: 83 | 84 | .. code-block:: python 85 | 86 | from web3auth import urls as web3auth_urls 87 | 88 | 89 | urlpatterns = [ 90 | ... 91 | url(r'^', include(web3auth_urls)), 92 | ... 93 | ] 94 | 95 | Add some javascript to handle login: 96 | 97 | 98 | .. code-block:: html 99 | 100 | 101 | 102 | 103 | .. code-block:: javascript 104 | 105 | function startLogin() { 106 | if (typeof web3 !== 'undefined') { 107 | checkWeb3(function (loggedIn) { 108 | if (!loggedIn) { 109 | alert("Please unlock your web3 provider (probably, Metamask)") 110 | } else { 111 | var login_url = '{% url 'web3auth:web3auth_login_api' %}'; 112 | web3Login(login_url, console.log, console.log, console.log, console.log, console.log, function (resp) { 113 | console.log(resp); 114 | window.location.replace(resp.redirect_url); 115 | }); 116 | } 117 | }); 118 | 119 | } else { 120 | alert('web3 missing'); 121 | } 122 | } 123 | 124 | You can access signup using {% url 'web3auth:web3auth_signup' %}. 125 | 126 | If you have any questions left, head to the example app https://github.com/Bearle/django-web3-auth/tree/master/example 127 | 128 | 129 | 130 | Important details and FAQ 131 | ------------------------- 132 | 133 | 1. *If you set a custom address field (WEB3AUTH_USER_ADDRESS_FIELD), it MUST be unique (unique=True).* 134 | 135 | This is needed because if it's not, the user can register a new account with the same address as the other one, 136 | meaning that the user can now login as any of those accounts (sometimes being the wrong one). 137 | 138 | 2. *How do i deal with user passwords or Password is not set* 139 | There should be some code in your project that generates a password using ``User.objects.make_random_password`` and sends it to a user email. 140 | Or, even better, sends them a 'restore password' link. 141 | 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. 142 | 143 | 3. *Why do i have to sign a message? It's not needed in MyEtherWallet or other DApps!* 144 | 145 | The main reason is that when using a DApp, you most likely don't have an account on the website, it's accessible only with web3 (Metamask). 146 | When using web3 only to sign into user account, it is necessary to prove your identity with a private key (e.g. sign a random message), 147 | because when we have backend we can't trust any user just by his knowledge of the public address. 148 | Signed message proves that user possesses the private key, associated with the address. 149 | 150 | 151 | Running Tests 152 | ------------- 153 | 154 | Does the code actually work? 155 | 156 | :: 157 | 158 | source /bin/activate 159 | (myenv) $ pip install tox 160 | (myenv) $ tox 161 | 162 | Credits 163 | ------- 164 | 165 | Tools used in rendering this package: 166 | 167 | * Cookiecutter_ 168 | * `cookiecutter-djangopackage`_ 169 | 170 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 171 | .. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage 172 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/complexity.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/complexity.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/complexity" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/complexity" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\complexity.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\complexity.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # complexity documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jul 9 22:26:36 2013. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | cwd = os.getcwd() 22 | parent = os.path.dirname(cwd) 23 | sys.path.append(parent) 24 | 25 | import web3auth 26 | 27 | # -- General configuration ----------------------------------------------------- 28 | 29 | # If your documentation needs a minimal Sphinx version, state it here. 30 | #needs_sphinx = '1.0' 31 | 32 | # Add any Sphinx extension module names here, as strings. They can be extensions 33 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 34 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ['_templates'] 38 | 39 | # The suffix of source filenames. 40 | source_suffix = '.rst' 41 | 42 | # The encoding of source files. 43 | #source_encoding = 'utf-8-sig' 44 | 45 | # The master toctree document. 46 | master_doc = 'index' 47 | 48 | # General information about the project. 49 | project = u'Django-Web3-Auth' 50 | copyright = u'2018, Denis Bobrov' 51 | 52 | # The version info for the project you're documenting, acts as replacement for 53 | # |version| and |release|, also used in various other places throughout the 54 | # built documents. 55 | # 56 | # The short X.Y version. 57 | version = web3auth.__version__ 58 | # The full version, including alpha/beta/rc tags. 59 | release = web3auth.__version__ 60 | 61 | # The language for content autogenerated by Sphinx. Refer to documentation 62 | # for a list of supported languages. 63 | #language = None 64 | 65 | # There are two options for replacing |today|: either, you set today to some 66 | # non-false value, then it is used: 67 | #today = '' 68 | # Else, today_fmt is used as the format for a strftime call. 69 | #today_fmt = '%B %d, %Y' 70 | 71 | # List of patterns, relative to source directory, that match files and 72 | # directories to ignore when looking for source files. 73 | exclude_patterns = ['_build'] 74 | 75 | # The reST default role (used for this markup: `text`) to use for all documents. 76 | #default_role = None 77 | 78 | # If true, '()' will be appended to :func: etc. cross-reference text. 79 | #add_function_parentheses = True 80 | 81 | # If true, the current module name will be prepended to all description 82 | # unit titles (such as .. function::). 83 | #add_module_names = True 84 | 85 | # If true, sectionauthor and moduleauthor directives will be shown in the 86 | # output. They are ignored by default. 87 | #show_authors = False 88 | 89 | # The name of the Pygments (syntax highlighting) style to use. 90 | pygments_style = 'sphinx' 91 | 92 | # A list of ignored prefixes for module index sorting. 93 | #modindex_common_prefix = [] 94 | 95 | # If true, keep warnings as "system message" paragraphs in the built documents. 96 | #keep_warnings = False 97 | 98 | 99 | # -- Options for HTML output --------------------------------------------------- 100 | 101 | # The theme to use for HTML and HTML Help pages. See the documentation for 102 | # a list of builtin themes. 103 | import sphinx_rtd_theme 104 | html_theme = "sphinx_rtd_theme" 105 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] 106 | html_theme_options = { 107 | 'display_version': True, 108 | # Toc options 109 | 'collapse_navigation': False, 110 | 'sticky_navigation': True, 111 | 'navigation_depth': 4, 112 | } 113 | 114 | 115 | # Theme options are theme-specific and customize the look and feel of a theme 116 | # further. For a list of options available for each theme, see the 117 | # documentation. 118 | #html_theme_options = {} 119 | 120 | # Add any paths that contain custom themes here, relative to this directory. 121 | #html_theme_path = [] 122 | 123 | # The name for this set of Sphinx documents. If None, it defaults to 124 | # " v documentation". 125 | #html_title = None 126 | 127 | # A shorter title for the navigation bar. Default is the same as html_title. 128 | #html_short_title = None 129 | 130 | # The name of an image file (relative to this directory) to place at the top 131 | # of the sidebar. 132 | #html_logo = None 133 | 134 | # The name of an image file (within the static path) to use as favicon of the 135 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 136 | # pixels large. 137 | #html_favicon = None 138 | 139 | # Add any paths that contain custom static files (such as style sheets) here, 140 | # relative to this directory. They are copied after the builtin static files, 141 | # so a file named "default.css" will overwrite the builtin "default.css". 142 | html_static_path = ['_static'] 143 | 144 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 145 | # using the given strftime format. 146 | #html_last_updated_fmt = '%b %d, %Y' 147 | 148 | # If true, SmartyPants will be used to convert quotes and dashes to 149 | # typographically correct entities. 150 | #html_use_smartypants = True 151 | 152 | # Custom sidebar templates, maps document names to template names. 153 | #html_sidebars = {} 154 | 155 | # Additional templates that should be rendered to pages, maps page names to 156 | # template names. 157 | #html_additional_pages = {} 158 | 159 | # If false, no module index is generated. 160 | #html_domain_indices = True 161 | 162 | # If false, no index is generated. 163 | #html_use_index = True 164 | 165 | # If true, the index is split into individual pages for each letter. 166 | #html_split_index = False 167 | 168 | # If true, links to the reST sources are added to the pages. 169 | #html_show_sourcelink = True 170 | 171 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 172 | #html_show_sphinx = True 173 | 174 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 175 | #html_show_copyright = True 176 | 177 | # If true, an OpenSearch description file will be output, and all pages will 178 | # contain a tag referring to it. The value of this option must be the 179 | # base URL from which the finished HTML is served. 180 | #html_use_opensearch = '' 181 | 182 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 183 | #html_file_suffix = None 184 | 185 | # Output file base name for HTML help builder. 186 | htmlhelp_basename = 'django-web3-authdoc' 187 | 188 | 189 | # -- Options for LaTeX output -------------------------------------------------- 190 | 191 | latex_elements = { 192 | # The paper size ('letterpaper' or 'a4paper'). 193 | #'papersize': 'letterpaper', 194 | 195 | # The font size ('10pt', '11pt' or '12pt'). 196 | #'pointsize': '10pt', 197 | 198 | # Additional stuff for the LaTeX preamble. 199 | #'preamble': '', 200 | } 201 | 202 | # Grouping the document tree into LaTeX files. List of tuples 203 | # (source start file, target name, title, author, documentclass [howto/manual]). 204 | latex_documents = [ 205 | ('index', 'django-web3-auth.tex', u'Django-Web3-Auth Documentation', 206 | u'Denis Bobrov', 'manual'), 207 | ] 208 | 209 | # The name of an image file (relative to this directory) to place at the top of 210 | # the title page. 211 | #latex_logo = None 212 | 213 | # For "manual" documents, if this is true, then toplevel headings are parts, 214 | # not chapters. 215 | #latex_use_parts = False 216 | 217 | # If true, show page references after internal links. 218 | #latex_show_pagerefs = False 219 | 220 | # If true, show URL addresses after external links. 221 | #latex_show_urls = False 222 | 223 | # Documents to append as an appendix to all manuals. 224 | #latex_appendices = [] 225 | 226 | # If false, no module index is generated. 227 | #latex_domain_indices = True 228 | 229 | 230 | # -- Options for manual page output -------------------------------------------- 231 | 232 | # One entry per manual page. List of tuples 233 | # (source start file, name, description, authors, manual section). 234 | man_pages = [ 235 | ('index', 'django-web3-auth', u'Django-Web3-Auth Documentation', 236 | [u'Denis Bobrov'], 1) 237 | ] 238 | 239 | # If true, show URL addresses after external links. 240 | #man_show_urls = False 241 | 242 | 243 | # -- Options for Texinfo output ------------------------------------------------ 244 | 245 | # Grouping the document tree into Texinfo files. List of tuples 246 | # (source start file, target name, title, author, 247 | # dir menu entry, description, category) 248 | texinfo_documents = [ 249 | ('index', 'django-web3-auth', u'Django-Web3-Auth Documentation', 250 | u'Denis Bobrov', 'django-web3-auth', 'One line description of project.', 251 | 'Miscellaneous'), 252 | ] 253 | 254 | # Documents to append as an appendix to all manuals. 255 | #texinfo_appendices = [] 256 | 257 | # If false, no module index is generated. 258 | #texinfo_domain_indices = True 259 | 260 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 261 | #texinfo_show_urls = 'footnote' 262 | 263 | # If true, do not generate a @detailmenu in the "Top" node's menu. 264 | #texinfo_no_detailmenu = False 265 | 266 | sys.path.insert(0, os.path.abspath('..')) 267 | from django.conf import settings 268 | settings.configure() 269 | --------------------------------------------------------------------------------