From 0abd7c4ec27ec7b62473d9001a76a70d3172663f Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Tue, 5 Mar 2024 12:11:08 +0000 Subject: [PATCH] Disable authentication for certs endpoint --- keycloak_oauth/starlette_admin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/keycloak_oauth/starlette_admin.py b/keycloak_oauth/starlette_admin.py index 9737a22..46953f5 100644 --- a/keycloak_oauth/starlette_admin.py +++ b/keycloak_oauth/starlette_admin.py @@ -1,4 +1,4 @@ -from typing import Sequence +from typing import Any, Sequence from starlette.exceptions import HTTPException from starlette.requests import Request from starlette.responses import RedirectResponse @@ -50,6 +50,10 @@ async def render_logout( async def handle_auth_callback(self, request: Request) -> RedirectResponse: return await self.keycloak.auth(request) + @login_not_required + async def public_keys(self) -> dict[str, Any]: + return await self.keycloak.public_keys() + def setup_admin(self, admin: BaseAdmin) -> None: super().setup_admin(admin) """add custom authentication callback route""" @@ -64,7 +68,7 @@ def setup_admin(self, admin: BaseAdmin) -> None: admin.routes.append( Route( "/auth/certs", - self.keycloak.public_keys, + self.public_keys, methods=["GET"], ) )