diff --git a/litellm/proxy/common_utils/html_forms/jwt_display_template.py b/litellm/proxy/common_utils/html_forms/jwt_display_template.py new file mode 100644 index 00000000000..03dff78dba0 --- /dev/null +++ b/litellm/proxy/common_utils/html_forms/jwt_display_template.py @@ -0,0 +1,284 @@ +# JWT display template for SSO debug callback +jwt_display_template = """ + + +
+ +Results from the SSO authentication process.
+ +The SSO authentication completed successfully. Below is the information returned by the provider.
+Loading...+
No data was returned from the SSO provider.
", + status_code=400, + ) + + # Convert the OpenID object to a dictionary + if hasattr(result, "__dict__"): + result_dict = result.__dict__ + else: + result_dict = dict(result) + + # Filter out any None values and convert to JSON serializable format + filtered_result = {} + for key, value in result_dict.items(): + if value is not None and not key.startswith("_"): + if isinstance(value, (str, int, float, bool)) or value is None: + filtered_result[key] = value + else: + try: + # Try to convert to string or another JSON serializable format + filtered_result[key] = str(value) + except: + filtered_result[key] = "Complex value (not displayable)" + + # Replace the placeholder in the template with the actual data + html_content = jwt_display_template.replace( + "const userData = SSO_DATA;", + f"const userData = {json.dumps(filtered_result, indent=2)};", + ) + + return HTMLResponse(content=html_content)