diff --git a/IdentityServer/v7/SessionManagement/.vscode/launch.json b/IdentityServer/v7/SessionManagement/.vscode/launch.json
new file mode 100644
index 00000000..b9b67c9e
--- /dev/null
+++ b/IdentityServer/v7/SessionManagement/.vscode/launch.json
@@ -0,0 +1,53 @@
+{
+ "version": "0.2.0",
+ "compounds": [
+ {
+ "name": "Run All",
+ "configurations": ["IdentityServer", "Api", "Client"],
+ "presentation": {
+ "group": "10-compunds",
+ }
+ }
+ ],
+ "configurations": [
+ {
+ "name": "IdentityServer",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build-identityserver",
+ "program": "${workspaceFolder}/IdentityServer/bin/Debug/net8.0/IdentityServer.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/IdentityServer",
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "console": "externalTerminal",
+ },
+ {
+ "name": "Api",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build-api",
+ "program": "${workspaceFolder}/Api/bin/Debug/net8.0/Api.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/Api",
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "console": "externalTerminal",
+ },
+ {
+ "name": "Client",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build-client",
+ "program": "${workspaceFolder}/Client/bin/Debug/net8.0/Client.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/Client",
+ "console": "externalTerminal",
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ }
+ ]
+}
\ No newline at end of file
diff --git a/IdentityServer/v7/SessionManagement/.vscode/tasks.json b/IdentityServer/v7/SessionManagement/.vscode/tasks.json
new file mode 100644
index 00000000..22f4455a
--- /dev/null
+++ b/IdentityServer/v7/SessionManagement/.vscode/tasks.json
@@ -0,0 +1,53 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "type": "process",
+ "command": "dotnet",
+ "args": [
+ "build",
+ "${workspaceFolder}/SessionManagement.sln",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "build-identityserver",
+ "type": "process",
+ "command": "dotnet",
+ "args": [
+ "build",
+ "${workspaceFolder}/IdentityServer",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "build-api",
+ "type": "process",
+ "command": "dotnet",
+ "args": [
+ "build",
+ "${workspaceFolder}/Api",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "build-client",
+ "type": "process",
+ "command": "dotnet",
+ "args": [
+ "build",
+ "${workspaceFolder}/Client",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/IdentityServer/v7/SessionManagement/SimpleApi/ApiHost.csproj b/IdentityServer/v7/SessionManagement/Api/Api.csproj
similarity index 56%
rename from IdentityServer/v7/SessionManagement/SimpleApi/ApiHost.csproj
rename to IdentityServer/v7/SessionManagement/Api/Api.csproj
index 0cb2150b..f5df8837 100644
--- a/IdentityServer/v7/SessionManagement/SimpleApi/ApiHost.csproj
+++ b/IdentityServer/v7/SessionManagement/Api/Api.csproj
@@ -1,13 +1,12 @@
- net6.0
+ net8.0
-
-
-
+
+
\ No newline at end of file
diff --git a/IdentityServer/v7/SessionManagement/Api/IdentityController.cs b/IdentityServer/v7/SessionManagement/Api/IdentityController.cs
new file mode 100644
index 00000000..21183a40
--- /dev/null
+++ b/IdentityServer/v7/SessionManagement/Api/IdentityController.cs
@@ -0,0 +1,27 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using System.Linq;
+
+namespace Api;
+
+[Route("identity")]
+public class IdentityController : ControllerBase
+{
+ private readonly ILogger _logger;
+
+ public IdentityController(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ // this action simply echoes the claims back to the client
+ [HttpGet]
+ public ActionResult Get()
+ {
+ var claims = User.Claims.Select(c => new { c.Type, c.Value });
+ _logger.LogInformation("claims: {claims}", claims);
+
+ return new JsonResult(claims);
+ }
+}
\ No newline at end of file
diff --git a/IdentityServer/v7/SessionManagement/Api/Program.cs b/IdentityServer/v7/SessionManagement/Api/Program.cs
new file mode 100644
index 00000000..21d55ba3
--- /dev/null
+++ b/IdentityServer/v7/SessionManagement/Api/Program.cs
@@ -0,0 +1,36 @@
+using System;
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+using Serilog;
+using Serilog.Events;
+using Serilog.Sinks.SystemConsole.Themes;
+
+namespace Api;
+
+public class Program
+{
+ public static void Main(string[] args)
+ {
+ Console.Title = "API";
+
+ BuildWebHost(args).Run();
+ }
+
+ public static IHost BuildWebHost(string[] args)
+ {
+ Log.Logger = new LoggerConfiguration()
+ .MinimumLevel.Information()
+ .Enrich.FromLogContext()
+ .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)
+ .CreateLogger();
+
+ return Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup();
+ })
+ .UseSerilog()
+ .Build();
+ }
+}
\ No newline at end of file
diff --git a/IdentityServer/v7/SessionManagement/SimpleApi/Properties/launchSettings.json b/IdentityServer/v7/SessionManagement/Api/Properties/launchSettings.json
similarity index 100%
rename from IdentityServer/v7/SessionManagement/SimpleApi/Properties/launchSettings.json
rename to IdentityServer/v7/SessionManagement/Api/Properties/launchSettings.json
diff --git a/IdentityServer/v7/SessionManagement/Api/Startup.cs b/IdentityServer/v7/SessionManagement/Api/Startup.cs
new file mode 100644
index 00000000..d4fe098a
--- /dev/null
+++ b/IdentityServer/v7/SessionManagement/Api/Startup.cs
@@ -0,0 +1,40 @@
+using System.IdentityModel.Tokens.Jwt;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Api;
+
+public class Startup
+{
+ public Startup()
+ {
+ JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
+ }
+
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddControllers();
+
+ // this API will accept any access token from the authority
+ services.AddAuthentication("token")
+ .AddJwtBearer("token", options =>
+ {
+ options.Authority = "https://localhost:5001";
+ options.TokenValidationParameters.ValidateAudience = false;
+
+ options.TokenValidationParameters.ValidTypes = new[] { "at+jwt" };
+ });
+ }
+
+ public void Configure(IApplicationBuilder app)
+ {
+ app.UseRouting();
+ app.UseAuthentication();
+ app.UseAuthorization();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllers().RequireAuthorization();
+ });
+ }
+}
\ No newline at end of file
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/BackChannelClient.csproj b/IdentityServer/v7/SessionManagement/Client/Client.csproj
similarity index 56%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/BackChannelClient.csproj
rename to IdentityServer/v7/SessionManagement/Client/Client.csproj
index c2fbd4a1..19ff4268 100644
--- a/IdentityServer/v7/SessionManagement/BackChannelClient/BackChannelClient.csproj
+++ b/IdentityServer/v7/SessionManagement/Client/Client.csproj
@@ -1,14 +1,14 @@
- net6.0
+ net8.0
-
+
-
+
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Controllers/HomeController.cs b/IdentityServer/v7/SessionManagement/Client/Controllers/HomeController.cs
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Controllers/HomeController.cs
rename to IdentityServer/v7/SessionManagement/Client/Controllers/HomeController.cs
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Controllers/LogoutController.cs b/IdentityServer/v7/SessionManagement/Client/Controllers/LogoutController.cs
similarity index 95%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Controllers/LogoutController.cs
rename to IdentityServer/v7/SessionManagement/Client/Controllers/LogoutController.cs
index 281750d1..1e211e0a 100644
--- a/IdentityServer/v7/SessionManagement/BackChannelClient/Controllers/LogoutController.cs
+++ b/IdentityServer/v7/SessionManagement/Client/Controllers/LogoutController.cs
@@ -1,6 +1,7 @@
using IdentityModel;
using IdentityModel.Client;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using System;
@@ -26,8 +27,8 @@ public LogoutController(LogoutSessionManager logoutSessions)
[AllowAnonymous]
public async Task Index(string logout_token)
{
- Response.Headers.Add("Cache-Control", "no-cache, no-store");
- Response.Headers.Add("Pragma", "no-cache");
+ Response.Headers.Append("Cache-Control", "no-cache, no-store");
+ Response.Headers.Append("Pragma", "no-cache");
try
{
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/CookieEventHandler.cs b/IdentityServer/v7/SessionManagement/Client/CookieEventHandler.cs
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/CookieEventHandler.cs
rename to IdentityServer/v7/SessionManagement/Client/CookieEventHandler.cs
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/LogoutSessionManager.cs b/IdentityServer/v7/SessionManagement/Client/LogoutSessionManager.cs
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/LogoutSessionManager.cs
rename to IdentityServer/v7/SessionManagement/Client/LogoutSessionManager.cs
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Program.cs b/IdentityServer/v7/SessionManagement/Client/Program.cs
similarity index 90%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Program.cs
rename to IdentityServer/v7/SessionManagement/Client/Program.cs
index 8561404f..86ebddf7 100644
--- a/IdentityServer/v7/SessionManagement/BackChannelClient/Program.cs
+++ b/IdentityServer/v7/SessionManagement/Client/Program.cs
@@ -1,3 +1,4 @@
+using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
@@ -7,6 +8,8 @@ public class Program
{
public static void Main(string[] args)
{
+ Console.Title = "Client";
+
CreateHostBuilder(args).Build().Run();
}
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Properties/launchSettings.json b/IdentityServer/v7/SessionManagement/Client/Properties/launchSettings.json
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Properties/launchSettings.json
rename to IdentityServer/v7/SessionManagement/Client/Properties/launchSettings.json
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Startup.cs b/IdentityServer/v7/SessionManagement/Client/Startup.cs
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Startup.cs
rename to IdentityServer/v7/SessionManagement/Client/Startup.cs
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Views/Home/CallApi.cshtml b/IdentityServer/v7/SessionManagement/Client/Views/Home/CallApi.cshtml
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Views/Home/CallApi.cshtml
rename to IdentityServer/v7/SessionManagement/Client/Views/Home/CallApi.cshtml
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Views/Home/Index.cshtml b/IdentityServer/v7/SessionManagement/Client/Views/Home/Index.cshtml
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Views/Home/Index.cshtml
rename to IdentityServer/v7/SessionManagement/Client/Views/Home/Index.cshtml
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Views/Home/Secure.cshtml b/IdentityServer/v7/SessionManagement/Client/Views/Home/Secure.cshtml
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Views/Home/Secure.cshtml
rename to IdentityServer/v7/SessionManagement/Client/Views/Home/Secure.cshtml
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Views/Shared/Error.cshtml b/IdentityServer/v7/SessionManagement/Client/Views/Shared/Error.cshtml
similarity index 100%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Views/Shared/Error.cshtml
rename to IdentityServer/v7/SessionManagement/Client/Views/Shared/Error.cshtml
diff --git a/IdentityServer/v7/SessionManagement/BackChannelClient/Views/Shared/_Layout.cshtml b/IdentityServer/v7/SessionManagement/Client/Views/Shared/_Layout.cshtml
similarity index 94%
rename from IdentityServer/v7/SessionManagement/BackChannelClient/Views/Shared/_Layout.cshtml
rename to IdentityServer/v7/SessionManagement/Client/Views/Shared/_Layout.cshtml
index 42e5c24b..58c42abe 100644
--- a/IdentityServer/v7/SessionManagement/BackChannelClient/Views/Shared/_Layout.cshtml
+++ b/IdentityServer/v7/SessionManagement/Client/Views/Shared/_Layout.cshtml
@@ -3,7 +3,7 @@
- @ViewData["Title"] - MvcCode
+ @ViewData["Title"] - Session Management
@@ -11,7 +11,7 @@