Skip to content

Instantly share code, notes, and snippets.

@ravindUwU
Last active January 14, 2025 03:40
Show Gist options
  • Save ravindUwU/c820dd5e2936d02ee96451189b0df53f to your computer and use it in GitHub Desktop.
Save ravindUwU/c820dd5e2936d02ee96451189b0df53f to your computer and use it in GitHub Desktop.
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
[ApiController]
public class ClaimsEndpoint : ControllerBase
{
[HttpGet("/uwu")]
public ActionResult Handle()
{
return Ok(new
{
Identities = User.Identities.Select((i) => new
{
i.AuthenticationType,
Claims = i.Claims
.GroupBy((c) => c.Type)
.Select((g) => KeyValuePair.Create<string, object>(
g.Key,
g.Count() is 1 ? g.First().Value : g.Select((c) => c.Value)
))
.ToDictionary()
}),
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment