public static IApplicationBuilder UseBattleNetAuthentication( [NotNull] this IApplicationBuilder app, [NotNull] Action <BattleNetAuthenticationOptions> configuration) { var options = new BattleNetAuthenticationOptions(); configuration(options); return(app.UseMiddleware <BattleNetAuthenticationMiddleware>(options)); }
/// <summary> /// Adds the <see cref="BattleNetAuthenticationMiddleware"/> middleware to the specified /// <see cref="IApplicationBuilder"/>, which enables Battle.net authentication capabilities. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/> to add the middleware to.</param> /// <param name="options">A <see cref="BattleNetAuthenticationOptions"/> that specifies options for the middleware.</param> /// <returns>A reference to this instance after the operation has completed.</returns> public static IApplicationBuilder UseBattleNetAuthentication( [NotNull] this IApplicationBuilder app, [NotNull] BattleNetAuthenticationOptions options) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return(app.UseMiddleware <BattleNetAuthenticationMiddleware>(Options.Create(options))); }
public void Configuration(IAppBuilder app) { System.Web.Helpers.AntiForgeryConfig.UniqueClaimTypeIdentifier = System.Security.Claims.ClaimsIdentity.DefaultNameClaimType; //var hubConfiguration = new HubConfiguration(); //app.MapSignalR(hubConfiguration); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Login"), Provider = new CookieAuthenticationProvider() { OnApplyRedirect = ctx => { if (!IsApiRequest(ctx.Request)) { ctx.Response.Redirect(ctx.RedirectUri); } } } }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); //var options = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions() //{ // AppId = "473122666380977", // AppSecret = "01e5097c01532011e8826581a26c8f54", // BackchannelHttpHandler = new HttpClientHandler(), //}; //options.Fields.Add("email"); //options.Scope.Add("email"); //app.UseFacebookAuthentication(options); var options = new BattleNetAuthenticationOptions() { ClientId = WebConfigurationManager.AppSettings["BattleNetKey"], ClientSecret = WebConfigurationManager.AppSettings["BattleNetSecret"], //BackchannelHttpHandler = new HttpClientHandler(), }; options.Scope.Clear(); app.UseBattleNetAuthentication(options); }
/// <summary> /// Adds the <see cref="BattleNetAuthenticationMiddleware"/> middleware to the specified /// <see cref="IApplicationBuilder"/>, which enables Battle.net authentication capabilities. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/> to add the middleware to.</param> /// <param name="configuration">An action delegate to configure the provided <see cref="BattleNetAuthenticationOptions"/>.</param> /// <returns>A reference to this instance after the operation has completed.</returns> public static IApplicationBuilder UseBattleNetAuthentication( [NotNull] this IApplicationBuilder app, [NotNull] Action <BattleNetAuthenticationOptions> configuration) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var options = new BattleNetAuthenticationOptions(); configuration(options); return(app.UseMiddleware <BattleNetAuthenticationMiddleware>(Options.Create(options))); }
public static IApplicationBuilder UseBattleNetAuthentication( [NotNull] this IApplicationBuilder app, [NotNull] BattleNetAuthenticationOptions options) { return(app.UseMiddleware <BattleNetAuthenticationMiddleware>(options)); }
// 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(BellumGensDbContext.Create); app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext <ApplicationRoleManager>(ApplicationRoleManager.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() { ExpireTimeSpan = TimeSpan.FromDays(30), CookieSameSite = SameSiteMode.None, CookieSecure = CookieSecureOption.SameAsRequest }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Configure the application for OAuth based flow PublicClientId = "bellum-gens-api"; OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/Token"), Provider = new ApplicationOAuthProvider(PublicClientId), AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), AllowInsecureHttp = allowInsecureHttp }; // Enable the application to use bearer tokens to authenticate users app.UseOAuthBearerTokens(OAuthOptions); app.UseSteamAuthentication(AppInfo.Config.steamApiKey); var battleNetAuthOptions = new BattleNetAuthenticationOptions() { ClientId = AppInfo.Config.battleNetClientId, ClientSecret = AppInfo.Config.battleNetClientSecret, Region = Region.Europe }; battleNetAuthOptions.Scope.Clear(); battleNetAuthOptions.Scope.Add("sc2.profile"); // battleNetAuthOptions.CallbackPath = new PathString("/signin-battlenet"); app.UseBattleNetAuthentication(battleNetAuthOptions); var twitchAuthOptions = new TwitchAuthenticationOptions() { ClientId = AppInfo.Config.twitchClientId, ClientSecret = AppInfo.Config.twitchSecret }; app.UseTwitchAuthentication(twitchAuthOptions); // 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 = "" //}); }