public RegisterExecutor( IClient client, StormpathConfiguration configuration, HandlerConfiguration handlers, ILogger logger) { _client = client; _configuration = configuration; _handlers = handlers; _logger = logger; }
private StormpathMiddleware( IViewRenderer viewRenderer, ILogger logger, IFrameworkUserAgentBuilder userAgentBuilder, IScopedClientFactory clientFactory, IntegrationConfiguration configuration, HandlerConfiguration handlers) { this.viewRenderer = viewRenderer; this.logger = logger; this.userAgentBuilder = userAgentBuilder; this.clientFactory = clientFactory; this.Configuration = configuration; this.Handlers = handlers; this.routingTable = this.BuildRoutingTable(); }
public static StormpathMiddleware Create(StormpathOwinOptions options) { if (string.IsNullOrEmpty(options.LibraryUserAgent)) { throw new ArgumentNullException(nameof(options.LibraryUserAgent)); } if (options.ViewRenderer == null) { throw new ArgumentNullException(nameof(options.ViewRenderer)); } // Construct the framework User-Agent IFrameworkUserAgentBuilder userAgentBuilder = new DefaultFrameworkUserAgentBuilder(options.LibraryUserAgent); options.Logger.Info("Stormpath middleware starting up", nameof(StormpathMiddleware)); // Initialize and warm up SDK options.Logger.Trace("Initializing and warming up SDK...", nameof(StormpathMiddleware)); var clientFactory = InitializeClient(options.Configuration, options.ConfigurationFileRoot, options.CacheProvider, options.Logger); // Scope a client for our resolution steps below options.Logger.Trace("Creating scoped ClientFactory...", nameof(StormpathMiddleware)); var client = clientFactory.Create(new ScopedClientOptions() { UserAgent = userAgentBuilder.GetUserAgent() }); // Resolve application href, if necessary // (see https://github.com/stormpath/stormpath-framework-spec/blob/master/configuration.md#application-resolution) options.Logger.Trace("Resolving application...", nameof(StormpathMiddleware)); var application = ResolveApplication(client, options.Logger); var updatedConfiguration = new StormpathConfiguration( client.Configuration.Client, new ApplicationConfiguration(application.Name, application.Href), client.Configuration.Web); // Pull some configuration from the tenant environment options.Logger.Trace("Examining tenant environment...", nameof(StormpathMiddleware)); var integrationConfiguration = GetIntegrationConfiguration(client, updatedConfiguration, application, options.Logger); // Validate Account Store configuration // (see https://github.com/stormpath/stormpath-framework-spec/blob/master/configuration.md#application-resolution) options.Logger.Trace("Ensuring the Account Store configuration is valid...", nameof(StormpathMiddleware)); EnsureAccountStores(client, integrationConfiguration, application, options.Logger); // Validate any remaining configuration options.Logger.Trace("Ensuring the integration configuration is valid...", nameof(StormpathMiddleware)); EnsureIntegrationConfiguration(integrationConfiguration, options.Logger); options.Logger.Trace("Stormpath middleware ready!", nameof(StormpathMiddleware)); var handlerConfiguration = new HandlerConfiguration( options.PreChangePasswordHandler ?? DefaultHandlers.PreChangePasswordHandler, options.PostChangePasswordHandler ?? DefaultHandlers.PostChangePasswordHandler, options.PreLoginHandler ?? DefaultHandlers.PreLoginHandler, options.PostLoginHandler ?? DefaultHandlers.PostLoginHandler, options.PreLogoutHandler ?? DefaultHandlers.PreLogoutHandler, options.PostLogoutHandler ?? DefaultHandlers.PostLogoutHandler, options.PreRegistrationHandler ?? DefaultHandlers.PreRegistrationHandler, options.PostRegistrationHandler ?? DefaultHandlers.PostRegistrationHandler, options.PreVerifyEmailHandler ?? DefaultHandlers.PreVerifyEmailHandler, options.PostVerifyEmailHandler ?? DefaultHandlers.PostVerifyEmailHandler); return(new StormpathMiddleware( options.ViewRenderer, options.Logger, userAgentBuilder, clientFactory, integrationConfiguration, handlerConfiguration)); }