diff --git a/IdentityServer/v7/SessionMigration/.vscode/launch.json b/IdentityServer/v7/SessionMigration/.vscode/launch.json new file mode 100644 index 00000000..d95d6a7f --- /dev/null +++ b/IdentityServer/v7/SessionMigration/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "IdentityServer", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/net8.0/SessionMigration.dll", + "args": [], + "cwd": "${workspaceFolder}", + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "console": "externalTerminal", + } + ] +} \ No newline at end of file diff --git a/IdentityServer/v7/SessionMigration/.vscode/tasks.json b/IdentityServer/v7/SessionMigration/.vscode/tasks.json new file mode 100644 index 00000000..1c749f23 --- /dev/null +++ b/IdentityServer/v7/SessionMigration/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "process", + "command": "dotnet", + "args": [ + "build", + "${workspaceFolder}/SessionMigration.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/IdentityServer/v7/SessionMigration/HostingExtensions.cs b/IdentityServer/v7/SessionMigration/HostingExtensions.cs index 8103ac9f..04459e8a 100644 --- a/IdentityServer/v7/SessionMigration/HostingExtensions.cs +++ b/IdentityServer/v7/SessionMigration/HostingExtensions.cs @@ -32,7 +32,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde // ******************** // *** INSTRUCTIONS *** - // This purpose of this sample is to show how to migrate existing client side session to server + // The purpose of this sample is to show how to migrate existing client side session to server // side session without the user having to login again. To test it, first run the sample as is // and log in (user: alice, password: alice) to get a normal cookie based session in your // browser. Then uncomment the following blocks and run the sample again. The first request @@ -43,20 +43,19 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde // Note that if server side sessions have been enabled and then are removed before another // test run, you have to manually clear the cookie to be able to log in again. - // ** This is the normal template code for activating server side sessions. + // //** This is the normal template code for activating server side sessions. + // isBuilder.AddServerSideSessions(); - //isBuilder.AddServerSideSessions(); - - //builder.Services.AddAuthorization(options => + // builder.Services.AddAuthorization(options => // options.AddPolicy("admin", // policy => policy.RequireClaim("sub", "1")) // ); - //builder.Services.Configure(options => + // builder.Services.Configure(options => // options.Conventions.AuthorizeFolder("/ServerSideSessions", "admin")); - // ** This is the code that adds migration of sessions. Enabling server side sessions through the - // ** block above without enabling this will invalidate all existing sessions. - //builder.Services.AddTransient, SessionMigrationPostConfigureOptions>(); + // //** This is the code that adds migration of sessions. Enabling server side sessions through the + // //** block above without enabling this will invalidate all existing sessions. + // builder.Services.AddTransient, SessionMigrationPostConfigureOptions>(); return builder.Build(); } diff --git a/IdentityServer/v7/SessionMigration/Pages/SecurityHeadersAttribute.cs b/IdentityServer/v7/SessionMigration/Pages/SecurityHeadersAttribute.cs index 915c99c6..70134bfa 100644 --- a/IdentityServer/v7/SessionMigration/Pages/SecurityHeadersAttribute.cs +++ b/IdentityServer/v7/SessionMigration/Pages/SecurityHeadersAttribute.cs @@ -17,13 +17,13 @@ public override void OnResultExecuting(ResultExecutingContext context) // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options if (!context.HttpContext.Response.Headers.ContainsKey("X-Content-Type-Options")) { - context.HttpContext.Response.Headers.Add("X-Content-Type-Options", "nosniff"); + context.HttpContext.Response.Headers.Append("X-Content-Type-Options", "nosniff"); } // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options if (!context.HttpContext.Response.Headers.ContainsKey("X-Frame-Options")) { - context.HttpContext.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); + context.HttpContext.Response.Headers.Append("X-Frame-Options", "SAMEORIGIN"); } // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy @@ -36,19 +36,19 @@ public override void OnResultExecuting(ResultExecutingContext context) // once for standards compliant browsers if (!context.HttpContext.Response.Headers.ContainsKey("Content-Security-Policy")) { - context.HttpContext.Response.Headers.Add("Content-Security-Policy", csp); + context.HttpContext.Response.Headers.Append("Content-Security-Policy", csp); } // and once again for IE if (!context.HttpContext.Response.Headers.ContainsKey("X-Content-Security-Policy")) { - context.HttpContext.Response.Headers.Add("X-Content-Security-Policy", csp); + context.HttpContext.Response.Headers.Append("X-Content-Security-Policy", csp); } // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy var referrer_policy = "no-referrer"; if (!context.HttpContext.Response.Headers.ContainsKey("Referrer-Policy")) { - context.HttpContext.Response.Headers.Add("Referrer-Policy", referrer_policy); + context.HttpContext.Response.Headers.Append("Referrer-Policy", referrer_policy); } } } diff --git a/IdentityServer/v7/SessionMigration/SessionMigration.csproj b/IdentityServer/v7/SessionMigration/SessionMigration.csproj index 8e8abcfc..76a456eb 100644 --- a/IdentityServer/v7/SessionMigration/SessionMigration.csproj +++ b/IdentityServer/v7/SessionMigration/SessionMigration.csproj @@ -1,15 +1,15 @@  - net6.0 + net8.0 enable - + - - + +