public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); appBuilder.UseWebApi(config); var appFolder = Path.Combine(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName, "Webportal"); appBuilder.UseFileServer(new Microsoft.Owin.StaticFiles.FileServerOptions { RequestPath = new PathString(WebPortalUrl), FileSystem = new PhysicalFileSystem(appFolder), EnableDirectoryBrowsing = true }); appBuilder.Map(PathString.Empty, a => a.Use<PortalRedirectionMiddelware>(WebPortalUrl)); appBuilder.Use<AdminMiddleware>(); }
public void Configuration(IAppBuilder appBuilder) { var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new {id = RouteParameter.Optional}); appBuilder.UseWebApi(config).UseNancy(); }
public static void ConfigureSocialIdentityProviders(IAppBuilder app, string signInAsType) { var google = new GoogleAuthenticationOptions { AuthenticationType = "Google", SignInAsAuthenticationType = signInAsType }; app.UseGoogleAuthentication(google); var fb = new FacebookAuthenticationOptions { AuthenticationType = "Facebook", SignInAsAuthenticationType = signInAsType, AppId = "676607329068058", AppSecret = "9d6ab75f921942e61fb43a9b1fc25c63" }; app.UseFacebookAuthentication(fb); var twitter = new TwitterAuthenticationOptions { AuthenticationType = "Twitter", SignInAsAuthenticationType = signInAsType, ConsumerKey = "N8r8w7PIepwtZZwtH066kMlmq", ConsumerSecret = "df15L2x6kNI50E4PYcHS0ImBQlcGIt6huET8gQN41VFpUCwNjM" }; app.UseTwitterAuthentication(twitter); }
// This code configures Web API. The Startup class is specified as a type // parameter in the WebApp.Start method. public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } ); // 默认返回Json数据 //config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); //var bson = new BsonMediaTypeFormatter(); //bson.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/bson")); //config.Formatters.Add(bson); config.Formatters.Add(new Raven.AspNet.WebApiExtensions.Formatters.MsgPackFormatter()); appBuilder.UseRequestScopeContext(); appBuilder.UseWebApi(config); //CallContext //appBuilder.Use( }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); app.UseKentorAuthServicesAuthentication(CreateAuthServicesOptions()); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Enable the application to use a cookie to store information for the signed in user app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); // Use a cookie to temporarily store information about a user logging in with a third party login provider app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(); }
public static void Configure(IAppBuilder app) { if (app == null) throw new ArgumentNullException("app"); IContainer container = IocConfiguration.BuildContainer(actorSystemName: "Wakka"); app.UseAutofacMiddleware(container); HttpConfiguration webApiConfiguration = new HttpConfiguration { // Only used when mapping attribute routes. DependencyResolver = new AutofacWebApiDependencyResolver(container) }; app.UseAutofacWebApi(webApiConfiguration); // Share OWIN lifetime scope. webApiConfiguration.MapHttpAttributeRoutes(); webApiConfiguration.EnsureInitialized(); app.UseWebApi(webApiConfiguration); // Explicitly start the actor system when the OWIN app is started. ActorSystem actorSystem = container.ResolveNamed<ActorSystem>("Wakka"); // Try to gracefully shut down the actor system when the host is shutting down. AppProperties appProperties = new AppProperties(app.Properties); appProperties.OnAppDisposing.Register(() => { actorSystem.Shutdown(); actorSystem.AwaitTermination( timeout: TimeSpan.FromSeconds(5) ); }); }
public void ConfigureAuth(IAppBuilder app) { // Configure the db context and user manager to use a single instance per request app.CreatePerOwinContext(MessagesDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Configure the application for OAuth based flow. Do it only once! if (OAuthOptions == null) { PublicClientId = "self"; OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString(TokenEndpointPath), Provider = new ApplicationOAuthProvider(PublicClientId), AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), AllowInsecureHttp = true }; } // Enable the application to use bearer tokens to authenticate users app.UseOAuthBearerTokens(OAuthOptions); }
private void ConfigureModules(IAppBuilder appBuilder) { appBuilder .Use<ListenerModule>(registeredHandlers, Logger) .MapSignalR(new HubConfiguration { EnableJavaScriptProxies = false, EnableJSONP = HubEnableJsonp }) .Use<Error404Module>(); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Configure the application for OAuth based flow PublicClientId = "self"; // Enable the application to use bearer tokens to authenticate users // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() //{ // ClientId = "", // ClientSecret = "" //}); }
public void Configuration(IAppBuilder app) { app.MapSignalR<SendingConnection>("/sending-connection"); app.MapSignalR<TestConnection>("/test-connection"); app.MapSignalR<RawConnection>("/raw-connection"); app.MapSignalR<StreamingConnection>("/streaming-connection"); app.Use(typeof(ClaimsMiddleware)); ConfigureSignalR(GlobalHost.DependencyResolver, GlobalHost.HubPipeline); var config = new HubConfiguration() { EnableDetailedErrors = true }; app.MapSignalR(config); app.Map("/cors", map => { map.UseCors(CorsOptions.AllowAll); map.MapSignalR<RawConnection>("/raw-connection"); map.MapSignalR(); }); app.Map("/basicauth", map => { map.UseBasicAuthentication(new BasicAuthenticationProvider()); map.MapSignalR<AuthenticatedEchoConnection>("/echo"); map.MapSignalR(); }); BackgroundThread.Start(); }
public void Configuration(IAppBuilder app) { ConfigureWebApi(); ConfigureJsonFormatter(); app.UseWebApi(_configuration); }
public static new void Install(HttpConfiguration config, IAppBuilder app) { config.SuppressHostPrincipal(); app.UseCors(CorsOptions.AllowAll); app.MapSignalR(); var jSettings = new JsonSerializerSettings(); jSettings.Formatting = Formatting.Indented; jSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.Remove(config.Formatters.XmlFormatter); config.Formatters.JsonFormatter.SerializerSettings = jSettings; config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(RealEstatesDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<UserManager<User>, User>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process. app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Enables the application to remember the second login verification factor such as phone or email. // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from. // This is similar to the RememberMe option when you log in. app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context and user manager to use a single instance per request app.CreatePerOwinContext(DBContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Configure the application for OAuth based flow PublicClientId = "self"; OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/Token"), Provider = new ApplicationOAuthProvider(PublicClientId), AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), //If the AccessTokenExpireTimeSpan is changed, also change the ExpiresUtc in the RefreshTokenProvider.cs. AccessTokenExpireTimeSpan = TimeSpan.FromHours(2), AllowInsecureHttp = true, RefreshTokenProvider = new RefreshTokenProvider() }; // Enable the application to use bearer tokens to authenticate users app.UseOAuthBearerTokens(OAuthOptions); }
public static void ConfigureMobileApp(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); #if DEBUG config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; #endif new MobileAppConfiguration().UseDefaultConfiguration().ApplyTo(config); config.Services.Add(typeof(IExceptionLogger), new AiExceptionLogger()); // Use Entity Framework Code First to create database tables based on your DbContext Database.SetInitializer(new MobileServiceInitializer()); MobileAppSettingsDictionary settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings(); if (string.IsNullOrEmpty(settings.HostName)) { app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions { // This middleware is intended to be used locally for debugging. By default, HostName will // only have a value when running in an App Service application. SigningKey = ConfigurationManager.AppSettings["SigningKey"], ValidAudiences = new[] { ConfigurationManager.AppSettings["ValidAudience"] }, ValidIssuers = new[] { ConfigurationManager.AppSettings["ValidIssuer"] }, TokenHandler = config.GetAppServiceTokenHandler() }); } app.UseWebApi(config); }
// Para obtener más información sobre la configuración de la autenticación, visite http://go.microsoft.com/fwlink/?LinkId=301883 public void ConfigureAuth(IAppBuilder app) { // Habilitar la aplicación para que use una cookie para almacenar la información del usuario que inició sesión // y almacenar también información acerca de un usuario que inicie sesión con un proveedor de inicio de sesión de un tercero. // Es obligatorio si la aplicación permite a los usuarios iniciar sesión app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Quitar las marcas de comentario de las líneas siguientes para habilitar el inicio de sesión con proveedores de inicio de sesión de terceros //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(); }
public void Configuration(IAppBuilder app) { var httpConfiguration = new HttpConfiguration(); // Configure Web API Routes: // - Enable Attribute Mapping // - Enable Default routes at /api. httpConfiguration.MapHttpAttributeRoutes(); httpConfiguration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); app.UseWebApi(httpConfiguration); // Make ./public the default root of the static files in our Web Application. app.UseFileServer(new FileServerOptions { RequestPath = new PathString(string.Empty), FileSystem = new PhysicalFileSystem("./public"), EnableDirectoryBrowsing = true, }); app.UseStageMarker(PipelineStage.MapHandler); }
public void Configuration(IAppBuilder app) { //app.MapSignalR(); app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { EnableJSONP = true }; map.RunSignalR(hubConfiguration); }); // Branch the pipeline here for requests that start with "/signalr" //app.Map("/signalr", map => //{ // // Setup the CORS middleware to run before SignalR. // // By default this will allow all origins. You can // // configure the set of origins and/or http verbs by // // providing a cors options with a different policy. // map.UseCors(CorsOptions.AllowAll); // var hubConfiguration = new HubConfiguration // { // // You can enable JSONP by uncommenting line below. // // JSONP requests are insecure but some older browsers (and some // // versions of IE) require JSONP to work cross domain // // EnableJSONP = true // }; // // Run the SignalR pipeline. We're not using MapSignalR // // since this branch already runs under the "/signalr" // // path. // map.RunSignalR(hubConfiguration); //}); }
public void Configuration(IAppBuilder app) { app.Run(context => { return context.Response.WriteAsync(RESULT); }); }
public void Configuration(IAppBuilder app) { var config = new HttpConfiguration(); ConfigureOAuth(app); WebApiConfig.Register(config); app.UseWebApi(config); }
public void Configuration(IAppBuilder app) { app.UseNancy(options => { options.Bootstrapper = new Bootstrapper(); }); }
public void Configuration(IAppBuilder app) { var config = new ResttpConfiguration(typeof(HomeController).Assembly); config.MapHttpRoutesFromAttributes(); config.HttpRoutes.AddRoutes ( "Home", "/Main", new { controller = "Home", action = "Index", httpMethod = "Get" }); config.HttpRoutes.AddRoutes ( "Home", "/{controller}/{action}", new { controller = "Home" }); config.DependencyResolver = GetResolver(); app.UseResttp(config); }
public void Configuration(IAppBuilder app) { app.UseOAuthBearerAuthentication(AccountController.OAuthBearerOptions); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); if (IsTrue("ExternalAuth.Facebook.IsEnabled")) { app.UseFacebookAuthentication(CreateFacebookAuthOptions()); } if (IsTrue("ExternalAuth.Twitter.IsEnabled")) { app.UseTwitterAuthentication(CreateTwitterAuthOptions()); } if (IsTrue("ExternalAuth.Google.IsEnabled")) { app.UseGoogleAuthentication(CreateGoogleAuthOptions()); } }
public void Configuration(IAppBuilder builder) { builder.UseAlpha("a", "b"); builder.UseFunc(app => Alpha.Invoke(app, "a", "b")); builder.UseFunc(Alpha.Invoke, "a", "b"); builder.Use(Beta.Invoke("a", "b")); builder.UseFunc(Beta.Invoke, "a", "b"); builder.UseGamma("a", "b"); builder.Use(typeof(Gamma), "a", "b"); builder.UseType<Gamma>("a", "b"); builder.UseFunc<AppFunc>(app => new Gamma(app, "a", "b").Invoke); builder.Use(typeof(Delta), "a", "b"); builder.UseType<Delta>("a", "b"); builder.UseFunc<AppFunc>(app => new Delta(app, "a", "b").Invoke); builder.Run(this); }
public void Configuration(IAppBuilder app) { var webApiConfiguration = ConfigureWebApi(); webApiConfiguration.EnsureInitialized(); app.UseWebApi(webApiConfiguration); ConfigureHandlers(); }
// 有关配置身份验证的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // 使应用程序可以使用 Cookie 来存储已登录用户的信息 app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); // Use a cookie to temporarily store information about a user logging in with a third party login provider app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // 取消注释以下行可允许使用第三方登录提供程序登录 //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process. app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Enables the application to remember the second login verification factor such as phone or email. // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from. // This is similar to the RememberMe option when you log in. app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() //{ // ClientId = "", // ClientSecret = "" //}); //SignalR GlobalHost.DependencyResolver.Register(typeof(IHubActivator), () => new UnityHubActivator(UnityConfig.GetConfiguredContainer())); //var config = new HubConfiguration {EnableJSONP = true}; //app.MapSignalR(config); app.MapSignalR(); }
// Para obtener más información para configurar la autenticación, visite http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Permitir que la aplicación use una cookie para almacenar información para el usuario que inicia sesión app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); // Use a cookie to temporarily store information about a user logging in with a third party login provider app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Quitar los comentarios de las siguientes líneas para habilitar el inicio de sesión con proveedores de inicio de sesión de terceros //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(); }
public void ConfigureOAuth(IAppBuilder app) { app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()); app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(30), Provider = new OAuthAuthorizationServerProvider { OnValidateClientAuthentication = async c=>c.Validated(), OnGrantResourceOwnerCredentials = async c => { using (var repo = new AuthRepository()) { var user = await repo.FindUser(c.UserName, c.Password); if (user == null) { c.Rejected(); throw new ApiException("User not existed or wrong password."); } } var identity = new ClaimsIdentity(c.Options.AuthenticationType); identity.AddClaims(new[] {new Claim(ClaimTypes.Name, c.UserName), new Claim(ClaimTypes.Role, "user")}); if (string.Equals(c.UserName, AppConfig.Manager, StringComparison.InvariantCultureIgnoreCase)) identity.AddClaims(new[] {new Claim(ClaimTypes.Name, c.UserName), new Claim(ClaimTypes.Role, "manager")}); c.Validated(identity); } }, }); }
private static void SetUpAuth(IAppBuilder appBuilder) { var listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"]; listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication; }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; }
public static IAppBuilder UseExtensionlessUrls(this IAppBuilder builder) { return(builder.UseExtensionlessUrls(new ExtensionlessUrlsOptions())); }
public void Configuration(IAppBuilder app) { app.Use <LoggerMiddleware>(); app.UseWelcomePage(); }
/// <summary>Addes the Swagger UI (only) to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="settings">The Swagger UI settings.</param> /// <returns>The app builder.</returns> public static IAppBuilder UseSwaggerReDoc( this IAppBuilder app, SwaggerReDocSettings settings) { return app.UseSwaggerReDoc(null, settings, null); }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); }
public void Configuration(IAppBuilder app) { }
public static void UseDoubleConfirmIdentity(this IAppBuilder app, DoubleConfirmIdentityOptions options) { app.Use(typeof(DoubleConfirmIdentityMiddleware), options); }
public void Configuration(IAppBuilder app) { StartupIdentity.Configure(app); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context, user manager and signin manager to use a single instance per request }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); CreateUserAndRoles(); }
public void Configuration(IAppBuilder app) { GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(30); app.UseCors(CorsOptions.AllowAll); app.MapSignalR(); }
public void Configuration(IAppBuilder appBuilder) { SetUpAuth(appBuilder); SetUpApi(appBuilder); SetUpUi(appBuilder); }
public void Configuration(IAppBuilder app) { app.UseNancy(options => options.Bootstrapper = new Bootstrapper()); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process. app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Enables the application to remember the second login verification factor such as phone or email. // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from. // This is similar to the RememberMe option when you log in. app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); var facebookOptions = new FacebookAuthenticationOptions() { AppId = "1139025256271388", AppSecret = "9bb6670361712d00c49412a067cfb740", BackchannelHttpHandler = new FaceBookBackChannelHandler(), UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,email" }; facebookOptions.Scope.Add("email"); app.UseFacebookAuthentication(facebookOptions); //app.UseFacebookAuthentication( // appId: "1139025256271388", // appSecret: "9bb6670361712d00c49412a067cfb740" // ); //Remaining app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() { ClientId = "207188986091-jadpa7vbkgqml6uhnnf04m4ib66qjeef.apps.googleusercontent.com", ClientSecret = "-cPBunMR1sh3Wi2BQl39nTM7" }); }
public void Configuration(IAppBuilder app) { AntiForgeryConfig.UniqueClaimTypeIdentifier = Constants.ClaimTypes.Subject; JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary <string, string>(); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" }); app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions { Authority = "https://localhost:44365/identity", Scope = "openid profile roles sampleApi", ClientId = "mvc", RedirectUri = "http://localhost:28545/", ResponseType = "id_token token", SignInAsAuthenticationType = "Cookies", UseTokenLifetime = false, Notifications = new OpenIdConnectAuthenticationNotifications { SecurityTokenValidated = n => { var id = n.AuthenticationTicket.Identity; // we want to keep first name, last name, subject and roles var givenName = id.FindFirst(Constants.ClaimTypes.GivenName); var familyName = id.FindFirst(Constants.ClaimTypes.FamilyName); var sub = id.FindFirst(Constants.ClaimTypes.Subject); var roles = id.FindAll(Constants.ClaimTypes.Role); // create new identity and set name and role claim type var nid = new ClaimsIdentity( id.AuthenticationType, Constants.ClaimTypes.GivenName, Constants.ClaimTypes.Role); nid.AddClaim(givenName); nid.AddClaim(familyName); nid.AddClaim(sub); nid.AddClaims(roles); // add some other app specific claim nid.AddClaim(new Claim("app_specific", "some data")); nid.AddClaim(new Claim("id_token", n.ProtocolMessage.IdToken)); n.AuthenticationTicket = new AuthenticationTicket( nid, n.AuthenticationTicket.Properties); return(Task.FromResult(0)); }, // 登出事件的處理 RedirectToIdentityProvider = n => { if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest) { var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token"); if (idTokenHint != null) { n.ProtocolMessage.IdTokenHint = idTokenHint.Value; } } return(Task.FromResult(0)); } } }); }
public void Configuration(IAppBuilder app) { // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=316888 app.MapSignalR(); }
public void Configuration(IAppBuilder app) { app.UseCors(CorsOptions.AllowAll); app.MapSignalR(); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { try { // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process. app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Enables the application to remember the second login verification factor such as phone or email. // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from. // This is similar to the RememberMe option when you log in. app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() //{ // ClientId = "", // ClientSecret = "" //}); #region api authentication OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(1), Provider = new ApiAuthorizationServerProvider() }; // Token Generation app.UseOAuthAuthorizationServer(OAuthServerOptions); app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()); app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); #endregion app.MapSignalR(); } catch (Exception ex) { Log.Error(ex); //throw; } }
public void Configuration(IAppBuilder app) { app.MapSignalR(); }
public static IAppBuilder UseServiceUnit(this IAppBuilder builder, ServiceUnitSettings settings, params IMiddlewareRegisterSetting[] middlewares) { //service unit request context の生成と保持 builder = builder.Use<ServiceUnitRequestMiddleware>(settings); return ApplyMiddlewares(builder, middlewares); }
public static void Configuration(IAppBuilder app) { app.MapSignalR <PersistentCommandController>("/api/commandstream"); app.MapSignalR("/api/filesystemhub", new HubConfiguration()); }
public void Configuration(IAppBuilder app) { ConfigureMobileApp(app); }
public static IAppBuilder UseServiceUnit(this IAppBuilder builder, params IMiddlewareRegisterSetting[] middlewares) { //service unit request context の生成と保持 return builder.UseServiceUnit(ServiceUnitSettings.Create(), middlewares); }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); app.MapSignalR(); }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); CreateRolesandUsers(); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { //app.CreatePerOwinContext<UserManager<User, int>>((id, ctx) => ctx.GetAutofacLifetimeScope().Resolve<UserManager<User, int>>()); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), // TODO: Figure out how to make this work Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <UserManager <User, int>, User, int>( validateInterval: TimeSpan.FromMinutes(0), regenerateIdentityCallback: (manager, user) => manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie), getUserIdCallback: id => id.GetUserId <int>()) /*, * OnApplyRedirect = context => * { * if (!IsAjaxRequest(context.Request)) * { * context.Response.Redirect(new Uri(context.RedirectUri).PathAndQuery); * } * } */ } }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process. app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Enables the application to remember the second login verification factor such as phone or email. // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from. // This is similar to the RememberMe option when you log in. app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() //{ // ClientId = "", // ClientSecret = "" //}); }
public void Configuration(IAppBuilder app) { var container = ConfigureAutofac(); ConfigureWebApi(app, container); }
// For more information on configuring authentication, please visit https://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context and user manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext <Data.Migrations.UserManager>(Data.Migrations.UserManager.Create); app.CreatePerOwinContext <ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider //app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Configure the application for OAuth based flow PublicClientId = "self"; OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/Token"), Provider = new ApplicationOAuthProvider(PublicClientId), AuthorizeEndpointPath = new PathString("/api/User/ExternalLogin"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), // In production mode set AllowInsecureHttp = false AllowInsecureHttp = true }; app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = OAuthDefaults.AuthenticationType, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <Data.Migrations.UserManager, User>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager, OAuthDefaults.AuthenticationType)) } }); // Enable the application to use bearer tokens to authenticate users app.UseOAuthBearerTokens(OAuthOptions); app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() //{ // ClientId = "", // ClientSecret = "" //}); }
private static void SetUpUi(IAppBuilder appBuilder) { appBuilder.UseFileServer("/web"); }