+ 8

Decrypting .net cookies

Is it possible to decrypt owin asp.net application cookies without using asp.net c# itself? How?

11th Jul 2019, 12:49 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
1 Answer
+ 7
Here’s an example that simply displays all of the user’s claims from either an AccessToken or Cookie: // Allow CORS for all origins. [EnableCors(origins: "*", headers: "*", methods: "*")] [HostAuthentication("Application")] [Authorize] public class UserController : ApiController { public object Get() { var identity = this.User.Identity as ClaimsIdentity; var roleClaims = identity.Claims.Where(x => x.Type == ClaimsIdentity.DefaultRoleClaimType).Select(x => x.Value).ToList(); var nonRoleClaims = identity.Claims.Where(x => x.Type != ClaimsIdentity.DefaultRoleClaimType).Select(x => new { Type = x.Type, Value = x.Value }).ToList(); return new { name = identity.Name, roles = roleClaims, claims = nonRoleClaims }; } }
12th Jul 2019, 4:48 AM
Prabhat
Prabhat - avatar