Skip to content

Instantly share code, notes, and snippets.

@xivk
Created December 12, 2017 11:46
Show Gist options
  • Save xivk/e6af897ead54bb36ca74cf592073062d to your computer and use it in GitHub Desktop.
Save xivk/e6af897ead54bb36ca74cf592073062d to your computer and use it in GitHub Desktop.
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