22 lines
No EOL
440 B
C#
22 lines
No EOL
440 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
} |