You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
django-scatter-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.
14
+
django-scatter-auth is a pluggable Django app that enables login/signup via Scatter (EOS extension wallet). The user authenticates themselves by digitally signing the hostname with their wallet's private key.
Copy file name to clipboardExpand all lines: docs/overview.rst
+13-15
Original file line number
Diff line number
Diff line change
@@ -2,29 +2,30 @@
2
2
Overview
3
3
========
4
4
5
-
Django-web3-auth features 1 view for login (with JSON responses)
5
+
Django-scatter-auth features 1 view for login (with JSON responses)
6
6
and 2 views for Signup (one with JSON responses, and the other - using Django Forms and rendered templates).
7
7
8
8
It also has 2 forms, SignupForm (rendered) and LoginForm (uses hidden inputs, used to validate data only).
9
9
10
-
Possible configuration includes customizable address field (``SCATTERAUTH_USER_PUBKEY_FIELD``), additional fields for User model (``SCATTERAUTH_USER_SIGNUP_FIELDS``) and on/off switch for registration (``SCATTERAUTH_SIGNUP_ENABLED``).
11
-
You can read more on that in the Configuration section.
10
+
Possible configuration includes customizable address field (``SCATTERAUTH_USER_PUBKEY_FIELD``), additional fields for User model (``SCATTERAUTH_USER_SIGNUP_FIELDS``),on/off switch for registration (``SCATTERAUTH_SIGNUP_ENABLED``) and domain which will be used for signed message validation (``SCATTERAUTH_DOMAIN``).
11
+
You can read more on that in the Settings section.
12
+
You should also definitely check example app, it features most of the features needed.
12
13
13
14
Sign up
14
15
-------
15
16
16
17
The signup process is as follows (signup_view example, signup_api is similar):
17
18
18
-
1. User heads to the signup URL (``{% url 'web3auth_signup' %}``)
19
+
1. User heads to the signup URL (``{% url 'scatterauth_signup' %}``)
19
20
2. The signup view is rendered with a ``SignupForm`` which includes ``SCATTERAUTH_USER_SIGNUP_FIELDS`` and ``SCATTERAUTH_USER_PUBKEY_FIELD``
20
21
3. The user enters required data and clicks the submit button and the POST request fires to the same URL with ``signup_view``
21
22
4. Signup view does the following:
22
23
4.1. Creates an instance of a ``SignupForm``.
23
24
4.2. Checks if the registration is enabled.
24
25
4.3. If the registration is closed or form has errors, returns form with errors
25
26
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.ScatterAuthBackend``
27
+
4.5. Sets the user public key from the form, saves it to DB
28
+
4.6. Logins the user using ``scatterauth.backend.ScatterAuthBackend``
28
29
4.7. Redirects the user to ``LOGIN_REDIRECT_URL`` or 'next' in get or post params
29
30
5. The user is signed up and logged in
30
31
@@ -33,14 +34,11 @@ Login
33
34
34
35
The login process is as follows (login_api example):
35
36
36
-
1. On some page of the website, there is Javascript which fires a GET request to the ``{% url '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
-
37
+
1. On some page of the website, there is Javascript which gets the user signature for the website's hostname.
38
+
2. The signature is sent to the login_api url (``{% url 'scatterauth_login_api' %}``) alongside the public key.
39
+
3. The view validates given parameters agains ``LoginForm``
40
+
4. The view validates signature with the given public key, and then tries to ``authenticate`` the user
41
+
5. If the user is found, the user is signed in and the view responds with a ``redirect_url`` for Javascript to handle
42
+
6. If the user is not found, the corresponding error is returned
45
43
46
44
The Javascript is included in the app, also you can check out example app if you are struggling with logging in the user.
0 commit comments