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,22 @@
using System;
using System.Threading.Tasks;
namespace Robware.Auth.API {
public class ApiKeyValidator : IApiKeyValidator {
private readonly IApiKeys _apiKeys;
public ApiKeyValidator(IApiKeys apiKeys) {
_apiKeys = apiKeys;
}
public async Task<bool> Validate(string key) {
try {
var apiKey = await _apiKeys.Get(key);
return apiKey.Enabled;
}
catch (ApiKeyNotFoundException) {
return false;
}
}
}
}