mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
Merge branch 'master' into native-model
This commit is contained in:
44
.github/workflows/documentation.yml
vendored
44
.github/workflows/documentation.yml
vendored
@@ -2,30 +2,36 @@ name: Update documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Set up Python 3.7
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flit
|
||||
flit install --deps develop --extras oauth,redis
|
||||
- name: Build
|
||||
run: mkdocs build
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v2.5.0
|
||||
env:
|
||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||
PUBLISH_BRANCH: gh-pages
|
||||
PUBLISH_DIR: ./site
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python 3.7
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flit
|
||||
flit install --deps develop --extras oauth,redis
|
||||
- name: Build
|
||||
run: mkdocs build
|
||||
- name: Parse tag
|
||||
id: version_tag
|
||||
uses: battila7/get-version-action@v2
|
||||
- name: Deploy
|
||||
env:
|
||||
DOC_TAG: ${{ steps.version_tag.outputs.major && steps.version_tag.outputs.minor && format('{0}.{1} latest', steps.version_tag.outputs.major, steps.version_tag.outputs.minor) || 'dev' }}
|
||||
run: |
|
||||
git config user.name fastapi-users-ci
|
||||
git config user.email fastapi-users-ci@francoisvoron.com
|
||||
git fetch origin gh-pages --depth=1
|
||||
mike deploy --push --update-aliases ${{ env.DOC_TAG }}
|
||||
|
||||
8
docs-overrides/main.html
Normal file
8
docs-overrides/main.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block outdated %}
|
||||
You're not viewing the latest version.
|
||||
<a href="{{ '../' ~ base_url }}">
|
||||
<strong>Click here to go to latest.</strong>
|
||||
</a>
|
||||
{% endblock %}
|
||||
@@ -37,12 +37,12 @@ It is structured like this:
|
||||
|
||||
With Tortoise ORM, you need to define a proper Tortoise model for `AccessToken` and manually specify the user foreign key. Besides, you need to modify the Pydantic model a bit so that it works well with this Tortoise model.
|
||||
|
||||
=== ":octicons-file-code-16: model.py"
|
||||
=== "model.py"
|
||||
```py hl_lines="2 4 31-38"
|
||||
--8<-- "docs/src/db_tortoise_access_tokens_model.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: adapter.py"
|
||||
=== "adapter.py"
|
||||
```py hl_lines="2 4 13-14"
|
||||
--8<-- "docs/src/db_tortoise_access_tokens_adapter.py"
|
||||
```
|
||||
|
||||
@@ -8,39 +8,39 @@ Here is a full working example with JWT authentication to help get you started.
|
||||
|
||||
## SQLAlchemy
|
||||
|
||||
[Open :octicons-link-external-16:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/sqlalchemy)
|
||||
[Open :material-open-in-new:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/sqlalchemy)
|
||||
|
||||
=== ":octicons-file-code-16: requirements.txt"
|
||||
=== "requirements.txt"
|
||||
|
||||
```
|
||||
--8<-- "examples/sqlalchemy/requirements.txt"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: main.py"
|
||||
=== "main.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy/main.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/app.py"
|
||||
=== "app/app.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy/app/app.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/db.py"
|
||||
=== "app/db.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy/app/db.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/models.py"
|
||||
=== "app/models.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy/app/models.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/users.py"
|
||||
=== "app/users.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy/app/users.py"
|
||||
@@ -48,39 +48,39 @@ Here is a full working example with JWT authentication to help get you started.
|
||||
|
||||
## MongoDB
|
||||
|
||||
[Open :octicons-link-external-16:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/mongodb)
|
||||
[Open :material-open-in-new:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/mongodb)
|
||||
|
||||
=== ":octicons-file-code-16: requirements.txt"
|
||||
=== "requirements.txt"
|
||||
|
||||
```
|
||||
--8<-- "examples/mongodb/requirements.txt"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: main.py"
|
||||
=== "main.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb/main.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/app.py"
|
||||
=== "app/app.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb/app/app.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/db.py"
|
||||
=== "app/db.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb/app/db.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/models.py"
|
||||
=== "app/models.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb/app/models.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/users.py"
|
||||
=== "app/users.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb/app/users.py"
|
||||
@@ -88,39 +88,39 @@ Here is a full working example with JWT authentication to help get you started.
|
||||
|
||||
## Tortoise ORM
|
||||
|
||||
[Open :octicons-link-external-16:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/tortoise)
|
||||
[Open :material-open-in-new:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/tortoise)
|
||||
|
||||
=== ":octicons-file-code-16: requirements.txt"
|
||||
=== "requirements.txt"
|
||||
|
||||
```
|
||||
--8<-- "examples/tortoise/requirements.txt"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: main.py"
|
||||
=== "main.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise/main.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/app.py"
|
||||
=== "app/app.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise/app/app.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/db.py"
|
||||
=== "app/db.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise/app/db.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/models.py"
|
||||
=== "app/models.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise/app/models.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/users.py"
|
||||
=== "app/users.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise/app/users.py"
|
||||
|
||||
@@ -123,39 +123,39 @@ app.include_router(
|
||||
|
||||
#### SQLAlchemy
|
||||
|
||||
[Open :octicons-link-external-16:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/sqlalchemy-oauth)
|
||||
[Open :material-open-in-new:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/sqlalchemy-oauth)
|
||||
|
||||
=== ":octicons-file-code-16: requirements.txt"
|
||||
=== "requirements.txt"
|
||||
|
||||
```
|
||||
--8<-- "examples/sqlalchemy-oauth/requirements.txt"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: main.py"
|
||||
=== "main.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy-oauth/main.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/app.py"
|
||||
=== "app/app.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy-oauth/app/app.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/db.py"
|
||||
=== "app/db.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy-oauth/app/db.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/models.py"
|
||||
=== "app/models.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy-oauth/app/models.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/users.py"
|
||||
=== "app/users.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/sqlalchemy-oauth/app/users.py"
|
||||
@@ -163,39 +163,39 @@ app.include_router(
|
||||
|
||||
#### MongoDB
|
||||
|
||||
[Open :octicons-link-external-16:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/mongodb-oauth)
|
||||
[Open :material-open-in-new:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/mongodb-oauth)
|
||||
|
||||
=== ":octicons-file-code-16: requirements.txt"
|
||||
=== "requirements.txt"
|
||||
|
||||
```
|
||||
--8<-- "examples/mongodb-oauth/requirements.txt"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: main.py"
|
||||
=== "main.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb-oauth/main.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/app.py"
|
||||
=== "app/app.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb-oauth/app/app.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/db.py"
|
||||
=== "app/db.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb-oauth/app/db.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/models.py"
|
||||
=== "app/models.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb-oauth/app/models.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/users.py"
|
||||
=== "app/users.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/mongodb-oauth/app/users.py"
|
||||
@@ -203,39 +203,39 @@ app.include_router(
|
||||
|
||||
#### Tortoise ORM
|
||||
|
||||
[Open :octicons-link-external-16:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/tortoise-oauth)
|
||||
[Open :material-open-in-new:](https://github.com/fastapi-users/fastapi-users/tree/master/examples/tortoise-oauth)
|
||||
|
||||
=== ":octicons-file-code-16: requirements.txt"
|
||||
=== "requirements.txt"
|
||||
|
||||
```
|
||||
--8<-- "examples/tortoise-oauth/requirements.txt"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: main.py"
|
||||
=== "main.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise-oauth/main.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/app.py"
|
||||
=== "app/app.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise-oauth/app/app.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/db.py"
|
||||
=== "app/db.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise-oauth/app/db.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/models.py"
|
||||
=== "app/models.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise-oauth/app/models.py"
|
||||
```
|
||||
|
||||
=== ":octicons-file-code-16: app/users.py"
|
||||
=== "app/users.py"
|
||||
|
||||
```py
|
||||
--8<-- "examples/tortoise-oauth/app/users.py"
|
||||
|
||||
38
mkdocs.yml
38
mkdocs.yml
@@ -3,22 +3,31 @@ site_description: Ready-to-use and customizable users management for FastAPI
|
||||
|
||||
theme:
|
||||
name: 'material'
|
||||
custom_dir: docs-overrides
|
||||
palette:
|
||||
- scheme: default
|
||||
primary: 'red'
|
||||
accent: 'red'
|
||||
toggle:
|
||||
icon: material/lightbulb
|
||||
icon: material/weather-sunny
|
||||
name: Switch to dark mode
|
||||
- scheme: slate
|
||||
primary: 'red'
|
||||
accent: 'red'
|
||||
toggle:
|
||||
icon: material/lightbulb-outline
|
||||
icon: material/weather-night
|
||||
name: Switch to light mode
|
||||
icon:
|
||||
logo: material/account-supervisor
|
||||
favicon: 'favicon.png'
|
||||
features:
|
||||
- navigation.instant
|
||||
- navigation.top
|
||||
- navigation.sections
|
||||
- navigation.indexes
|
||||
- search.suggest
|
||||
- search.highlight
|
||||
- content.code.annotate
|
||||
|
||||
repo_name: frankie567/fastapi-users
|
||||
repo_url: https://github.com/fastapi-users/fastapi-users
|
||||
@@ -28,29 +37,34 @@ markdown_extensions:
|
||||
- toc:
|
||||
permalink: true
|
||||
- admonition
|
||||
- codehilite
|
||||
- pymdownx.details
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.snippets
|
||||
- pymdownx.superfences:
|
||||
custom_fences:
|
||||
- name: mermaid
|
||||
class: mermaid
|
||||
format: !!python/name:mermaid2.fence_mermaid
|
||||
- pymdownx.tasklist
|
||||
format: !!python/name:pymdownx.superfences.fence_code_format
|
||||
- pymdownx.tasklist:
|
||||
custom_checkbox: true
|
||||
- pymdownx.tabbed:
|
||||
alternate_style: true
|
||||
- pymdownx.snippets
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||
- attr_list
|
||||
- tables
|
||||
- def_list
|
||||
|
||||
plugins:
|
||||
- search
|
||||
- mermaid2:
|
||||
arguments:
|
||||
theme: |
|
||||
^(JSON.parse(window.localStorage.getItem('/.__palette')).index == 1) ? 'dark' : 'light'
|
||||
- mike
|
||||
|
||||
extra_javascript:
|
||||
- https://unpkg.com/mermaid/dist/mermaid.min.js
|
||||
extra:
|
||||
version:
|
||||
provider: mike
|
||||
|
||||
nav:
|
||||
- About: index.md
|
||||
|
||||
@@ -86,6 +86,7 @@ dev = [
|
||||
"isort",
|
||||
"pytest-asyncio",
|
||||
"flake8-docstrings",
|
||||
"mike",
|
||||
"mkdocs",
|
||||
"mkdocs-material",
|
||||
"mkdocs-mermaid2-plugin",
|
||||
|
||||
Reference in New Issue
Block a user