Skip to content

Commit

Permalink
Update sample apis to .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdecock committed Nov 30, 2023
1 parent e31c1eb commit f1fa630
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 104 deletions.
41 changes: 0 additions & 41 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,47 +93,6 @@
"order": 40
}
},
{
"name": "JS3",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-js3",
"program": "${workspaceFolder}/samples/JS3/bin/Debug/net6.0/JS3.dll",
"args": [],
"cwd": "${workspaceFolder}/samples/JS3",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"presentation": {
"hidden": false,
"order": 10
}
},

{
"name": "JS5",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-js5",
"program": "${workspaceFolder}/samples/JS5/bin/Debug/net6.0/JS5.dll",
"args": [],
"cwd": "${workspaceFolder}/samples/JS5",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"presentation": {
"hidden": false,
"order": 10
}
},
{
"name": "JS6",
"type": "coreclr",
Expand Down
24 changes: 0 additions & 24 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,6 @@
],
"problemMatcher": "$msCompile"
},
{
"label": "build-js3",
"type": "process",
"command": "dotnet",
"args": [
"build",
"${workspaceFolder}/samples/JS3/JS3.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "build-js5",
"type": "process",
"command": "dotnet",
"args": [
"build",
"${workspaceFolder}/samples/JS5/JS5.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "build-js6",
"type": "process",
Expand Down
4 changes: 2 additions & 2 deletions migrations/UserSessionDb/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
},
"UserSessionDb": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
6 changes: 3 additions & 3 deletions samples/Api.DPoP/Api.DPoP.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="IdentityModel" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.9" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion samples/Api.DPoP/DPoP/DPoPJwtBearerEvents.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using IdentityModel;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using System.Text;
Expand Down Expand Up @@ -130,7 +131,7 @@ public override Task Challenge(JwtBearerChallengeContext context)
}
}

context.Response.Headers.Add(HeaderNames.WWWAuthenticate, sb.ToString());
context.Response.Headers.Append(HeaderNames.WWWAuthenticate, sb.ToString());


if (context.HttpContext.Items.ContainsKey("DPoP-Nonce"))
Expand Down
10 changes: 4 additions & 6 deletions samples/Api.DPoP/DPoP/DPoPProofValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected virtual Task ValidateHeaderAsync(DPoPProofValidatonContext context, DP
/// <summary>
/// Validates the signature.
/// </summary>
protected virtual Task ValidateSignatureAsync(DPoPProofValidatonContext context, DPoPProofValidatonResult result)
protected virtual async Task ValidateSignatureAsync(DPoPProofValidatonContext context, DPoPProofValidatonResult result)
{
TokenValidationResult tokenValidationResult;

Expand All @@ -185,27 +185,25 @@ protected virtual Task ValidateSignatureAsync(DPoPProofValidatonContext context,
};

var handler = new JsonWebTokenHandler();
tokenValidationResult = handler.ValidateToken(context.ProofToken, tvp);
tokenValidationResult = await handler.ValidateTokenAsync(context.ProofToken, tvp);
}
catch (Exception ex)
{
Logger.LogDebug("Error parsing DPoP token: {error}", ex.Message);
result.IsError = true;
result.ErrorDescription = "Invalid signature on DPoP token.";
return Task.CompletedTask;
return;
}

if (tokenValidationResult.Exception != null)
{
Logger.LogDebug("Error parsing DPoP token: {error}", tokenValidationResult.Exception.Message);
result.IsError = true;
result.ErrorDescription = "Invalid signature on DPoP token.";
return Task.CompletedTask;
return;
}

result.Payload = tokenValidationResult.Claims;

return Task.CompletedTask;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion samples/Api.DPoP/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Api": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5011",
"environmentVariables": {
Expand Down
6 changes: 3 additions & 3 deletions samples/Api.Isolated/Api.Isolated.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="IdentityModel" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.9" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion samples/Api.Isolated/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Api": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5012",
"environmentVariables": {
Expand Down
6 changes: 3 additions & 3 deletions samples/Api/Api.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="IdentityModel" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.9" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion samples/Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Api": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:5010",
"environmentVariables": {
Expand Down
25 changes: 21 additions & 4 deletions samples/IdentityServer/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,32 @@ public static class Config
},

RedirectUris = { "https://localhost:5002/signin-oidc" },

//FrontChannelLogoutUri = "https://localhost:5002/signout-oidc",
BackChannelLogoutUri = "https://localhost:5002/bff/backchannel",

FrontChannelLogoutUri = "https://localhost:5002/signout-oidc",
PostLogoutRedirectUris = { "https://localhost:5002/signout-callback-oidc" },

AllowOfflineAccess = true,
AllowedScopes = { "openid", "profile", "api", "scope-for-isolated-api" },
},

new Client
{
ClientId = "backchannel-spa",
ClientSecrets = { new Secret("secret".Sha256()) },

AllowedGrantTypes =
{
GrantType.AuthorizationCode,
GrantType.ClientCredentials,
OidcConstants.GrantTypes.TokenExchange
},

RedirectUris = { "https://localhost:5003/signin-oidc" },
BackChannelLogoutUri = "https://localhost:5003/bff/backchannel",
PostLogoutRedirectUris = { "https://localhost:5003/signout-callback-oidc" },

AllowOfflineAccess = true,
AllowedScopes = { "openid", "profile", "api", "scope-for-isolated-api" },
},
};
}
}
4 changes: 2 additions & 2 deletions samples/JS.Yarp/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"profiles": {
"Host5": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
4 changes: 2 additions & 2 deletions samples/JS6.DPoP/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"profiles": {
"Host6": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
4 changes: 2 additions & 2 deletions samples/JS6.EF/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"profiles": {
"Host5.EntityFramework": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
2 changes: 1 addition & 1 deletion samples/JS6.EF/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void ConfigureServices(IServiceCollection services)
options.Authority = "https://localhost:5001";

// confidential client using code flow + PKCE
options.ClientId = "spa";
options.ClientId = "backchannel-spa";
options.ClientSecret = "secret";
options.ResponseType = "code";
options.ResponseMode = "query";
Expand Down
4 changes: 2 additions & 2 deletions samples/JS6/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"profiles": {
"Host6": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
4 changes: 2 additions & 2 deletions samples/JS8.DPoP/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"profiles": {
"Host6": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
4 changes: 2 additions & 2 deletions samples/JS8.EF/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"profiles": {
"Host8.EntityFramework": {
"commandName": "Project",
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5002",
"applicationUrl": "https://localhost:5003",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
2 changes: 1 addition & 1 deletion samples/JS8.EF/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void ConfigureServices(IServiceCollection services)
options.Authority = "https://localhost:5001";

// confidential client using code flow + PKCE
options.ClientId = "spa";
options.ClientId = "backchannel-spa";
options.ClientSecret = "secret";
options.ResponseType = "code";
options.ResponseMode = "query";
Expand Down

0 comments on commit f1fa630

Please sign in to comment.