Skip to content

Commit 2ba6bf2

Browse files
authored
Merge pull request #13 from swiss-ssi-group/net9
.NET 9
2 parents b6654dc + 9b02591 commit 2ba6bf2

26 files changed

+230
-288
lines changed

.github/workflows/azure-deploy-issuer.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
1818
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples
1919

20-
name: Build and deploy IssuerDrivingLicense
20+
name: Deploy IssuerDrivingLicense
2121

2222
env:
2323
AZURE_WEBAPP_NAME: damienbodsharepointissuer # set this to the name of your Azure Web App
2424
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
25-
DOTNET_VERSION: '7.0' # set this to the .NET Core version to use
25+
DOTNET_VERSION: '9.0' # set this to the .NET Core version to use
2626

2727
on:
2828
push:
@@ -37,15 +37,15 @@ jobs:
3737
runs-on: ubuntu-latest
3838

3939
steps:
40-
- uses: actions/checkout@v3
40+
- uses: actions/checkout@v4
4141

4242
- name: Set up .NET Core
43-
uses: actions/setup-dotnet@v2
43+
uses: actions/setup-dotnet@v4
4444
with:
4545
dotnet-version: ${{ env.DOTNET_VERSION }}
4646

4747
- name: Set up dependency caching for faster builds
48-
uses: actions/cache@v3
48+
uses: actions/cache@v4
4949
with:
5050
path: ~/.nuget/packages
5151
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@@ -59,7 +59,7 @@ jobs:
5959
run: dotnet publish ./IssuerDrivingLicense/IssuerDrivingLicense.csproj -c Release -o ${{env.DOTNET_ROOT}}/issuerpackage
6060

6161
- name: Upload artifact for deployment job
62-
uses: actions/upload-artifact@v3
62+
uses: actions/upload-artifact@v4
6363
with:
6464
name: .net-app
6565
path: ${{env.DOTNET_ROOT}}/issuerpackage
@@ -75,7 +75,7 @@ jobs:
7575

7676
steps:
7777
- name: Download artifact from build job
78-
uses: actions/download-artifact@v3
78+
uses: actions/download-artifact@v4
7979
with:
8080
name: .net-app
8181

.github/workflows/azure-deploy-verifier.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
1818
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples
1919

20-
name: Build and deploy VerifierInsuranceCompany
20+
name: Deploy VerifierInsuranceCompany
2121

2222
env:
2323
AZURE_WEBAPP_NAME: damienbodsharepointverifier # set this to the name of your Azure Web App
2424
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
25-
DOTNET_VERSION: '7.0' # set this to the .NET Core version to use
25+
DOTNET_VERSION: '9.0' # set this to the .NET Core version to use
2626

2727
on:
2828
push:
@@ -37,15 +37,15 @@ jobs:
3737
runs-on: ubuntu-latest
3838

3939
steps:
40-
- uses: actions/checkout@v3
40+
- uses: actions/checkout@v4
4141

4242
- name: Set up .NET Core
43-
uses: actions/setup-dotnet@v2
43+
uses: actions/setup-dotnet@v4
4444
with:
4545
dotnet-version: ${{ env.DOTNET_VERSION }}
4646

4747
- name: Set up dependency caching for faster builds
48-
uses: actions/cache@v3
48+
uses: actions/cache@v4
4949
with:
5050
path: ~/.nuget/packages
5151
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@@ -59,7 +59,7 @@ jobs:
5959
run: dotnet publish ./VerifierInsuranceCompany/VerifierInsuranceCompany.csproj -c Release -o ${{env.DOTNET_ROOT}}/verifierpackage
6060

6161
- name: Upload artifact for deployment job
62-
uses: actions/upload-artifact@v3
62+
uses: actions/upload-artifact@v4
6363
with:
6464
name: .net-app
6565
path: ${{env.DOTNET_ROOT}}/verifierpackage
@@ -75,7 +75,7 @@ jobs:
7575

7676
steps:
7777
- name: Download artifact from build job
78-
uses: actions/download-artifact@v3
78+
uses: actions/download-artifact@v4
7979
with:
8080
name: .net-app
8181

.github/workflows/dotnet.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Setup .NET
17-
uses: actions/setup-dotnet@v2
17+
uses: actions/setup-dotnet@v4
1818
with:
19-
dotnet-version: '7.0'
19+
dotnet-version: '9.0'
2020
include-prerelease: True
2121
- name: Restore dependencies
2222
run: dotnet restore
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<UserSecretsId>aspnet-IssuerDrivingLicense-825A2CCD-D7A7-4681-8552-A73D569859BF</UserSecretsId>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" NoWarn="NU1605" />
12-
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.9" NoWarn="NU1605" />
13-
<PackageReference Include="Microsoft.Identity.Web" Version="2.13.1" />
14-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.13.1" />
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
11+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" NoWarn="NU1605" />
12+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.0" NoWarn="NU1605" />
13+
<PackageReference Include="Microsoft.Identity.Web" Version="3.5.0" />
14+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="3.5.0" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>
20-
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
20+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
2121

22-
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.9" />
23-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.8" />
24-
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="0.20.0" />
25-
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders.TagHelpers" Version="0.20.0" />
22+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="9.0.0" />
23+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
24+
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="1.0.0-preview.2" />
25+
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders.TagHelpers" Version="1.0.0-preview.2" />
2626
</ItemGroup>
2727

2828
</Project>

IssuerDrivingLicense/Migrations/20211015070446_init.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using Microsoft.EntityFrameworkCore.Migrations;
32

43
#nullable disable

IssuerDrivingLicense/Migrations/20230623080507_update-scheme.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using Microsoft.EntityFrameworkCore.Migrations;
1+
using Microsoft.EntityFrameworkCore.Migrations;
32

