-
-
Save miseeger/4dc85d2a29b555ec12a29cf376930320 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 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