Last active
January 14, 2025 03:40
-
-
Save ravindUwU/c820dd5e2936d02ee96451189b0df53f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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