43
#nullable disable
54

IssuerDrivingLicense/Pages/Admin.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
using IssuerDrivingLicense.Persistence;
12
using Microsoft.AspNetCore.Mvc.RazorPages;
23
using Microsoft.EntityFrameworkCore;
3-
using IssuerDrivingLicense.Persistence;
44

55
namespace IssuerDrivingLicense;
66

IssuerDrivingLicense/Pages/DriverLicenses/Create.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public async Task<IActionResult> OnPostAsync()
5050
// TODO add other properties as needed
5151

5252
_context.DriverLicenses.Add(DriverLicense);
53-
await _context.SaveChangesAsync();
53+
await _context.SaveChangesAsync();
5454

5555
return RedirectToPage("./User", new { id = DriverLicense.UserName });
5656
}

IssuerDrivingLicense/Pages/DriverLicenses/Details.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
using IssuerDrivingLicense.Persistence;
12
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.AspNetCore.Mvc.RazorPages;
34
using Microsoft.EntityFrameworkCore;
4-
using IssuerDrivingLicense.Persistence;
55

66
namespace IssuerDrivingLicense.Pages.DriverLicenses;
77

IssuerDrivingLicense/Pages/DriverLicenses/Edit.cshtml.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using IssuerDrivingLicense.Persistence;
2+
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.AspNetCore.Mvc.RazorPages;
34
using Microsoft.EntityFrameworkCore;
4-
using IssuerDrivingLicense.Persistence;
55

66
namespace IssuerDrivingLicense.Pages.DriverLicenses;
77

@@ -53,7 +53,7 @@ public async Task<IActionResult> OnPostAsync()
5353
if (DriverLicense != null)
5454
{
5555
var existingDriverLicense = await _context.DriverLicenses.FirstOrDefaultAsync(m => m.Id == DriverLicense.Id);
56-
56+
5757
if (existingDriverLicense == null)
5858
return NotFound();
5959

IssuerDrivingLicense/Pages/DriverLicenses/User.cshtml.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using IssuerDrivingLicense.Persistence;
2+
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.AspNetCore.Mvc.RazorPages;
34
using Microsoft.EntityFrameworkCore;
4-
using IssuerDrivingLicense.Persistence;
55

66
namespace IssuerDrivingLicense.Pages.DriverLicenses;
77

IssuerDrivingLicense/Pages/Error.cshtml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
using System.Diagnostics;
12
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.AspNetCore.Mvc.RazorPages;
3-
using System.Diagnostics;
44

55
namespace IssuerDrivingLicense.Pages;
66

IssuerDrivingLicense/Program.cs

+75-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,78 @@
1-
namespace IssuerDrivingLicense;
1+
using System.Configuration;
2+
using IssuerDrivingLicense;
3+
using IssuerDrivingLicense.Persistence;
4+
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
5+
using Microsoft.AspNetCore.Server.Kestrel.Core;
6+
using Microsoft.EntityFrameworkCore;
7+
using Microsoft.Identity.Web.UI;
8+
using Microsoft.Identity.Web;
29

3-
public class Program
10+
var builder = WebApplication.CreateBuilder(args);
11+
12+
builder.WebHost.ConfigureKestrel(serverOptions =>
13+
{
14+
serverOptions.AddServerHeader = false;
15+
});
16+
17+
var services = builder.Services;
18+
var configuration = builder.Configuration;
19+
20+
services.Configure<KestrelServerOptions>(options =>
21+
{
22+
options.AllowSynchronousIO = true;
23+
});
24+
25+
services.AddSecurityHeaderPolicies()
26+
.SetPolicySelector(ctx => SecurityHeadersDefinitions
27+
.GetHeaderPolicyCollection(builder.Environment.IsDevelopment()));
28+
29+
services.Configure<CredentialSettings>(configuration.GetSection("CredentialSettings"));
30+
services.AddScoped<DriverLicenseService>();
31+
services.AddScoped<IssuerService>();
32+
33+
services.AddDatabaseDeveloperPageExceptionFilter();
34+
services.AddDbContext<DrivingLicenseDbContext>(options =>
35+
options.UseSqlServer(
36+
configuration.GetConnectionString("DefaultConnection")));
37+
38+
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
39+
.AddMicrosoftIdentityWebApp(configuration.GetSection("AzureAd"));
40+
41+
services.AddAuthorization(options =>
42+
{
43+
options.FallbackPolicy = options.DefaultPolicy;
44+
});
45+
46+
services.AddDistributedMemoryCache();
47+
48+
services.AddRazorPages()
49+
.AddMvcOptions(options => { })
50+
.AddMicrosoftIdentityUI();
51+
52+
services.AddRazorPages();
53+
54+
var app = builder.Build();
55+
56+
app.UseSecurityHeaders();
57+
58+
if (app.Environment.IsDevelopment())
59+
{
60+
app.UseDeveloperExceptionPage();
61+
}
62+
else
463
{
5-
public static void Main(string[] args)
6-
{
7-
CreateHostBuilder(args).Build().Run();
8-
}
9-
10-
public static IHostBuilder CreateHostBuilder(string[] args) =>
11-
Host.CreateDefaultBuilder(args)
12-
.ConfigureWebHostDefaults(webBuilder =>
13-
{
14-
webBuilder
15-
.ConfigureKestrel(options => options.AddServerHeader = false)
16-
.UseStartup<Startup>();
17-
});
64+
app.UseExceptionHandler("/Error");
1865
}
66+
67+
app.UseHttpsRedirection();
68+
app.UseStaticFiles();
69+
70+
app.UseRouting();
71+
72+
app.UseAuthentication();
73+
app.UseAuthorization();
74+
75+
app.MapRazorPages();
76+
app.MapControllers();
77+
78+
app.Run();

0 commit comments

Comments
 (0)