Skip to content

Commit

Permalink
Document SessionMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Feb 27, 2024
1 parent c6fe00b commit c31e8c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pip install keycloak-oauth[fastapi]
```python
from fastapi import FastAPI
from starlette.middleware.sessions import SessionMiddleware
from backend.settings import settings, BASE_URL # secrets
from backend.settings import settings, BASE_URL, SECRET_KEY # secrets
from keycloak.oauth import KeycloakOAuth2

keycloak = KeycloakOAuth2(
Expand All @@ -27,7 +27,7 @@ keycloak = KeycloakOAuth2(
keycloak.setup_fastapi_routes()

app = FastAPI()
app.add_middleware(SessionMiddleware, secret_key=settings.secret_key)
app.add_middleware(SessionMiddleware, secret_key=SECRET_KEY)
app.include_router(keycloak.router, prefix="/auth")
```

Expand All @@ -44,6 +44,7 @@ pip install keycloak-oauth[starlette-admin]
```

```python
from starlette.middleware.sessions import SessionMiddleware
from starlette_admin.contrib.sqla import Admin
from backend.settings import settings, BASE_URL # secrets
from keycloak.oauth import KeycloakOAuth2
Expand All @@ -62,6 +63,7 @@ admin = Admin(
title=...,
base_url=BASE_URL,
auth_provider=KeycloakAuthProvider(keycloak),
middlewares=[Middleware(SessionMiddleware, secret_key=SECRET_KEY)],
)
```

Expand Down

0 comments on commit c31e8c5

Please sign in to comment.