/// <summary> /// Adds <see cref="SteamAuthenticationMiddleware"/> to the specified /// <see cref="IApplicationBuilder"/>, which enables Steam authentication capabilities. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/>.</param> /// <param name="options">The <see cref="SteamAuthenticationOptions"/> used to configure the Steam options.</param> /// <returns>The <see cref="IApplicationBuilder"/>.</returns> public static IApplicationBuilder UseSteamAuthentication( [NotNull] this IApplicationBuilder app, [NotNull] SteamAuthenticationOptions options) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return(app.UseMiddleware <SteamAuthenticationMiddleware>(Options.Create(options))); }
/// <summary> /// Adds <see cref="SteamAuthenticationMiddleware"/> to the specified /// <see cref="IApplicationBuilder"/>, which enables Steam authentication capabilities. /// </summary> /// <param name="app">The <see cref="IApplicationBuilder"/>.</param> /// <param name="configuration">The delegate used to configure the Steam options.</param> /// <returns>The <see cref="IApplicationBuilder"/>.</returns> public static IApplicationBuilder UseSteamAuthentication( [NotNull] this IApplicationBuilder app, [NotNull] Action <SteamAuthenticationOptions> configuration) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var options = new SteamAuthenticationOptions(); configuration(options); return(app.UseMiddleware <SteamAuthenticationMiddleware>(Options.Create(options))); }
public async Task <IActionResult> Test() { StringBuilder sb = new StringBuilder(); var user = await this.userManager.GetUserAsync(this.User); var steamAuthenticationOptions = new SteamAuthenticationOptions(); var item1 = steamAuthenticationOptions.ApplicationKey; var item2 = steamAuthenticationOptions.UserInformationEndpoint.FirstOrDefault().ToString(); var item3 = steamAuthenticationOptions.UserInformationEndpoint; var item4 = SteamAuthenticationConstants.Parameters.Name; var item5 = SteamAuthenticationConstants.Parameters.SteamId; string cloneLine = "ASD2"; string line = "ASD1"; //var item6 = SteamAuthenticationConstants.Parameters.Key; //var item7 = SteamAuthenticationConstants.Parameters.Players; //var item8 = SteamAuthenticationConstants.Parameters.Response; //var item9 = SteamAuthenticationConstants.Namespaces.Identifier; //var item10 = SteamAuthenticationConstants.Namespaces.LegacyIdentifier; // //var item11 = SteamAuthenticationDefaults.UserInformationEndpoint; //var item12 = SteamAuthenticationDefaults.Authority; //var item13 = SteamAuthenticationDefaults.DisplayName; //var item14 = SteamAuthenticationDefaults.AuthenticationScheme; //var item15 = SteamAuthenticationDefaults.CallbackPath; foreach (var item in item5) { var asd = item; } var info1 = this.userManager.GetUserAsync(this.User); return(this.View()); }
public void Configuration(IAppBuilder app) { app.SetDefaultSignInAsAuthenticationType("ExternalCookie"); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "ExternalCookie", AuthenticationMode = AuthenticationMode.Passive, CookieName = ".AspNet.ExternalCookie", ExpireTimeSpan = TimeSpan.FromMinutes(5) }); var webconfig = WebConfigurationManager.OpenWebConfiguration("~/"); var key = webconfig.AppSettings.Settings["apiKey"].Value; var options = new SteamAuthenticationOptions { ApplicationKey = key }; app.UseSteamAuthentication(options); }
// 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); // Steam Key var options = new SteamAuthenticationOptions { ApplicationKey = "AF8461EDF5817463B5E69E013DBF84AB", CallbackPath = new PathString("/oauth-redirect/steam") }; app.UseSteamAuthentication(options); // 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 = "" //}); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseIdentity(); app.UseCookieAuthentication(new CookieAuthenticationOptions() { AutomaticAuthenticate = true, CookieName = "MyApp", CookieSecure = CookieSecurePolicy.Always, AuthenticationScheme = "Cookies" }); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary <string, string>(); //TODO Facebook //app.UseFacebookAuthentication( new FacebookOptions() { // AppId = Configuration[ "Authentication:Facebook:AppId" ], // AppSecret = Configuration[ "Authentication:Facebook:AppSecret" ] //} ); //TODO byta till identityserver4 ? //STEAM OPTIONS var options = new SteamAuthenticationOptions { ApplicationKey = "1678D429F67B9AC88EC696082AFE5F06", CallbackPath = new PathString("/LoginSteam"), Events = new OpenIdAuthenticationEvents { OnAuthenticated = context => { var identity = context.Ticket.Principal.Identity as ClaimsIdentity; var subject = identity.Claims.FirstOrDefault(z => z.Type.Contains("nameidentifier")); // var newIdentity = new ClaimsIdentity( //context.Ticket.AuthenticationScheme, //"given_name", //"role" ); // context.Ticket = new AuthenticationTicket( // new ClaimsPrincipal( newIdentity ), // context.Ticket.Properties, // context.Ticket.AuthenticationScheme ); //string role; //if( context.Attributes.TryGetValue( "role", out role ) ) { // context.Identity.AddClaim( new Claim( ClaimTypes.Role, role ) ); //} return(Task.FromResult(0)); } } }; app.UseSteamAuthentication(options); // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }