using AuthStudy.Authentication.Browser;

namespace AuthStudy.WebApp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

            // 添加服务到IoC容器
            builder.Services.AddControllers();
            // Swagger 注册
            builder.Services.AddSwaggerGen();

            #region 认证注册
            //接口实现注册
            builder.Services.AddBrowserAuthentication
            (
                BrowserAuthenticationDefault.SchemeName,
                BrowserAuthenticationDefault.DispayName,
                new BrowserAuthenticationOptions()
                {
                    AllowBrowsers = new List<string>() { "Edge" }
                }
            );
            builder.Services
                .AddAuthentication(AuthenticationSchemeList.BaseBrowserScheme)
                .AddScheme<BrowserAuthenticationOptions, BrowserAuthenticationHandler>(AuthenticationSchemeList.BaseBrowserScheme, option =>
                {
                    option.AllowBrowsers = new List<string>() { "Edge", "Chrome", "Firefox" };
                });

            //默认基类实现注册

            #endregion

            WebApplication app = builder.Build();

            // 配置 Http 管道.
            app.UseSwagger();
            app.UseSwaggerUI();

            app.UseAuthentication();
            app.UseAuthorization();

            app.MapControllers();

            app.Run();
        }
    }
}