Skip to content

Commit b6df6c0

Browse files
committed
transport and strategy readme
1 parent da087bd commit b6df6c0

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ docker compose up
9797
## Users
9898

9999
В данном шаблоне реализован CRUD для пользователя с помощью библиотеки
100-
fastapi-users
100+
[fastapi-users]<https://fastapi-users.github.io/fastapi-users/latest/>
101101

102102
### End-points
103103

@@ -142,6 +142,50 @@ fastapi-users
142142
В данный момент отправка осуществляется через `консоль`.
143143
Для деталей смотрите миксин `api_v1/users/mixins/ActionUserManagerMixin`
144144

145+
### Transport
146+
147+
В fastapi-users есть 2 вида транспорта:
148+
149+
- [Bearer]<https://fastapi-users.github.io/fastapi-users/latest/configuration/authentication/transports/bearer/>
150+
- [Cookie]<https://fastapi-users.github.io/fastapi-users/latest/configuration/authentication/transports/cookie/>
151+
152+
В шаблоне реализован Bearer способ:
153+
154+
```python
155+
from fastapi_users.authentication import BearerTransport
156+
157+
from config import settings
158+
159+
160+
bearer_transport = BearerTransport(settings.CURRENT_ORIGIN +
161+
settings.API_PREFIX +
162+
settings.JWT.JWT_PATH +
163+
'/login')
164+
```
165+
166+
### Strategy
167+
168+
В fastapi-users есть 3 вида стратегии:
169+
170+
- [Database]<https://fastapi-users.github.io/fastapi-users/latest/configuration/authentication/strategies/database/>
171+
- [JWT]<https://fastapi-users.github.io/fastapi-users/latest/configuration/authentication/strategies/jwt/>
172+
- [Redis]<https://fastapi-users.github.io/fastapi-users/latest/configuration/authentication/strategies/redis/>
173+
174+
В Шаблоне реализован JWT способ:
175+
176+
```python
177+
from fastapi_users.authentication import JWTStrategy
178+
179+
from config import settings
180+
181+
182+
def get_jwt_strategy() -> JWTStrategy:
183+
return JWTStrategy(
184+
secret=settings.JWT.SECRET,
185+
lifetime_seconds=settings.JWT.RESET_LIFESPAN_TOKEN_SECONDS,
186+
)
187+
```
188+
145189
## Найболее используемые
146190

147191
Найболее используемые конструкции с которыми приходится часто взаимодействовать.

0 commit comments

Comments
 (0)