-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimpleController.cs
More file actions
35 lines (33 loc) · 954 Bytes
/
SimpleController.cs
File metadata and controls
35 lines (33 loc) · 954 Bytes
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
31
32
33
34
35
using Microsoft.AspNetCore.Mvc;
using SimpleAPI.OIDC;
namespace SimpleAPI.Controllers
{
[Route("simple")]
[ApiController]
public class SimpleController : ControllerBase
{
public IntrospectionClient Client { get; }
public SimpleController(IntrospectionClient client)
{
Client = client;
}
[HttpGet]
public async Task<IActionResult> Index([FromHeader(Name = "Authorization")] string authorization)
{
var introspection = await Client.ValidateAuthorization(authorization);
if (introspection != null)
{
var sub = introspection.Subject;
var obj = new
{
hello = sub
};
return new JsonResult(obj);
}
else
{
return new BearerTokenResult(Client.ClientId);
}
}
}
}