Created
December 12, 2017 11:46
-
-
Save xivk/e6af897ead54bb36ca74cf592073062d to your computer and use it in GitHub Desktop.
This file contains 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 Nancy; | |
using Nancy.Security; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace Anyways.Nancy.API | |
{ | |
public class IdentityModule : NancyModule | |
{ | |
public IdentityModule() | |
{ | |
Get("/identity", args => this.Get()); | |
} | |
public object Get() | |
{ | |
try | |
{ | |
this.RequiresAuthentication(); | |
var claims = new List<Tuple<string, string>>(); | |
foreach(var c in this.Context.CurrentUser.Claims) | |
{ | |
claims.Add(new Tuple<string, string>(c.Type, c.Value)); | |
} | |
return claims.ToArray(); | |
} | |
catch(Exception ex) | |
{ | |
throw ex; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment