Beispiel #1
0
        public Facade(IAuthenticationSchemeRetriever authenticationSchemeRetriever, IAuthorizationResolver authorizationResolver, IClientStore clientStore, IDecorationLoader decorationLoader, IEventService events, IOptionsMonitor <ExceptionHandlingOptions> exceptionHandling, IFeatureManager featureManager, IHttpContextAccessor httpContextAccessor, IIdentityFacade identity, IOptionsMonitor <ExtendedIdentityServerOptions> identityServer, IIdentityServerInteractionService interaction, IStringLocalizerFactory localizerFactory, ILoggerFactory loggerFactory, IOptionsMonitor <RequestLocalizationOptions> requestLocalization, IServiceProvider serviceProvider)
        {
            this.AuthenticationSchemeRetriever = authenticationSchemeRetriever ?? throw new ArgumentNullException(nameof(authenticationSchemeRetriever));
            this.AuthorizationResolver         = authorizationResolver ?? throw new ArgumentNullException(nameof(authorizationResolver));
            this.ClientStore         = clientStore ?? throw new ArgumentNullException(nameof(clientStore));
            this.DecorationLoader    = decorationLoader ?? throw new ArgumentNullException(nameof(decorationLoader));
            this.Events              = events ?? throw new ArgumentNullException(nameof(events));
            this.ExceptionHandling   = exceptionHandling ?? throw new ArgumentNullException(nameof(exceptionHandling));
            this.FeatureManager      = featureManager ?? throw new ArgumentNullException(nameof(featureManager));
            this.HttpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
            this.Identity            = identity ?? throw new ArgumentNullException(nameof(identity));
            this.IdentityServer      = identityServer ?? throw new ArgumentNullException(nameof(identityServer));
            this.Interaction         = interaction ?? throw new ArgumentNullException(nameof(interaction));
            this.LocalizerFactory    = localizerFactory ?? throw new ArgumentNullException(nameof(localizerFactory));
            this.LoggerFactory       = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            this.RequestLocalization = requestLocalization ?? throw new ArgumentNullException(nameof(requestLocalization));

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (featureManager.IsEnabled(Feature.Saml))
            {
                this.SamlInteraction = serviceProvider.GetRequiredService <ISamlInteractionService>();
            }
        }
        public static async Task <IDictionary <IAuthenticationScheme, AuthenticationSchemeOptions> > GetDiagnosticsAsync(this IAuthenticationSchemeRetriever authenticationSchemeRetriever, IServiceProvider serviceProvider)
        {
            if (authenticationSchemeRetriever == null)
            {
                throw new ArgumentNullException(nameof(authenticationSchemeRetriever));
            }

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            var diagnostics = new Dictionary <IAuthenticationScheme, AuthenticationSchemeOptions>();

            var schemes = await authenticationSchemeRetriever.ListAsync().ConfigureAwait(false);

            foreach (var scheme in schemes)
            {
                var options = await scheme.GetOptionsDiagnosticsAsync(serviceProvider).ConfigureAwait(false);

                diagnostics.Add(scheme, options);
            }

            return(diagnostics);
        }