Adding security
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.Library.Internal.ApiSecurity.Models;
|
||||
|
||||
namespace LCU.Library.Internal.ApiSecurity;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds required API Security services.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection that API Security services are added to.</param>
|
||||
/// <returns>A <see cref="IApiSecurityBuilder"/> that can be used to customize API Security functionality.</returns>
|
||||
public static IApiSecurityBuilder AddApiKeySecurity(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddLogging();
|
||||
|
||||
//TODO: Move this functionality from binding a config to making a call to an API Security API, only hold config in memory instead of file system
|
||||
//This is less of a concern for containerized apps but still not ideal since the credentials will still be on the containers file system
|
||||
var apiSecurityConfiguration = new ApiSecurityConfiguration();
|
||||
configuration.GetSection("ApiSecurityConfiguration").Bind(apiSecurityConfiguration);
|
||||
services.AddSingleton(apiSecurityConfiguration);
|
||||
|
||||
return new ApiSecurityBuilder(services);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user