Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Dec 29, 2023
1 parent dab7f3e commit 6a5929c
Show file tree
Hide file tree
Showing 24 changed files with 114 additions and 82 deletions.
6 changes: 3 additions & 3 deletions fief/apps/auth/exception_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

async def authorize_exception_handler(request: Request, exc: AuthorizeException):
return templates.TemplateResponse(
request,
"auth/authorize.html",
{
"request": request,
"error": exc.error.error_description,
"tenant": exc.tenant,
"fatal_error": True,
Expand Down Expand Up @@ -64,10 +64,10 @@ async def login_exception_handler(
form = await form_helper.get_form()

return templates.TemplateResponse(
request,
"auth/login.html",
{
"form": form,
"request": request,
"error": exc.error.error_description,
"oauth_providers": exc.oauth_providers,
"tenant": exc.tenant,
Expand All @@ -94,9 +94,9 @@ async def token_request_exception_handler(request: Request, exc: TokenRequestExc

async def logout_exception_handler(request: Request, exc: LogoutException):
return templates.TemplateResponse(
request,
"auth/logout.html",
{
"request": request,
"error": exc.error.error_description,
"tenant": exc.tenant,
"fatal_error": True,
Expand Down
6 changes: 3 additions & 3 deletions fief/apps/dashboard/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import Depends, FastAPI
from fastapi import Depends, FastAPI, Request
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.staticfiles import StaticFiles
from starlette.middleware.sessions import SessionMiddleware
Expand Down Expand Up @@ -60,8 +60,8 @@
@app.get(
"/", name="dashboard:index", dependencies=[Depends(is_authenticated_admin_session)]
)
async def index(context: BaseContext = Depends(get_base_context)):
return templates.TemplateResponse("admin/index.html", {**context})
async def index(request: Request, context: BaseContext = Depends(get_base_context)):
return templates.TemplateResponse(request, "admin/index.html", {**context})


__all__ = ["app"]
3 changes: 0 additions & 3 deletions fief/apps/dashboard/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ async def get_layout(hx_request: bool = Header(False)) -> str:


class BaseContext(TypedDict):
request: Request
layout: str
hx_target: str | None
user: FiefUserInfo
Expand All @@ -32,15 +31,13 @@ class BaseContext(TypedDict):


async def get_base_context(
request: Request,
hx_target: str | None = Header(None),
layout: str = Depends(get_layout),
userinfo: FiefUserInfo = Depends(get_userinfo),
current_workspace: Workspace = Depends(get_current_workspace),
workspaces: list[Workspace] = Depends(get_admin_user_workspaces),
) -> BaseContext:
return {
"request": request,
"layout": layout,
"hx_target": hx_target,
"user": userinfo,
Expand Down
2 changes: 1 addition & 1 deletion fief/apps/dashboard/exception_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
async def http_exception_handler(request: Request, exc: StarletteHTTPException):
headers = getattr(exc, "headers", None)
return templates.TemplateResponse(
request,
"admin/error.html",
{
"request": request,
"status_code": exc.status_code,
"detail": exc.detail,
},
Expand Down
5 changes: 4 additions & 1 deletion fief/apps/dashboard/routers/api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ async def get_list_context(

@router.get("/", name="dashboard.api_keys:list")
async def list_api_keys(
request: Request,
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(
"admin/api_keys/list.html", {**context, **list_context}
request, "admin/api_keys/list.html", {**context, **list_context}
)


Expand Down Expand Up @@ -93,6 +94,7 @@ async def create_api_key(
audit_logger.log_object_write(AuditLogMessage.OBJECT_CREATED, api_key)

return templates.TemplateResponse(
request,
"admin/api_keys/token.html",
{**context, **list_context, "api_key": api_key, "token": token},
status_code=status.HTTP_201_CREATED,
Expand Down Expand Up @@ -125,6 +127,7 @@ async def delete_api_key(
)
else:
return templates.TemplateResponse(
request,
"admin/api_keys/delete.html",
{**context, **list_context, "api_key": api_key},
)
7 changes: 4 additions & 3 deletions fief/apps/dashboard/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from fastapi import APIRouter, Depends, Query, Request, status
from fastapi.responses import RedirectResponse
from fief_client import FiefAsync

from fief.crypto.token import generate_token
from fief.dependencies.admin_authentication import is_authenticated_admin_session
from fief.dependencies.admin_session import get_admin_session_token
from fief.dependencies.fief import FiefAsyncRelativeEndpoints, get_fief
from fief.dependencies.fief import get_fief
from fief.dependencies.main_repositories import get_main_repository
from fief.models import AdminSessionToken
from fief.repositories import AdminSessionTokenRepository
Expand All @@ -19,7 +20,7 @@
async def login(
request: Request,
screen: str = Query("login"),
fief: FiefAsyncRelativeEndpoints = Depends(get_fief),
fief: FiefAsync = Depends(get_fief),
):
url = await fief.auth_url(
redirect_uri=str(request.url_for("dashboard.auth:callback")),
Expand All @@ -33,7 +34,7 @@ async def login(
async def callback(
request: Request,
code: str = Query(...),
fief: FiefAsyncRelativeEndpoints = Depends(get_fief),
fief: FiefAsync = Depends(get_fief),
repository: AdminSessionTokenRepository = Depends(
get_main_repository(AdminSessionTokenRepository)
),
Expand Down
8 changes: 7 additions & 1 deletion fief/apps/dashboard/routers/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,23 @@ async def get_list_template(hx_combobox: bool = Header(False)) -> str:

@router.get("/", name="dashboard.clients:list")
async def list_clients(
request: Request,
template: str = Depends(get_list_template),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(template, {**context, **list_context})
return templates.TemplateResponse(request, template, {**context, **list_context})


@router.get("/{id:uuid}", name="dashboard.clients:get")
async def get_client(
request: Request,
client: Client = Depends(get_client_by_id_or_404),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(
request,
"admin/clients/get/general.html",
{**context, **list_context, "client": client, "tab": "general"},
)
Expand Down Expand Up @@ -209,6 +212,7 @@ async def update_client(
name="dashboard.clients:encryption_key",
)
async def create_encryption_key(
request: Request,
client: Client = Depends(get_client_by_id_or_404),
repository: ClientRepository = Depends(get_workspace_repository(ClientRepository)),
context: BaseContext = Depends(get_base_context),
Expand All @@ -222,6 +226,7 @@ async def create_encryption_key(
trigger_webhooks(ClientUpdated, client, schemas.client.Client)

return templates.TemplateResponse(
request,
"admin/clients/encryption_key.html",
{**context, "client": client, "key": key.export(as_dict=True)},
)
Expand Down Expand Up @@ -252,6 +257,7 @@ async def delete_client(
)
else:
return templates.TemplateResponse(
request,
"admin/clients/delete.html",
{**context, **list_context, "client": client},
)
9 changes: 6 additions & 3 deletions fief/apps/dashboard/routers/email_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ async def get_list_context(

@router.get("/", name="dashboard.email_templates:list")
async def list_email_templates(
request: Request,
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(
"admin/email_templates/list.html", {**context, **list_context}
request, "admin/email_templates/list.html", {**context, **list_context}
)


Expand Down Expand Up @@ -120,10 +121,12 @@ async def update_email_template(
)
try:
subject = await email_subject_renderer.render(
EmailTemplateType[email_template_preview.type], sample_context
EmailTemplateType[email_template_preview.type],
sample_context,
) # type: ignore
content = await email_template_renderer.render(
EmailTemplateType[email_template_preview.type], sample_context
EmailTemplateType[email_template_preview.type],
sample_context,
) # type: ignore
except jinja2.exceptions.TemplateError as e:
return await form_helper.get_error_response(
Expand Down
6 changes: 5 additions & 1 deletion fief/apps/dashboard/routers/oauth_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,23 @@ async def get_list_template(hx_combobox: bool = Header(False)) -> str:

@router.get("/", name="dashboard.oauth_providers:list")
async def list_oauth_providers(
request: Request,
template: str = Depends(get_list_template),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(template, {**context, **list_context})
return templates.TemplateResponse(request, template, {**context, **list_context})


@router.get("/{id:uuid}", name="dashboard.oauth_providers:get")
async def get_oauth_provider(
request: Request,
oauth_provider: OAuthProvider = Depends(get_oauth_provider_by_id_or_404),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(
request,
"admin/oauth_providers/get.html",
{**context, **list_context, "oauth_provider": oauth_provider},
)
Expand Down Expand Up @@ -205,6 +208,7 @@ async def delete_oauth_provider(
)
else:
return templates.TemplateResponse(
request,
"admin/oauth_providers/delete.html",
{**context, **list_context, "oauth_provider": oauth_provider},
)
1 change: 1 addition & 0 deletions fief/apps/dashboard/routers/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ async def delete_permission(
)
else:
return templates.TemplateResponse(
request,
"admin/permissions/delete.html",
{**form_helper.context, "permission": permission},
)
6 changes: 5 additions & 1 deletion fief/apps/dashboard/routers/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,23 @@ async def get_list_template(hx_combobox: bool = Header(False)) -> str:

@router.get("/", name="dashboard.roles:list")
async def list_roles(
request: Request,
template: str = Depends(get_list_template),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(template, {**context, **list_context})
return templates.TemplateResponse(request, template, {**context, **list_context})


@router.get("/{id:uuid}", name="dashboard.roles:get")
async def get_role(
request: Request,
role: Role = Depends(get_role_by_id_or_404),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(
request,
"admin/roles/get.html",
{**context, **list_context, "role": role},
)
Expand Down Expand Up @@ -223,6 +226,7 @@ async def delete_role(
)
else:
return templates.TemplateResponse(
request,
"admin/roles/delete.html",
{**context, **list_context, "role": role},
)
6 changes: 5 additions & 1 deletion fief/apps/dashboard/routers/tenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,23 @@ async def get_list_template(hx_combobox: bool = Header(False)) -> str:

@router.get("/", name="dashboard.tenants:list")
async def list_tenants(
request: Request,
template: str = Depends(get_list_template),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(template, {**context, **list_context})
return templates.TemplateResponse(request, template, {**context, **list_context})


@router.get("/{id:uuid}", name="dashboard.tenants:get")
async def get_tenant(
request: Request,
tenant: Tenant = Depends(get_tenant_by_id_or_404),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(
request,
"admin/tenants/get/general.html",
{**context, **list_context, "tenant": tenant, "tab": "general"},
)
Expand Down Expand Up @@ -399,6 +402,7 @@ async def delete_tenant(
users_count = await user_repository.count_by_tenant(tenant.id)
clients_count = await client_repository.count_by_tenant(tenant.id)
return templates.TemplateResponse(
request,
"admin/tenants/delete.html",
{
**context,
Expand Down
3 changes: 2 additions & 1 deletion fief/apps/dashboard/routers/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ async def get_list_template(hx_combobox: bool = Header(False)) -> str:

@router.get("/", name="dashboard.themes:list")
async def list_themes(
request: Request,
template: str = Depends(get_list_template),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(template, {**context, **list_context})
return templates.TemplateResponse(request, template, {**context, **list_context})


@router.api_route("/create", methods=["GET", "POST"], name="dashboard.themes:create")
Expand Down
6 changes: 5 additions & 1 deletion fief/apps/dashboard/routers/user_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,24 @@ async def get_list_context(

@router.get("/", name="dashboard.user_fields:list")
async def list_user_fields(
request: Request,
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(
"admin/user_fields/list.html", {**context, **list_context}
request, "admin/user_fields/list.html", {**context, **list_context}
)


@router.get("/{id:uuid}", name="dashboard.user_fields:get")
async def get_user_field(
request: Request,
user_field: UserField = Depends(get_user_field_by_id_or_404),
list_context=Depends(get_list_context),
context: BaseContext = Depends(get_base_context),
):
return templates.TemplateResponse(
request,
"admin/user_fields/get.html",
{**context, **list_context, "user_field": user_field},
)
Expand Down Expand Up @@ -236,6 +239,7 @@ async def delete_user_field(
)
else:
return templates.TemplateResponse(
request,
"admin/user_fields/delete.html",
{**context, **list_context, "user_field": user_field},
)
Loading

0 comments on commit 6a5929c

Please sign in to comment.