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
This is a [Jazzband](https://jazzband.co/) project. By contributing you agree to abide by the [Contributor Code of Conduct](https://jazzband.co/about/conduct) and follow the [guidelines](https://jazzband.co/about/guidelines).
Copy file name to clipboardexpand all lines: docs/auth.md
+8-10
Original file line number
Diff line number
Diff line change
@@ -49,18 +49,17 @@ If it is your only default authentication class, remember to overwrite knox's Lo
49
49
50
50
For instance, you can authenticate users using Basic Authentication by simply overwriting knox's LoginView and setting BasicAuthentication as one of the acceptable authentication classes, as follows:
51
51
52
+
**views.py:**
52
53
```python
53
-
54
-
views.py:
55
-
56
54
from knox.views import LoginView as KnoxLoginView
57
55
from rest_framework.authentication import BasicAuthentication
58
56
59
57
classLoginView(KnoxLoginView):
60
58
authentication_classes = [BasicAuthentication]
59
+
```
61
60
62
-
urls.py:
63
-
61
+
**urls.py:**
62
+
```python
64
63
from knox import views as knox_views
65
64
from yourapp.api.views import LoginView
66
65
@@ -75,10 +74,8 @@ You can use any number of authentication classes if you want to be able to authe
75
74
76
75
If you decide to use Token Authentication as your only authentication class, you can overwrite knox's login view as such:
77
76
77
+
**views.py:**
78
78
```python
79
-
80
-
views.py:
81
-
82
79
from django.contrib.auth import login
83
80
84
81
from rest_framework import permissions
@@ -94,9 +91,10 @@ class LoginView(KnoxLoginView):
For other systems or problems, see the [cryptography installation docs](https://cryptography.io/en/latest/installation/)
5
+
Knox depends on pythons internal library `hashlib` to provide bindings to `OpenSSL` or uses
6
+
an internal implementation of hashing algorithms for token generation.
26
7
27
8
## Installing Knox
28
9
Knox should be installed with pip
@@ -59,7 +40,7 @@ REST_FRAMEWORK = {
59
40
60
41
- If you set TokenAuthentication as the only default authentication class on the second step, [override knox's LoginView](auth.md#global-usage-on-all-views) to accept another authentication method and use it instead of knox's default login view.
0 commit comments