Skip to content

Commit 870be46

Browse files
committed
Update tutorial
1 parent bee43ec commit 870be46

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

tutorial/drf/README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Django REST framework middlewares tutorial
22

33
- [DRFAuthTokenMiddleware](#drfauthtokenmiddleware)
4+
- [QueryStringDRFAuthTokenMiddleware](#querystringdrfauthtokenmiddleware)
5+
- [DRFAuthTokenMiddlewareStack](#drfauthtokenmiddlewarestack)
46
- [SimpleJWTAuthTokenMiddleware](#simplejwtauthtokenmiddleware)
7+
- [QueryStringSimpleJWTAuthTokenMiddleware](#queryStringsimplejwtauthtokenmiddleware)
8+
- [SimpleJWTAuthTokenMiddlewareStack](#simplejwtauthtokenmiddlewarestack)
59

610

711
## DRFAuthTokenMiddleware
@@ -100,25 +104,30 @@ application = ProtocolTypeRouter({
100104
```
101105

102106

103-
## SimpleJWTAuthTokenMiddleware
107+
## QueryStringDRFAuthTokenMiddleware
104108

105-
> [Simple JWT](https://django-rest-framework-simplejwt.readthedocs.io/en/latest/index.html) middleware
109+
> Django REST framework auth token middleware with query string token
106110
107111
### Usage example
108112

109-
> SimpleJWTAuthTokenMiddleware could be used directly or behind other auth middlewares or middleware stacks.
113+
> Like DRFAuthTokenMiddleware QueryStringDRFAuthTokenMiddleware could be used directly or behind other auth middlewares or middleware stacks.
110114
111-
Direct usage
115+
116+
## DRFAuthTokenMiddlewareStack
117+
118+
> Combines DRFAuthTokenMiddleware and QueryStringDRFAuthTokenMiddleware
119+
120+
### Usage example
112121

113122
```python
114123
from channels.routing import ProtocolTypeRouter, URLRouter
115124

116-
from channels_auth_token_middlewares.middleware import SimpleJWTAuthTokenMiddleware
125+
from channels_auth_token_middlewares.middleware import DRFAuthTokenMiddlewareStack
117126

118127

119128
application = ProtocolTypeRouter({
120129

121-
"websocket": SimpleJWTAuthTokenMiddleware(
130+
"websocket": DRFAuthTokenMiddlewareStack(
122131
URLRouter([
123132
# app paths
124133
]),
@@ -127,22 +136,44 @@ application = ProtocolTypeRouter({
127136
})
128137
```
129138

130-
With AuthMiddlewareStack
139+
Same example without stack
131140

132141
```python
133142
from channels.routing import ProtocolTypeRouter, URLRouter
134-
from channels.auth import AuthMiddlewareStack
135143

136-
from channels_auth_token_middlewares.middleware import SimpleJWTAuthTokenMiddleware
144+
from channels_auth_token_middlewares.middleware import DRFAuthTokenMiddleware, QueryStringDRFAuthTokenMiddleware
137145

138146

139147
application = ProtocolTypeRouter({
140148

141-
"websocket": AuthMiddlewareStack(SimpleJWTAuthTokenMiddleware(
149+
"websocket": DRFAuthTokenMiddleware(QueryStringDRFAuthTokenMiddleware(
142150
URLRouter([
143151
# app paths
144152
]),
145153
)),
146154

147155
})
148156
```
157+
158+
159+
## SimpleJWTAuthTokenMiddleware
160+
161+
> [Simple JWT](https://django-rest-framework-simplejwt.readthedocs.io/en/latest/index.html) middleware
162+
163+
### Usage example
164+
165+
> Like DRFAuthTokenMiddleware SimpleJWTAuthTokenMiddleware could be used directly or behind other auth middlewares or middleware stacks.
166+
167+
168+
## QueryStringSimpleJWTAuthTokenMiddleware
169+
170+
> Simple JWT auth token middleware with query string token
171+
172+
### Usage example
173+
174+
> Like DRFAuthTokenMiddleware QueryStringSimpleJWTAuthTokenMiddleware could be used directly or behind other auth middlewares or middleware stacks.
175+
176+
177+
## SimpleJWTAuthTokenMiddlewareStack
178+
179+
> Like DRFAuthTokenMiddlewareStack but combines SimpleJWTAuthTokenMiddleware and QueryStringSimpleJWTAuthTokenMiddleware

0 commit comments

Comments
 (0)