Huge work
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
@@ -10,15 +11,39 @@ namespace KTUSAPS.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
public class AuthMetadataController : ControllerBase
|
||||
{
|
||||
public class AuthMetadata
|
||||
{
|
||||
public string ClientId { get; set; }
|
||||
public string Authority { get; set; }
|
||||
public string Tenant { get; set; }
|
||||
}
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
public AuthMetadataController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get authethication metadata needed to obtain token.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public object Index() => new { ClientId = _configuration["ClientId"], Authority = _configuration["Authority"], Tenant = _configuration["Tenant"] };
|
||||
public AuthMetadata Index() => new AuthMetadata { ClientId = _configuration["ClientId"], Authority = _configuration["Authority"], Tenant = _configuration["Tenant"] };
|
||||
|
||||
/// <summary>
|
||||
/// Returns true is provided token is valid, else throws exception
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">Provided token is correct.</response>
|
||||
/// <response code="401">No valid token provided.</response>
|
||||
[Authorize]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[HttpGet("Authed")]
|
||||
public bool IsAuthed() => true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user