Try to ensure a fresh token on request
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c45ee1647c
commit
777bd824a5
@ -7,6 +7,13 @@ from fastapi import Depends, Request
|
|||||||
from humanize import naturaldelta
|
from humanize import naturaldelta
|
||||||
|
|
||||||
|
|
||||||
|
async def fresh_token(request: Request):
|
||||||
|
"""Ensure fresh credentials for speaking to Keycloak."""
|
||||||
|
from keycloak_collective_portal.keycloak import init_keycloak
|
||||||
|
|
||||||
|
request.app.state.keycloak = init_keycloak()
|
||||||
|
|
||||||
|
|
||||||
async def logged_in(request: Request):
|
async def logged_in(request: Request):
|
||||||
"""Ensure the user is logged in."""
|
"""Ensure the user is logged in."""
|
||||||
from keycloak_collective_portal.exceptions import RequiresLoginException
|
from keycloak_collective_portal.exceptions import RequiresLoginException
|
||||||
|
@ -6,7 +6,7 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from fastapi import APIRouter, Depends, Form, Request
|
from fastapi import APIRouter, Depends, Form, Request
|
||||||
|
|
||||||
from keycloak_collective_portal.dependencies import get_invites
|
from keycloak_collective_portal.dependencies import fresh_token, get_invites
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ async def register_invite(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/form/keycloak/register")
|
@router.post("/form/keycloak/register", dependencies=[Depends(fresh_token)])
|
||||||
def form_keycloak_register(
|
def form_keycloak_register(
|
||||||
request: Request,
|
request: Request,
|
||||||
first_name: str = Form(...),
|
first_name: str = Form(...),
|
||||||
|
Loading…
Reference in New Issue
Block a user