Decrypting .net cookies | Sololearn: Learn to code for FREE!

+8

Decrypting .net cookies

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

7/11/2019 12:49:33 PM

Sarthak Pokhrel

1 Answer

New 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 }; } }