/// <summary> /// Adds services required for Stormpath. /// </summary> /// <param name="services">The <see cref="IServiceCollection" />.</param> /// <param name="options">Extended configuration for the Stormpath middleware.</param> /// <returns>A reference to this instance after the operation has completed.</returns> /// <exception cref="Stormpath.Owin.InitializationException">There was a problem initializing Stormpath.</exception> public static IServiceCollection AddStormpath( this IServiceCollection services, StormpathOptions options) { var owinOptions = new StormpathOwinOptions { Configuration = options?.Configuration, CacheProvider = options?.CacheProvider, PostChangePasswordHandler = options?.PostChangePasswordHandler, PostLoginHandler = options?.PostLoginHandler, PostLogoutHandler = options?.PostLogoutHandler, PostRegistrationHandler = options?.PostRegistrationHandler, PostVerifyEmailHandler = options?.PostVerifyEmailHandler, PreChangePasswordHandler = options?.PreChangePasswordHandler, PreLoginHandler = options?.PreLoginHandler, PreLogoutHandler = options?.PreLogoutHandler, PreRegistrationHandler = options?.PreRegistrationHandler, PreVerifyEmailHandler = options?.PreVerifyEmailHandler, }; return AddStormpath(services, owinOptions); }
public OptionsContainer(StormpathOwinOptions options = null) { Options = options; }
private static IServiceCollection AddStormpath( IServiceCollection services, StormpathOwinOptions options) { if (services == null) { throw new ArgumentNullException(nameof(services)); } services.AddLogging(); services.AddSingleton<SDK.Logging.ILogger>( provider => new LoggerAdapter(provider.GetRequiredService<ILoggerFactory>())); services.AddSingleton(new OptionsContainer(options)); services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped<ScopedClientAccessor>(); services.AddScoped<ScopedConfigurationAccessor>(); services.AddScoped<ScopedApplicationAccessor>(); services.AddScoped<ScopedLazyUserAccessor>(); services.AddScoped(provider => provider.GetRequiredService<ScopedClientAccessor>().Item); services.AddScoped(provider => provider.GetRequiredService<ScopedConfigurationAccessor>().Item); services.AddScoped(provider => provider.GetRequiredService<ScopedApplicationAccessor>().Item); services.AddScoped(provider => provider.GetRequiredService<ScopedLazyUserAccessor>().Item); services.AddScoped(provider => provider.GetRequiredService<ScopedLazyUserAccessor>().Item.Value); services.AddSingleton<RazorViewRenderer>(); services.AddAuthentication(); services.AddAuthorization(); services.AddSingleton<IAuthorizationHandler, StormpathGroupsHandler>(); services.AddSingleton<IAuthorizationHandler, StormpathCustomDataHandler>(); return services; }