Пример #1
0
        public static AuthenticationBuilder AddEsia <TEsiaEvents, TEsiaHandler>(
            this AuthenticationBuilder builder,
            string authenticationScheme,
            string displayName,
            Action <EsiaOptions> configureOptions)
            where TEsiaEvents : OpenIdConnectEvents
            where TEsiaHandler : OpenIdConnectHandler
        {
            var esiaOptions = new EsiaOptions();

            configureOptions(esiaOptions);
            IEsiaEnvironment esiaEnvironment = esiaOptions.EnvironmentInstance
                                               ?? new EsiaEnvironmentResolver(esiaOptions.Environment ?? throw new ArgumentNullException("Environment and EnvironmentInstance is null")).Resolve();

            // register new services
            builder.Services.AddSingleton(esiaOptions);
            builder.Services.AddSingleton(esiaEnvironment);
            builder.Services.AddSingleton <TEsiaEvents>();
            builder.Services.AddSingleton <OpenIdConnectOptionsBuilder>();
            builder.Services.AddTransient <IEsiaRestService, EsiaRestService>();
            builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton <IPostConfigureOptions <OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());

            var configBuilder = new OpenIdConnectOptionsBuilder(esiaOptions, esiaEnvironment);

            return(builder.AddRemoteScheme <OpenIdConnectOptions, TEsiaHandler>(authenticationScheme, displayName, configBuilder.BuildAction <TEsiaEvents>()));
        }
Пример #2
0
 /// <param name="esiaOptions">Свойства подключения к ЕСИА.</param>
 /// <param name="esiaEnvironment">Среда ЕСИА.</param>
 /// <param name="serviceProvider">Поставщик служб (сейчас используется для получения IEsiaSigner).</param>
 public EsiaEvents(
     EsiaOptions esiaOptions,
     IEsiaEnvironment esiaEnvironment,
     IServiceProvider serviceProvider) // TODO add IEsiaSigner directly
 {
     this.EsiaOptions     = esiaOptions;
     this.EsiaEnvironment = esiaEnvironment;
     this.EsiaSigner      = serviceProvider.GetService <IEsiaSigner>(); // TODO add IEsiaSigner directly
 }
Пример #3
0
 public EsiaRestService(
     IHttpContextAccessor httpContextAccessor,
     IEsiaEnvironment esiaEnvironment,
     IServiceProvider serviceProvider, // TODO add IEsiaSigner directly
     IOptionsMonitor <OpenIdConnectOptions> optionsMonitor,
     EsiaOptions esiaOptions)
 {
     this.context         = httpContextAccessor.HttpContext;
     this.esiaEnvironment = esiaEnvironment;
     this.esiaSigner      = serviceProvider.GetService <IEsiaSigner>(); // TODO add IEsiaSigner directly
     this.optionsMonitor  = optionsMonitor;
     this.esiaOptions     = esiaOptions;
 }
 public EsiaHandler(
     IOptionsMonitor <OpenIdConnectOptions> options,
     ILoggerFactory logger,
     HtmlEncoder htmlEncoder,
     UrlEncoder encoder,
     ISystemClock clock,
     EsiaOptions esiaOptions,
     IEsiaEnvironment esiaEnvironment)
     : base(options, logger, htmlEncoder, encoder, clock)
 {
     this.esiaOptions     = esiaOptions;
     this.esiaEnvironment = esiaEnvironment;
 }
Пример #5
0
 public OpenIdConnectOptionsBuilder(EsiaOptions esiaOptions, IEsiaEnvironment environment)
 {
     this.esiaOptions = esiaOptions;
     this.environment = environment;
 }