diff --git a/src/DigitalData.Auth.API/Services/ConsumerApiJsonBasedService.cs b/src/DigitalData.Auth.API/Services/ConsumerApiJsonBasedService.cs new file mode 100644 index 0000000..3e23c48 --- /dev/null +++ b/src/DigitalData.Auth.API/Services/ConsumerApiJsonBasedService.cs @@ -0,0 +1,19 @@ +using DigitalData.Auth.API.Dto; +using DigitalData.Auth.API.Services.Contracts; +using Microsoft.Extensions.Options; + +namespace DigitalData.Auth.API.Services +{ + public class ConsumerApiJsonBasedService : IConsumerApiService + { + private readonly IEnumerable _consumerAPIs; + public ConsumerApiJsonBasedService(IOptions> options) + { + _consumerAPIs = options.Value; + } + + public Task ReadByNameAsync(string name) => Task.Run(() => _consumerAPIs.FirstOrDefault(api => api.Name == name)); + + public async Task VerifyAsync(ConsumerApiLogin login, string password) => (await ReadByNameAsync(login.Name))?.Password == password; + } +} \ No newline at end of file diff --git a/src/DigitalData.Auth.API/Services/Contracts/IConsumerApiService.cs b/src/DigitalData.Auth.API/Services/Contracts/IConsumerApiService.cs new file mode 100644 index 0000000..942d610 --- /dev/null +++ b/src/DigitalData.Auth.API/Services/Contracts/IConsumerApiService.cs @@ -0,0 +1,11 @@ +using DigitalData.Auth.API.Dto; + +namespace DigitalData.Auth.API.Services.Contracts +{ + public interface IConsumerApiService + { + public Task ReadByNameAsync(string name); + + public Task VerifyAsync(ConsumerApiLogin login, string password); + } +} \ No newline at end of file