You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "A sample demonstrating how to integrate ASP.NET Identity with Duende IdentityServer using minimal code to create a working user management system with OIDC capabilities."
This section contains a collection of samples when building a Duende IdentityServer solution that uses [ASP.NET Identity](/identityserver/aspnet-identity/index.md)
15
+
for managing the identity database for users of IdentityServer.
16
+
17
+
### ASP.NET Identity
18
+
19
+
This sample shows using ASP.NET Identity with Duende IdentityServer.
20
+
The intent was to show the least amount of code needed to get a working sample that used Microsoft's ASP.NET Identity
21
+
user management library.
22
+
23
+
The first step in creating the sample was to create a new project that used the ASP.NET Identity templates from Visual
24
+
Studio (_"Individual Accounts"_ for the authentication type). This provides all the out-of-the-box features from
25
+
ASP.NET Identity for user management with only minor modifications, which are described below.
26
+
27
+
Then Duende IdentityServer was added to add OIDC/OAuth 2.0 capabilities to the application. Only the minimal configuration
28
+
was done to get Duende IdentityServer functional for this sample.
29
+
30
+
Finally, another project was added which acts as a OIDC client application to exercise the OIDC login (and logout)
31
+
capabilities.
32
+
33
+
The changes to the template in the ASP.NET Identity project (i.e. "IdentityServerAspNetIdentity"):
34
+
35
+
* Sqlite support was added, replacing the default of SqlServer.
36
+
* Duende IdentityServer was configured in `Startup.cs` with the necessary information about the client application, and
37
+
the OIDC scopes it would be requesting.
38
+
* Debug level logging was enabled for the "Duende" prefix to allow viewing the logging emitted during request
39
+
processing.
40
+
* In the middleware pipeline, `UseIdentityServer` replaced `UseAuthentication`.
41
+
* The logout page was scaffolded to allow modification (located in Areas/Identity/Pages/Account/Logout.cshtml). The
42
+
default logout page from the template is unaware of OIDC single signout, so this feature was added.
43
+
44
+
In the client application:
45
+
46
+
* A simple ASP.NET Core Razor Web Application was used as the starting point.
47
+
* In `Startup.cs` the standard cookie and OIDC authentication configuration was added.
48
+
* A secure page (`Secure.cshtml`) that required an authenticated user will render the logged-in user's claim in the
49
+
page.
50
+
* The index page (`Index.cshtml`) was modified to allow a POST to trigger OIDC logout.
51
+
* A logout button was added to trigger the POST.
52
+
53
+
<LinkCard
54
+
description="GitHub Repository for the ASP.NET Identity Sample"
This sample shows how to port passkey support from a .NET 10 Blazor App project template into Duende IdentityServer.
63
+
64
+
:::note[.NET 10 preview 7]
65
+
This sample was written using the functionality available in .NET 10 preview 7.
66
+
The final .NET 10 release may provide a different API surface.
67
+
:::
68
+
69
+
It is based on the [_Duende IdentityServer with ASP.NET Core Identity_](/identityserver/overview/packaging.mdx#duende-identityserver-with-aspnet-core-identity) project template,
70
+
and adds the necessary changes to support passkey authentication:
71
+
72
+
* In `HostingExtensions.cs`, the ASP.NET Identity schema is set to `IdentitySchemaVersions.Version3`.
73
+
* An Entity Framework Core migration is added to generate the `AspNetUserPasskeys` table in the database.
74
+
* The `Passkeys/PasskeyEndpointRouteBuilderExtensions.cs` file registers required minimal API endpoints for passkey creation and passkey request options. The extension method is called in `HostingExtensions.cs`.
75
+
* The `Passkeys/PasskeyOperation.cs`, `Passkeys/PasskeySubmitTagHelper.cs` and `wwwroot/js/passkey-submit.js`files define a tag helper and web component to handle passkey creation and authentication.
76
+
*`Pages/_ViewImports.cshtml` is updated to load the tag helper.
77
+
* The `Models/PasskeyInputModel.cs` file is added and used in the `/Login/InputModel.cs` model.
78
+
* The `Login/Index.cshtml` and `Login/Index.cshtml.cs` file include the necessary logic to handle passkey authentication.
79
+
* The `Pages/Account/Passkeys.cshtml`, `Pages/Account/Passkeys.cshtml.cs`,`Pages/Account/RenamePasskey.cshtml`, and `Pages/Account/RenamePasskey.cshtml.cs` files add functionality to register a passkey credential and rename a passkey.
80
+
81
+
<LinkCard
82
+
description="GitHub Repository for the ASP.NET Identity Passkey Sample"
title="MVC Client with Back-Channel Logout Notifications Sample"
149
+
target="_blank"
150
+
/>
115
151
116
152
### MVC Client with Pushed Authorization Requests
117
153
@@ -128,10 +164,14 @@ Key takeaways:
128
164
:::note
129
165
This sample is only relevant if you're using .NET 8 or lower.
130
166
131
-
[.NET 9 has support for PAR built-in][ms-learn-par], and the ASP.NET Core OIDC authentication handler will automatically use
132
-
PAR when the authority supports it, based on the discovery metadata.
167
+
[.NET 9 has support for PAR built-in](https://learn.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-9.0?view=aspnetcore-9.0#openidconnecthandler-adds-support-for-pushed-authorization-requests-par),
168
+
and the ASP.NET Core OIDC authentication handler will automatically use PAR when the authority supports it,
169
+
based on the discovery metadata.
133
170
:::
134
171
135
-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcPar)
0 commit comments