update documentation
This commit is contained in:
parent
197fb789cf
commit
a7452c1e14
|
@ -94,6 +94,21 @@ Ready to contribute? Here's how to set up `django-cryptolock` for local developm
|
|||
|
||||
8. Submit a pull request through the GitHub website.
|
||||
|
||||
|
||||
Running tests for specific environments
|
||||
---------------------------------------
|
||||
|
||||
Do want to test only a specific python version / django version locally?
|
||||
|
||||
You can use tox directly::
|
||||
|
||||
::
|
||||
|
||||
source <YOURVIRTUALENV>/bin/activate
|
||||
(myenv) $ pip install tox
|
||||
(myenv) $ tox -e <your-python-version>-django-<22_or_30>
|
||||
|
||||
|
||||
Pull Request Guidelines
|
||||
-----------------------
|
||||
|
||||
|
|
70
README.rst
70
README.rst
|
@ -11,7 +11,13 @@ Django-Cryptolock
|
|||
.. image:: https://coveralls.io/repos/github/dethos/django-cryptolock/badge.svg
|
||||
:target: https://coveralls.io/github/dethos/django-cryptolock
|
||||
|
||||
Django authentication using cryptocurrency wallets.
|
||||
Authenticatio using cryptocurrency wallets for Django projects
|
||||
|
||||
This package provided a django app containing a set of utilities to make easier to
|
||||
implement the BitId and Monero Cryptolock authentication "protocols".
|
||||
|
||||
Future releases might include other cryptocurrencies but for the being
|
||||
(until we reach some stability) the focus will continue BTC and XMR.
|
||||
|
||||
**DISCLAIMER:** This package is still in an early stage of development. It isn't meant to be
|
||||
used on any production scenario yet (in other words, only test projects for now).
|
||||
|
@ -24,11 +30,11 @@ The full documentation is at https://django-cryptolock.readthedocs.io.
|
|||
Quickstart
|
||||
----------
|
||||
|
||||
Install Django-Cryptolock::
|
||||
1. Install Django-Cryptolock::
|
||||
|
||||
pip install django-cryptolock
|
||||
|
||||
Add it to your `INSTALLED_APPS`:
|
||||
2. Add it to your `INSTALLED_APPS`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -38,9 +44,26 @@ Add it to your `INSTALLED_APPS`:
|
|||
...
|
||||
)
|
||||
|
||||
Migrate your database.
|
||||
3. Migrate your database::
|
||||
|
||||
Add Django-Cryptolock's URL patterns:
|
||||
python manage.py migrate
|
||||
|
||||
|
||||
4. Add the following settings to your project for the Monero Backend:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
"django_cryptolock.backends.MoneroAddressBackend",
|
||||
...
|
||||
]
|
||||
DJCL_MONERO_NETWORK = "mainnet"
|
||||
DJCL_MONERO_WALLET_RPC_PROTOCOL = "<http_or_https>"
|
||||
DJCL_MONERO_WALLET_RPC_HOST = "<wallet_rpc_host>:<port>"
|
||||
DJCL_MONERO_WALLET_RPC_USER = "<user>"
|
||||
DJCL_MONERO_WALLET_RPC_PASS = "<password>"
|
||||
|
||||
5. Add Django-Cryptolock's URL patterns:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -53,42 +76,7 @@ Add Django-Cryptolock's URL patterns:
|
|||
...
|
||||
]
|
||||
|
||||
|
||||
Add the following settings to your project for the Monero Backend:
|
||||
|
||||
* ``django_cryptolock.backends.MoneroAddressBackend`` to your
|
||||
``AUTHENTICATION_BACKENDS``
|
||||
* Set ``DJCL_MONERO_NETWORK`` with the network in use: ``mainnet``,
|
||||
``stagenet`` or ``testnet``
|
||||
* Use ``DJCL_MONERO_WALLET_RPC_PROTOCOL``, ``DJCL_MONERO_WALLET_RPC_HOST``,
|
||||
``DJCL_MONERO_WALLET_RPC_USER`` and ``DJCL_MONERO_WALLET_RPC_PASS`` to specify
|
||||
which wallet RPC should be used.
|
||||
|
||||
In case only Bitcoin Backend is used, you just need:
|
||||
|
||||
* ``DJCL_BITCOIN_NETWORK`` with
|
||||
one of two possible values: ``mainnet`` or ``testnet``.
|
||||
* Add ``django_cryptolock.backends.BitcoinAddressBackend`` to your
|
||||
``AUTHENTICATION_BACKENDS``
|
||||
|
||||
Finaly create the templates files (``login.html`` and ``signup.html``) under a
|
||||
``django_cryptolock`` subfolder.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Adds authentication based on cryptocurrency wallets to a Django project.
|
||||
|
||||
Running Tests
|
||||
-------------
|
||||
|
||||
Does the code actually work?
|
||||
|
||||
::
|
||||
|
||||
source <YOURVIRTUALENV>/bin/activate
|
||||
(myenv) $ pip install tox
|
||||
(myenv) $ tox -e <your-python-version>-django-22
|
||||
More detailed information can be found in the documentation.
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
from django.contrib.auth.backends import ModelBackend
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.conf import settings
|
||||
|
||||
from monerorpc.authproxy import AuthServiceProxy, JSONRPCException
|
||||
from monerorpc.authproxy import JSONRPCException
|
||||
|
||||
from .models import Address
|
||||
from .utils import verify_monero_signature, verify_bitcoin_signature
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class MoneroAddressBackend(ModelBackend):
|
||||
"""Custom Monero-Cryptolock authentication backend."""
|
||||
|
|
|
@ -2,7 +2,7 @@ from django import forms
|
|||
from django.contrib.auth import authenticate
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext, gettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.conf import settings
|
||||
|
||||
from pybitid import bitid
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from django.http.request import HttpRequest
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.exceptions import ValidationError
|
||||
|
@ -9,7 +7,6 @@ from django.core.exceptions import ValidationError
|
|||
from model_utils.models import TimeStampedModel
|
||||
|
||||
from .validators import validate_monero_address, validate_bitcoin_address
|
||||
from .utils import verify_bitcoin_signature, verify_monero_signature
|
||||
|
||||
|
||||
class Address(TimeStampedModel):
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.conf.urls import url
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from .views import CryptoLockLoginView, CryptoLockSignUpView
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.auth.views import LoginView
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.views.generic import FormView
|
||||
from django.forms.utils import ErrorList
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
|
||||
from monerorpc.authproxy import JSONRPCException
|
||||
|
||||
|
|
|
@ -12,6 +12,14 @@ django\_cryptolock.migrations.0001\_initial module
|
|||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
django\_cryptolock.migrations.0002\_auto\_20200218\_1312 module
|
||||
---------------------------------------------------------------
|
||||
|
||||
.. automodule:: django_cryptolock.migrations.0002_auto_20200218_1312
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
====================
|
||||
Features and Roadmap
|
||||
====================
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Below are some of the features the package already supports:
|
||||
|
||||
* Authentication using BitId
|
||||
* Authentication using Monero-Cryptolock
|
||||
* Supports custom user models
|
||||
|
||||
Roadmap
|
||||
-------
|
||||
|
||||
* QR code generation
|
||||
* Multiple login addresses per-user
|
|
@ -14,6 +14,7 @@ Contents:
|
|||
readme
|
||||
installation
|
||||
usage
|
||||
features_roadmap
|
||||
contributing
|
||||
authors
|
||||
history
|
||||
|
|
|
@ -4,7 +4,7 @@ Installation
|
|||
|
||||
At the command line::
|
||||
|
||||
$ easy_install django-cryptolock
|
||||
$ pip install django-cryptolock
|
||||
|
||||
Or, if you have virtualenvwrapper installed::
|
||||
|
||||
|
|
|
@ -12,15 +12,52 @@ To use Django-Cryptolock in a project, add it to your `INSTALLED_APPS`:
|
|||
...
|
||||
)
|
||||
|
||||
Now you should add the auth backend you wish to use on your project. You can use one or more:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
"django_cryptolock.backends.BitcoinAddressBackend",
|
||||
"django_cryptolock.backends.MoneroAddressBackend",
|
||||
]
|
||||
|
||||
If you use Monero, currently the following extra settings are required:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
DJCL_MONERO_NETWORK = "mainnet" # mainnet, stagenet or testnet
|
||||
DJCL_MONERO_WALLET_RPC_PROTOCOL = "<http_or_https>"
|
||||
DJCL_MONERO_WALLET_RPC_HOST = "<wallet_rpc_host>:<port>"
|
||||
DJCL_MONERO_WALLET_RPC_USER = "<user>"
|
||||
DJCL_MONERO_WALLET_RPC_PASS = "<password>"
|
||||
|
||||
For Bitcoin, you only need to set the ``DJCL_BITCOIN_NETWORK``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
DJCL_BITCOIN_NETWORK = "mainnet" # mainnet or testnet
|
||||
|
||||
Add Django-Cryptolock's URL patterns:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from django_cryptolock import urls as django_cryptolock_urls
|
||||
from django.conf.urls import url
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
...
|
||||
url(r'^', include(django_cryptolock_urls)),
|
||||
url(r"^auth/", include("django_cryptolock.urls", namespace="django_cryptolock")),
|
||||
...
|
||||
]
|
||||
|
||||
This will add 2 routes :
|
||||
|
||||
* ``django_cryptolock:signup``
|
||||
* ``django_cryptolock:login``
|
||||
|
||||
For usega within you templates. For specific auth pages you can create the
|
||||
template files (``login.html`` and ``signup.html``) under a
|
||||
``django_cryptolock`` subfolder.
|
||||
|
||||
Both of these templates will have access to a ``form```containing the required
|
||||
fields for the authentication.
|
||||
|
|
Loading…
Reference in New Issue