Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
YegorDB committed Jun 13, 2023
1 parent 926b48e commit bee43ec
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 7 deletions.
13 changes: 10 additions & 3 deletions docs/base/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Base middlewares


## BaseAuthTokenMiddleware(inner, token_regex=None)
## BaseAuthTokenMiddleware(inner, token_regex=r".*")
> Base auth token middleware class.
> Could be used behind other auth middlewares like channels.auth.AuthMiddleware.
Expand Down Expand Up @@ -57,6 +57,13 @@
- token_key - token key as string


### async BaseAuthTokenMiddleware.get_scope_header_value(scope, header_name)
> Returns scope header value by name or None
- scope - channels.auth.AuthMiddleware scope
- header_name - header name as a string or bytes


## HeaderAuthTokenMiddleware(inner, token_regex=r".*", header_name=None, keyword=None)
> Base middleware which parses auth token key from request header.
Expand Down Expand Up @@ -90,7 +97,7 @@
- token_key - token key as string


## CookieAuthTokenMiddleware(inner, token_regex=None, cookie_name=None)
## CookieAuthTokenMiddleware(inner, token_regex=r".*", cookie_name=None)
> Base middleware which parses token key from request cookie.
> Subclass of BaseAuthTokenMiddleware.
Expand All @@ -116,7 +123,7 @@
- token_key - token key as string


## QueryStringAuthTokenMiddleware(inner, token_regex=None, query_param=None)
## QueryStringAuthTokenMiddleware(inner, token_regex=r".*", query_param=None)
> Base middleware which parses token key from request query string.
> Subclass of BaseAuthTokenMiddleware.
Expand Down
60 changes: 56 additions & 4 deletions docs/drf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


## DRFAuthTokenMiddleware(inner, token_regex=r"[0-9a-f]{40}", header_name="Authorization", keyword="Token")
> Django REST framework [token authentication](https://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication) middleware class.
> Django REST framework [token authentication](https://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication) auth token middleware class.
> Subclass of HeaderAuthTokenMiddleware.
Expand All @@ -17,11 +17,37 @@
> Returns user instance or None.
- token_key - token key as string
- token_key - token key as a string


## QueryStringDRFAuthTokenMiddleware(inner, token_regex=r".*", query_param="token")
> Django REST framework auth token middleware class with query string token.
> Subclass of QueryStringAuthTokenMiddleware.
- inner - ASGI application (like channels.auth.AuthMiddleware inner argument)
- token_regex - token key validation regex, by default r".*"
- query_param - name of a query param to get token key string from, by default "token"


### async QueryStringDRFAuthTokenMiddleware.get_user_instance(token_key)
> Get user instance by token key.
> Returns user instance or None.
- token_key - token key as a string


## DRFAuthTokenMiddlewareStack(inner)
> Django REST framework auth token middleware stack factory function.
> Includes DRFAuthTokenMiddleware and QueryStringDRFAuthTokenMiddleware.
- inner - ASGI application (like channels.auth.AuthMiddleware inner argument)


## SimpleJWTAuthTokenMiddleware(inner, token_regex=r".*", header_name="Authorization", keyword="Bearer")
> [Simple JWT](https://django-rest-framework-simplejwt.readthedocs.io/en/latest/index.html) middleware class.
> [Simple JWT](https://django-rest-framework-simplejwt.readthedocs.io/en/latest/index.html) auth token middleware class.
> Subclass of HeaderAuthTokenMiddleware.
Expand All @@ -36,4 +62,30 @@
> Returns user instance or None.
- token_key - token key as string
- token_key - token key as a string


## QueryStringSimpleJWTAuthTokenMiddleware(inner, token_regex=r".*", query_param="token")
> Simple JWT auth token middleware class with query string token.
> Subclass of QueryStringAuthTokenMiddleware.
- inner - ASGI application (like channels.auth.AuthMiddleware inner argument)
- token_regex - token key validation regex, by default any string (r".*")
- query_param - name of a query param to get token key string from, by default "token"


### async QueryStringSimpleJWTAuthTokenMiddleware.get_user_instance(token_key)
> Get user instance by token key.
> Returns user instance or None.
- token_key - token key as a string


## SimpleJWTAuthTokenMiddlewareStack(inner)
> Simple JWT auth token middleware stack factory function.
> Includes SimpleJWTAuthTokenMiddleware and QueryStringSimpleJWTAuthTokenMiddleware.
- inner - ASGI application (like channels.auth.AuthMiddleware inner argument)

0 comments on commit bee43ec

Please sign in to comment.