OPC # 0001: Extract Clarity into standalone repo
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Clarity.Server.Endpoints
|
||||
{
|
||||
public static class DebugEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapDebugEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var api = app.MapGroup("/api").RequireAuthorization();
|
||||
|
||||
api.MapGet("debug/claims", (ClaimsPrincipal user) =>
|
||||
{
|
||||
var sub = user.FindFirstValue(ClaimTypes.NameIdentifier) ?? user.FindFirstValue("sub");
|
||||
|
||||
return Results.Ok(new
|
||||
{
|
||||
Subject = sub,
|
||||
Username = user.FindFirstValue("preferred_username"),
|
||||
Email = user.FindFirstValue(ClaimTypes.Email) ?? user.FindFirstValue("email"),
|
||||
IsAuthenticated = user.Identity?.IsAuthenticated,
|
||||
AllClaims = user.Claims.Select(c => new { c.Type, c.Value })
|
||||
});
|
||||
});
|
||||
|
||||
// Sanity check - no auth required, confirms API is reachable
|
||||
api.MapGet("auth/ping", () => Results.Ok(new { Status = "ok", Time = DateTimeOffset.UtcNow }))
|
||||
.AllowAnonymous();
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user