Skip to content

Commit 1bd69dd

Browse files
committed
Update to .NET 10
1 parent 41ed03d commit 1bd69dd

95 files changed

Lines changed: 11963 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,6 @@ obj
364364
# Docker
365365
.docker
366366

367-
# UI
368-
src/Pages
369-
src/wwwroot
370-
371367
# Runtime data
372368
keys
373369
tempkey.jwk

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.2.0
2+
* Updated dependencies
3+
* Updated ``Duende.IdentityServer`` to ``7.4``
4+
* Updated to .NET 10
5+
16
# 1.1.3
27
* Updated dependencies
38

renovate.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"datasources": [
99
"docker"
1010
],
11-
"allowedVersions": "<9"
11+
"allowedVersions": "<11"
1212
},
1313
{
1414
"description": "Stick with .NET LTS",
@@ -21,7 +21,7 @@
2121
"datasources": [
2222
"nuget"
2323
],
24-
"allowedVersions": "<9"
24+
"allowedVersions": "<11"
2525
},
2626
{
2727
"description": "Group aspnetcore",

src/.dockerignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
bin/
22
obj/
33

4-
Pages
5-
wwwroot
6-
74
keys/
85
tempkey.jwk
96

src/Dockerfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
# Stage 1: Build
2-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS source
2+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS source
33
ARG TARGETARCH
44
ARG target="Release"
55

66
RUN apk add --no-cache unzip curl bash
77

88
WORKDIR /src
99

10-
COPY ./getui.sh ./getui.sh
11-
RUN ./getui.sh
12-
1310
COPY ./OpenIdConnectServerMock.csproj ./OpenIdConnectServerMock.csproj
1411
RUN dotnet restore -a $TARGETARCH
1512

1613
COPY . .
1714

18-
RUN dotnet publish -a $TARGETARCH -c $target -o obj/docker/publish
15+
RUN dotnet publish -a $TARGETARCH -c $target --property:PublishDir=obj/docker/publish
1916

2017
RUN cp -r /src/obj/docker/publish /OpenIdConnectServerMock
2118

2219
# Stage 2: Release
23-
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS release
20+
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS release
2421
ARG target="Release"
2522

2623
RUN apk add --no-cache curl
@@ -34,7 +31,7 @@ ENV ASPNETCORE_ENVIRONMENT=Development
3431
EXPOSE 80
3532
EXPOSE 443
3633

37-
HEALTHCHECK --start-period=2s --interval=1s --timeout=100ms --retries=10 \
34+
HEALTHCHECK --start-period=2s --interval=5s --timeout=1s --retries=10 \
3835
CMD curl -k --location https://localhost/health || exit 1
3936

4037
ENTRYPOINT ["dotnet", "OpenIdConnectServerMock.dll" ]

src/OpenIdConnectServerMock.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
88

99
<IsPackable>true</IsPackable>
1010
<Description>Configurable mock server with OpenId Connect functionality</Description>
11-
<VersionPrefix>1.1.4-SNAPSHOT</VersionPrefix>
11+
<VersionPrefix>1.2.0-SNAPSHOT</VersionPrefix>
1212
<PackageProjectUrl>https://github.com/xdev-software/oidc-server-mock</PackageProjectUrl>
1313
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1414
<PackageTags>OIDC</PackageTags>
@@ -26,10 +26,10 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<PackageReference Include="Duende.IdentityServer" Version="7.3.2" />
30-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.23" />
31-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.23" />
32-
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
29+
<PackageReference Include="Duende.IdentityServer" Version="7.4.4" />
30+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.2" />
31+
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="10.0.2" />
32+
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
3333
<PackageReference Include="YamlDotNet" Version="16.3.0" />
3434
</ItemGroup>
3535

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@page
2+
@model IdentityServerHost.Pages.Account.AccessDeniedModel
3+
@{
4+
}
5+
<div class="row">
6+
<div class="col">
7+
<h1>Access Denied</h1>
8+
<p>You do not have permission to access that resource.</p>
9+
</div>
10+
</div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Microsoft.AspNetCore.Mvc.RazorPages;
2+
3+
namespace IdentityServerHost.Pages.Account;
4+
5+
public class AccessDeniedModel : PageModel
6+
{
7+
public void OnGet()
8+
{
9+
}
10+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@page
2+
@model IdentityServerHost.Pages.Create.Index
3+
4+
<div class="login-page">
5+
<div class="lead">
6+
<h1>Create Account</h1>
7+
</div>
8+
9+
<partial name="_ValidationSummary" />
10+
11+
<div class="row">
12+
13+
<div class="col-sm-6">
14+
<form asp-page="/Account/Create/Index">
15+
<input type="hidden" asp-for="Input.ReturnUrl" />
16+
17+
<div class="form-group">
18+
<label asp-for="Input.Username"></label>
19+
<input class="form-control" placeholder="Username" asp-for="Input.Username" autofocus>
20+
</div>
21+
<div class="form-group">
22+
<label asp-for="Input.Password"></label>
23+
<input type="password" class="form-control" placeholder="Password" asp-for="Input.Password" autocomplete="off">
24+
</div>
25+
<div class="form-group">
26+
<label asp-for="Input.Name"></label>
27+
<input type="text" class="form-control" placeholder="Name" asp-for="Input.Name">
28+
</div>
29+
<div class="form-group">
30+
<label asp-for="Input.Email"></label>
31+
<input type="email" class="form-control" placeholder="Email" asp-for="Input.Email" >
32+
</div>
33+
34+
<button class="btn btn-primary" name="Input.Button" value="create">Create</button>
35+
<button class="btn btn-secondary" name="Input.Button" value="cancel">Cancel</button>
36+
</form>
37+
</div>
38+
39+
</div>
40+
</div>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
using Duende.IdentityServer;
2+
using Duende.IdentityServer.Events;
3+
using Duende.IdentityServer.Models;
4+
using Duende.IdentityServer.Services;
5+
using Duende.IdentityServer.Stores;
6+
using Duende.IdentityServer.Test;
7+
using Microsoft.AspNetCore.Authentication;
8+
using Microsoft.AspNetCore.Authorization;
9+
using Microsoft.AspNetCore.Mvc;
10+
using Microsoft.AspNetCore.Mvc.RazorPages;
11+
12+
namespace IdentityServerHost.Pages.Create;
13+
14+
[SecurityHeaders]
15+
[AllowAnonymous]
16+
public class Index : PageModel
17+
{
18+
private readonly TestUserStore _users;
19+
private readonly IIdentityServerInteractionService _interaction;
20+
21+
[BindProperty]
22+
public InputModel Input { get; set; }
23+
24+
public Index(
25+
IIdentityServerInteractionService interaction,
26+
TestUserStore users = null)
27+
{
28+
// this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity)
29+
_users = users ?? throw new Exception("Please call 'AddTestUsers(TestUsers.Users)' on the IIdentityServerBuilder in Startup or remove the TestUserStore from the AccountController.");
30+
31+
_interaction = interaction;
32+
}
33+
34+
public IActionResult OnGet(string returnUrl)
35+
{
36+
Input = new InputModel { ReturnUrl = returnUrl };
37+
return Page();
38+
}
39+
40+
public async Task<IActionResult> OnPost()
41+
{
42+
// check if we are in the context of an authorization request
43+
var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl);
44+
45+
// the user clicked the "cancel" button
46+
if (Input.Button != "create")
47+
{
48+
if (context != null)
49+
{
50+
// if the user cancels, send a result back into IdentityServer as if they
51+
// denied the consent (even if this client does not require consent).
52+
// this will send back an access denied OIDC error response to the client.
53+
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
54+
55+
// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
56+
if (context.IsNativeClient())
57+
{
58+
// The client is native, so this change in how to
59+
// return the response is for better UX for the end user.
60+
return this.LoadingPage(Input.ReturnUrl);
61+
}
62+
63+
return Redirect(Input.ReturnUrl);
64+
}
65+
else
66+
{
67+
// since we don't have a valid context, then we just go back to the home page
68+
return Redirect("~/");
69+
}
70+
}
71+
72+
if (_users.FindByUsername(Input.Username) != null)
73+
{
74+
ModelState.AddModelError("Input.Username", "Invalid username");
75+
}
76+
77+
if (ModelState.IsValid)
78+
{
79+
var user = _users.CreateUser(Input.Username, Input.Password, Input.Name, Input.Email);
80+
81+
// issue authentication cookie with subject ID and username
82+
var isuser = new IdentityServerUser(user.SubjectId)
83+
{
84+
DisplayName = user.Username
85+
};
86+
87+
await HttpContext.SignInAsync(isuser);
88+
89+
if (context != null)
90+
{
91+
if (context.IsNativeClient())
92+
{
93+
// The client is native, so this change in how to
94+
// return the response is for better UX for the end user.
95+
return this.LoadingPage(Input.ReturnUrl);
96+
}
97+
98+
// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
99+
return Redirect(Input.ReturnUrl);
100+
}
101+
102+
// request for a local page
103+
if (Url.IsLocalUrl(Input.ReturnUrl))
104+
{
105+
return Redirect(Input.ReturnUrl);
106+
}
107+
else if (string.IsNullOrEmpty(Input.ReturnUrl))
108+
{
109+
return Redirect("~/");
110+
}
111+
else
112+
{
113+
// user might have clicked on a malicious link - should be logged
114+
throw new Exception("invalid return URL");
115+
}
116+
}
117+
118+
return Page();
119+
}
120+
}

0 commit comments

Comments
 (0)