Browse Source

Update the docs to align with other formatting

pull/13434/head
Dale 1 month ago
parent
commit
43df95fd57
  1. 16
      docs/en/docs/advanced/security/api-key.md
  2. BIN
      docs/en/docs/img/tutorial/security/image13.png
  3. 1
      docs/en/mkdocs.yml

16
docs/en/docs/advanced/security/api-key.md

@ -15,9 +15,7 @@ We'll protect the entire API under a Key (rather than single endpoints).
* Create a `get_api_key` function to check the key * Create a `get_api_key` function to check the key
* Create a `security` from the `get_api_key` function, used as a dependency in your FastAPI `app`. * Create a `security` from the `get_api_key` function, used as a dependency in your FastAPI `app`.
```Python hl_lines="5 7 14 23" {* ../../docs_src/security/tutorial008.py hl=[5,7,14,23] *}
{!../../../docs_src/security/tutorial008.py!}
```
This API now requires authentication to hit any endpoint: This API now requires authentication to hit any endpoint:
@ -36,9 +34,7 @@ description ends up on the documentation for the authentication: the description
is a perfect place to link to your developer documentation's "Generate a token" is a perfect place to link to your developer documentation's "Generate a token"
section. section.
```Python hl_lines="8 9" {* ../../docs_src/security/tutorial008.py hl=[8:9] *}
{!../../../docs_src/security/tutorial008.py!}
```
As for the `auto_error` parameter, it can be set to `True` so that missing the As for the `auto_error` parameter, it can be set to `True` so that missing the
header returns automatic HTTP 403 "Forbidden". header returns automatic HTTP 403 "Forbidden".
@ -59,9 +55,7 @@ For convenience, API Keys can be pushed in cookies instead.
<!-- Note: tutorial009.py is 100 %CLONED from tests/test_security_api_key_cookie.py --> <!-- Note: tutorial009.py is 100 %CLONED from tests/test_security_api_key_cookie.py -->
```Python hl_lines="2 7 14" {* ../../docs_src/security/tutorial009.py hl=[2,7,14] *}
{!../../../docs_src/security/tutorial009.py!}
```
Users can call this via: Users can call this via:
@ -74,9 +68,7 @@ response = client.get("/users/me", cookies={"key": "secret"})
To round up the multiple ways to use API Keys, one can set the API key as query parameter. To round up the multiple ways to use API Keys, one can set the API key as query parameter.
<!-- Note: tutorial010.py is 100 %CLONED from tests/test_security_api_key_query.py --> <!-- Note: tutorial010.py is 100 %CLONED from tests/test_security_api_key_query.py -->
```Python hl_lines="2 7 14" {* ../../docs_src/security/tutorial010.py hl=[2,7,14] *}
{!../../../docs_src/security/tutorial010.py!}
```
Users can call this via: Users can call this via:

BIN
docs/en/docs/img/tutorial/security/image13.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

1
docs/en/mkdocs.yml

@ -179,6 +179,7 @@ nav:
- advanced/security/index.md - advanced/security/index.md
- advanced/security/oauth2-scopes.md - advanced/security/oauth2-scopes.md
- advanced/security/http-basic-auth.md - advanced/security/http-basic-auth.md
- advanced/security/api-key.md
- advanced/using-request-directly.md - advanced/using-request-directly.md
- advanced/dataclasses.md - advanced/dataclasses.md
- advanced/middleware.md - advanced/middleware.md

Loading…
Cancel
Save