feat: add diagnostic view and update URL routing for build probe in provider and relying party
This commit is contained in:
@@ -19,7 +19,7 @@ from django.contrib import admin
|
||||
from django.views.static import serve
|
||||
from django.urls import include, path, re_path
|
||||
|
||||
from scripts.build_probe import build_probe_view
|
||||
from scripts.build_probe import build_probe_view, diag_view
|
||||
from spid_cie_oidc.entity.urls import urlpatterns as entity_urlpatterns
|
||||
|
||||
admin.site.site_header = "OIDC Federation Provider Administration"
|
||||
@@ -31,6 +31,7 @@ ADMIN_PATH = getattr(settings, 'ADMIN_PATH', 'admin/')
|
||||
urlpatterns = [
|
||||
path(f"{ADMIN_PATH}", admin.site.urls),
|
||||
path("__build", lambda request: build_probe_view("provider"), name="build_probe"),
|
||||
path("__diag", lambda request: diag_view("provider"), name="diag_probe"),
|
||||
re_path('^static/(?P<path>.*)$',
|
||||
serve, {
|
||||
'document_root': settings.STATIC_ROOT,
|
||||
|
||||
@@ -18,7 +18,7 @@ from django.contrib import admin
|
||||
from django.urls import include, path, re_path
|
||||
from django.views.static import serve
|
||||
|
||||
from scripts.build_probe import build_probe_view
|
||||
from scripts.build_probe import build_probe_view, diag_view
|
||||
from spid_cie_oidc.entity.urls import urlpatterns as ta_urlpatterns
|
||||
from .visione_views import VisioneCompleteView, VisioneStartView
|
||||
|
||||
@@ -31,6 +31,7 @@ ADMIN_PATH = getattr(settings, 'ADMIN_PATH', 'admin/')
|
||||
urlpatterns = [
|
||||
path(f"{ADMIN_PATH}", admin.site.urls),
|
||||
path("__build", lambda request: build_probe_view("relying-party"), name="build_probe"),
|
||||
path("__diag", lambda request: diag_view("relying-party"), name="diag_probe"),
|
||||
path("visione/start", VisioneStartView.as_view(), name="visione_start"),
|
||||
path("visione/complete", VisioneCompleteView.as_view(), name="visione_complete"),
|
||||
re_path('^static/(?P<path>.*)$',
|
||||
|
||||
@@ -3,6 +3,7 @@ import os
|
||||
from pathlib import Path
|
||||
|
||||
from django.http import JsonResponse
|
||||
from spid_cie_oidc.entity.models import FederationEntityConfiguration, TrustChain, FetchedEntityStatement
|
||||
|
||||
|
||||
def build_probe_view(service: str):
|
||||
@@ -32,3 +33,25 @@ def build_probe_view(service: str):
|
||||
"hostname": os.getenv("HOSTNAME", ""),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def diag_view(service: str):
|
||||
configs = FederationEntityConfiguration.objects.all()
|
||||
active = FederationEntityConfiguration.objects.filter(is_active=True)
|
||||
first = configs.order_by("id").first()
|
||||
first_active = active.order_by("id").first()
|
||||
|
||||
return JsonResponse(
|
||||
{
|
||||
"ok": True,
|
||||
"service": service,
|
||||
"config_count": configs.count(),
|
||||
"active_config_count": active.count(),
|
||||
"first_sub": getattr(first, "sub", None),
|
||||
"first_entity_type": getattr(first, "entity_type", None),
|
||||
"first_active_sub": getattr(first_active, "sub", None),
|
||||
"first_active_entity_type": getattr(first_active, "entity_type", None),
|
||||
"trust_chain_count": TrustChain.objects.count(),
|
||||
"fetched_statement_count": FetchedEntityStatement.objects.count(),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user