using Microsoft.AspNetCore.Authentication; namespace LANCommander.Server.Extensions { public static class HttpContextExtensions { public static async Task GetExternalProvidersAsync(this HttpContext context) { ArgumentNullException.ThrowIfNull(context); var schemes = context.RequestServices.GetRequiredService(); return (from scheme in await schemes.GetAllSchemesAsync() where !string.IsNullOrEmpty(scheme.DisplayName) select scheme).ToArray(); } public static async Task IsProviderSupportedAsync(this HttpContext context, string provider) { ArgumentNullException.ThrowIfNull(context); return (from scheme in await context.GetExternalProvidersAsync() where string.Equals(scheme.Name, provider, StringComparison.OrdinalIgnoreCase) select scheme).Any(); } } }