From f59570acaecf2422001310a1d312565e8c61f263 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Mon, 7 Feb 2022 23:15:45 +0100 Subject: fix: Don't use github as default challenge scheme as this results in a 302 to github by default when auth is required --- src/server/Startup.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/server') diff --git a/src/server/Startup.cs b/src/server/Startup.cs index aa07f33..8156444 100644 --- a/src/server/Startup.cs +++ b/src/server/Startup.cs @@ -1,5 +1,3 @@ -using AspNet.Security.OAuth.GitHub; - namespace IOL.BookmarkThing.Server; public class Startup @@ -15,7 +13,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDataProtection() - .PersistKeysToFileSystem(new(AppPaths.DataProtectionKeys.HostPath)); + .PersistKeysToFileSystem(new DirectoryInfo(AppPaths.DataProtectionKeys.HostPath)); StartupTasks.Execute(); @@ -52,7 +50,7 @@ public class Startup services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = GitHubAuthenticationDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie(options => { options.Cookie.Name = "bookmarkthing_session"; @@ -71,7 +69,6 @@ public class Startup options.ClientSecret = Configuration.GetValue("GH_CLIENT_SECRET"); options.ClientId = Configuration.GetValue("GH_CLIENT_ID"); options.SaveTokens = true; - options.ClaimActions.MapJsonKey(AppClaims.GITHUB_ID, "id"); options.CorrelationCookie = new CookieBuilder { Name = "gh_correlation", SameSite = SameSiteMode.Lax, @@ -132,7 +129,7 @@ public class Startup app.UseCors(x => x .AllowAnyMethod() .AllowAnyHeader() - .SetIsOriginAllowed(_ => true) // allow any origin + .WithOrigins("http://localhost:3000") .AllowCredentials()); // allow credentials } -- cgit v1.3