protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // Launch a thread that watches the book detail subscription. var container = App_Start.UnityConfig.GetConfiguredContainer(); LibUnityConfig.RegisterTypes(container); var bookDetailLookup = new BookDetailLookup(LibUnityConfig.ProjectId, logger: LogTicker.Instance); bookDetailLookup.CreateTopicAndSubscription(); var pullTask = bookDetailLookup.StartPullLoop(container.Resolve <IBookStore>(), new CancellationTokenSource().Token); }
/// <summary>Configure Google OAuth2 authentication</summary> /// <remarks> /// OAauth Client Id and Client Secret must be set in application configuration /// </remarks> public void Configuration(IAppBuilder app) { // [START cookie_authentication] app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ExternalCookie }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); // [END cookie_authentication] // [START configure_google_auth_client] var authenticationOptions = new GoogleOAuth2AuthenticationOptions() { ClientId = LibUnityConfig.GetConfigVariable("GoogleCloudSamples:AuthClientId"), ClientSecret = LibUnityConfig.GetConfigVariable("GoogleCloudSamples:AuthClientSecret"), }; // [END configure_google_auth_client] // [START configure_google_auth_scopes] // Add scope to access user's basic profile information authenticationOptions.Scope.Add("profile"); // [END configure_google_auth_scopes] authenticationOptions.Provider = new GoogleOAuth2AuthenticationProvider() { // [START read_google_profile_image_url] // After OAuth authentication completes successfully, // read user's profile image URL from the profile // response data and add it to the current user identity OnAuthenticated = context => { var profileUrl = context.User["image"]["url"].ToString(); context.Identity.AddClaim(new Claim(ClaimTypes.Uri, profileUrl)); return(Task.FromResult(0)); } // [END read_google_profile_image_url] }; app.UseGoogleAuthentication(authenticationOptions); }