Skip to content

Commit

Permalink
Merge pull request #13 from swiss-ssi-group/net9
Browse files Browse the repository at this point in the history
.NET 9
  • Loading branch information
damienbod authored Dec 15, 2024
2 parents b6654dc + 9b02591 commit 2ba6bf2
Show file tree
Hide file tree
Showing 26 changed files with 230 additions and 288 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/azure-deploy-issuer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples

name: Build and deploy IssuerDrivingLicense
name: Deploy IssuerDrivingLicense

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

on:
push:
Expand All @@ -37,15 +37,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

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

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/issuerpackage
Expand All @@ -75,7 +75,7 @@ jobs:

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: .net-app

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/azure-deploy-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples

name: Build and deploy VerifierInsuranceCompany
name: Deploy VerifierInsuranceCompany

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

on:
push:
Expand All @@ -37,15 +37,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

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

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/verifierpackage
Expand All @@ -75,7 +75,7 @@ jobs:

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: .net-app

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0'
dotnet-version: '9.0'
include-prerelease: True
- name: Restore dependencies
run: dotnet restore
Expand Down
24 changes: 12 additions & 12 deletions IssuerDrivingLicense/IssuerDrivingLicense.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-IssuerDrivingLicense-825A2CCD-D7A7-4681-8552-A73D569859BF</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.9" NoWarn="NU1605" />
<PackageReference Include="Microsoft.Identity.Web" Version="2.13.1" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.13.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.0" NoWarn="NU1605" />
<PackageReference Include="Microsoft.Identity.Web" Version="3.5.0" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="3.5.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />

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

</Project>
1 change: 0 additions & 1 deletion IssuerDrivingLicense/Migrations/20211015070446_init.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

Expand Down
2 changes: 1 addition & 1 deletion IssuerDrivingLicense/Pages/Admin.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using IssuerDrivingLicense.Persistence;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IssuerDrivingLicense.Persistence;

namespace IssuerDrivingLicense;

Expand Down
2 changes: 1 addition & 1 deletion IssuerDrivingLicense/Pages/DriverLicenses/Create.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task<IActionResult> OnPostAsync()
// TODO add other properties as needed

_context.DriverLicenses.Add(DriverLicense);
await _context.SaveChangesAsync();
await _context.SaveChangesAsync();

return RedirectToPage("./User", new { id = DriverLicense.UserName });
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using IssuerDrivingLicense.Persistence;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IssuerDrivingLicense.Persistence;

namespace IssuerDrivingLicense.Pages.DriverLicenses;

Expand Down
6 changes: 3 additions & 3 deletions IssuerDrivingLicense/Pages/DriverLicenses/Edit.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using IssuerDrivingLicense.Persistence;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IssuerDrivingLicense.Persistence;

namespace IssuerDrivingLicense.Pages.DriverLicenses;

Expand Down Expand Up @@ -53,7 +53,7 @@ public async Task<IActionResult> OnPostAsync()
if (DriverLicense != null)
{
var existingDriverLicense = await _context.DriverLicenses.FirstOrDefaultAsync(m => m.Id == DriverLicense.Id);

if (existingDriverLicense == null)
return NotFound();

Expand Down
4 changes: 2 additions & 2 deletions IssuerDrivingLicense/Pages/DriverLicenses/User.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using IssuerDrivingLicense.Persistence;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using IssuerDrivingLicense.Persistence;

namespace IssuerDrivingLicense.Pages.DriverLicenses;

Expand Down
2 changes: 1 addition & 1 deletion IssuerDrivingLicense/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace IssuerDrivingLicense.Pages;

Expand Down
90 changes: 75 additions & 15 deletions IssuerDrivingLicense/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,78 @@
namespace IssuerDrivingLicense;
using System.Configuration;
using IssuerDrivingLicense;
using IssuerDrivingLicense.Persistence;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.EntityFrameworkCore;
using Microsoft.Identity.Web.UI;
using Microsoft.Identity.Web;

public class Program
var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.AddServerHeader = false;
});

var services = builder.Services;
var configuration = builder.Configuration;

services.Configure<KestrelServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});

services.AddSecurityHeaderPolicies()
.SetPolicySelector(ctx => SecurityHeadersDefinitions
.GetHeaderPolicyCollection(builder.Environment.IsDevelopment()));

services.Configure<CredentialSettings>(configuration.GetSection("CredentialSettings"));
services.AddScoped<DriverLicenseService>();
services.AddScoped<IssuerService>();

services.AddDatabaseDeveloperPageExceptionFilter();
services.AddDbContext<DrivingLicenseDbContext>(options =>
options.UseSqlServer(
configuration.GetConnectionString("DefaultConnection")));

services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(configuration.GetSection("AzureAd"));

services.AddAuthorization(options =>
{
options.FallbackPolicy = options.DefaultPolicy;
});

services.AddDistributedMemoryCache();

services.AddRazorPages()
.AddMvcOptions(options => { })
.AddMicrosoftIdentityUI();

services.AddRazorPages();

var app = builder.Build();

app.UseSecurityHeaders();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.ConfigureKestrel(options => options.AddServerHeader = false)
.UseStartup<Startup>();
});
app.UseExceptionHandler("/Error");
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthentication();
app.UseAuthorization();

app.MapRazorPages();
app.MapControllers();

app.Run();
Loading

0 comments on commit 2ba6bf2

Please sign in to comment.