Provide mechanism to validate API keys. Re-organise structure to reflect new responsibility

This commit is contained in:
Robert Marshall 2020-04-19 18:16:42 +01:00
parent 87ae65316f
commit 9519bc623b
27 changed files with 245 additions and 36 deletions

View file

@ -0,0 +1,21 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Robware.Auth.API;
namespace Robware.Api.Auth.Controllers {
[ApiController]
[Route("[controller]")]
public class ApiController : ControllerBase {
private readonly ILogger<ApiController> _logger;
private readonly IApiKeyValidator _apiKeyValidator;
public ApiController(ILogger<ApiController> logger, IApiKeyValidator apiKeyValidator) {
_logger = logger;
_apiKeyValidator = apiKeyValidator;
}
[HttpGet(nameof(Validate))]
public async Task<ActionResult> Validate(string key) => await _apiKeyValidator.Validate(key) ? (ActionResult) Ok() : Unauthorized();
}
}