Skip to content

Commit

Permalink
Update tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
YegorDB committed Jun 13, 2023
1 parent bee43ec commit 870be46
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions tutorial/drf/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Django REST framework middlewares tutorial

- [DRFAuthTokenMiddleware](#drfauthtokenmiddleware)
- [QueryStringDRFAuthTokenMiddleware](#querystringdrfauthtokenmiddleware)
- [DRFAuthTokenMiddlewareStack](#drfauthtokenmiddlewarestack)
- [SimpleJWTAuthTokenMiddleware](#simplejwtauthtokenmiddleware)
- [QueryStringSimpleJWTAuthTokenMiddleware](#queryStringsimplejwtauthtokenmiddleware)
- [SimpleJWTAuthTokenMiddlewareStack](#simplejwtauthtokenmiddlewarestack)


## DRFAuthTokenMiddleware
Expand Down Expand Up @@ -100,25 +104,30 @@ application = ProtocolTypeRouter({
```


## SimpleJWTAuthTokenMiddleware
## QueryStringDRFAuthTokenMiddleware

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

> SimpleJWTAuthTokenMiddleware could be used directly or behind other auth middlewares or middleware stacks.
> Like DRFAuthTokenMiddleware QueryStringDRFAuthTokenMiddleware could be used directly or behind other auth middlewares or middleware stacks.
Direct usage

## DRFAuthTokenMiddlewareStack

> Combines DRFAuthTokenMiddleware and QueryStringDRFAuthTokenMiddleware
### Usage example

```python
from channels.routing import ProtocolTypeRouter, URLRouter

from channels_auth_token_middlewares.middleware import SimpleJWTAuthTokenMiddleware
from channels_auth_token_middlewares.middleware import DRFAuthTokenMiddlewareStack


application = ProtocolTypeRouter({

"websocket": SimpleJWTAuthTokenMiddleware(
"websocket": DRFAuthTokenMiddlewareStack(
URLRouter([
# app paths
]),
Expand All @@ -127,22 +136,44 @@ application = ProtocolTypeRouter({
})
```

With AuthMiddlewareStack
Same example without stack

```python
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack

from channels_auth_token_middlewares.middleware import SimpleJWTAuthTokenMiddleware
from channels_auth_token_middlewares.middleware import DRFAuthTokenMiddleware, QueryStringDRFAuthTokenMiddleware


application = ProtocolTypeRouter({

"websocket": AuthMiddlewareStack(SimpleJWTAuthTokenMiddleware(
"websocket": DRFAuthTokenMiddleware(QueryStringDRFAuthTokenMiddleware(
URLRouter([
# app paths
]),
)),

})
```


## SimpleJWTAuthTokenMiddleware

> [Simple JWT](https://django-rest-framework-simplejwt.readthedocs.io/en/latest/index.html) middleware
### Usage example

> Like DRFAuthTokenMiddleware SimpleJWTAuthTokenMiddleware could be used directly or behind other auth middlewares or middleware stacks.

## QueryStringSimpleJWTAuthTokenMiddleware

> Simple JWT auth token middleware with query string token
### Usage example

> Like DRFAuthTokenMiddleware QueryStringSimpleJWTAuthTokenMiddleware could be used directly or behind other auth middlewares or middleware stacks.

## SimpleJWTAuthTokenMiddlewareStack

> Like DRFAuthTokenMiddlewareStack but combines SimpleJWTAuthTokenMiddleware and QueryStringSimpleJWTAuthTokenMiddleware

0 comments on commit 870be46

Please sign in to comment.