Skip to content

Commit c96995a

Browse files
Add BaseUser import from piccolo.apps.user.tables (#313)
* Add BaseUser import from piccolo.apps.user.tables Imported BaseUser from piccolo.apps.user.tables for use in authentication and JWT middleware integration. This enables the app to validate users against the default Piccolo user table when protecting routes with JWTMiddleware. * move table import to bottom --------- Co-authored-by: Daniel Townsend <[email protected]>
1 parent 18d31ba commit c96995a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/source/jwt/examples/example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
from datetime import timedelta
22

33
from fastapi import FastAPI, Request
4-
from home.tables import Movie # An example Table
54
from piccolo_admin.endpoints import create_admin
65
from piccolo_api.crud.endpoints import PiccoloCRUD
76
from piccolo_api.fastapi.endpoints import FastAPIKwargs, FastAPIWrapper
87
from piccolo_api.jwt_auth.endpoints import jwt_login
98
from piccolo_api.jwt_auth.middleware import JWTBlacklist, JWTMiddleware
9+
from piccolo.apps.user.tables import BaseUser
1010
from starlette.routing import Mount, Route
1111

12+
from home.tables import Movie # An example Table
13+
14+
1215
public_app = FastAPI(
1316
routes=[
1417
Mount(
@@ -54,6 +57,7 @@ async def in_blacklist(self, token: str) -> bool:
5457

5558
public_app.mount("/private", protected_app)
5659

60+
5761
# This is optional if you want to provide a logout endpoint
5862
# in your application. By adding a token to the token blacklist,
5963
# you are invalidating the token and need to login again to get

0 commit comments

Comments
 (0)