-
Notifications
You must be signed in to change notification settings - Fork 6
/
IdentityController.cs
30 lines (29 loc) · 1.04 KB
/
IdentityController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Sample.Api.AspNetCore.Models;
namespace Sample.Api.AspNetCore.Controllers
{
[Authorize(Constants.AuthorizationPolicies.ReadIdentity)]
[Route("api/[controller]")]
[ApiController]
public class IdentityController : ControllerBase
{
[HttpGet]
public ActionResult<IdentityInfo> Get()
{
// Return identity information as seen from this application.
return new IdentityInfo
{
Source = "Access Token",
Application = "Sample API",
IsAuthenticated = this.User.Identity.IsAuthenticated,
Name = this.User.Identity.Name,
AuthenticationType = this.User.Identity.AuthenticationType,
Claims = this.User.Claims.Select(c => new ClaimInfo { Type = c.Type, Value = c.Value }).ToList(),
RelatedApplicationIdentities = Array.Empty<IdentityInfo>()
};
}
}
}