✨(backend) publish the JWT public key on a JWKS endpoint

The yhub service will need our public key in order to validate the jwt
token we will used. We choose to expose a jwks endpoint as it is a
standard wat to do this.
This commit is contained in:
Manuel Raynaud
2026-09-23 12:06:05 +02:00
parent 3addd04755
commit e8421824cc
10 changed files with 317 additions and 5 deletions
+24
View File
@@ -64,6 +64,10 @@ from core.services.converter_services import (
from core.services.converter_services import (
ValidationError as YProviderValidationError,
)
from core.services.jwt_services import (
ConfigurationError as JWTConfigurationError,
)
from core.services.jwt_services import JWTService
from core.services.search_indexers import (
get_document_indexer,
get_visited_document_ids_of,
@@ -3183,6 +3187,26 @@ class ConfigView(drf.views.APIView):
return theme_customization
class JWKSView(drf.views.APIView):
"""API ViewSet exposing the public key validating the tokens we issue."""
authentication_classes = []
permission_classes = [AllowAny]
def get(self, request):
"""
GET /api/v1.0/jwks
Return the JSON Web Key Set of the tokens issued by this service.
"""
try:
jwks = JWTService().get_jwks()
except JWTConfigurationError:
logger.exception("Unable to publish the JWKS")
raise drf.exceptions.NotFound("No JWKS available.") from None
return drf.response.Response(jwks)
class CommentViewSetMixin:
"""Comment ViewSet Mixin."""