using HopFrame.Database;
using HopFrame.Security.Claims;
using HopFrame.Security.Services;
using HopFrame.Security.Services.Implementation;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace HopFrame.Security.Authentication;
public static class HopFrameAuthenticationExtensions {
///
/// Configures the WebApplication to use the authentication and authorization of the HopFrame API
///
/// The service provider to add the services to
/// The database object that saves all entities that are important for the security api
///
public static IServiceCollection AddHopFrameAuthentication(this IServiceCollection service) where TDbContext : HopDbContextBase {
service.TryAddSingleton();
service.AddScoped>();
service.AddScoped>();
service.AddScoped>();
service.AddAuthentication(HopFrameAuthentication.SchemeName).AddScheme>(HopFrameAuthentication.SchemeName, _ => {});
service.AddAuthorization();
return service;
}
}