Skip to content

Commit e2ff1ad

Browse files
authored
Merge pull request #857 from DuendeSoftware/mb/samples
Refactor UX for IdentityServer samples to be in line with those of BFF
2 parents 7a699fd + 79f5e62 commit e2ff1ad

23 files changed

Lines changed: 442 additions & 201 deletions

src/content/docs/identityserver/configuration/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ and [special offers](https://duendesoftware.com/specialoffers) apply.
2525

2626
The Configuration API source code is available [on GitHub](https://github.com/DuendeSoftware/products/tree/main/identity-server/src/Configuration).
2727

28-
Samples of the Configuration API are available [here](/identityserver/samples/configuration.md).
28+
Samples of the Configuration API are available [here](/identityserver/samples/configuration.mdx).

src/content/docs/identityserver/diagnostics/otel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Traces shows individual requests and dependencies. The output is very useful for
4040
flow and finding performance bottlenecks.
4141

4242
This is an example of distributed traces from a web application calling an API (displayed using our
43-
[Aspire sample](/identityserver/samples/diagnostics.md)). The web application uses a refresh token to call
43+
[Aspire sample](/identityserver/samples/diagnostics.mdx)). The web application uses a refresh token to call
4444
IdentityServer to get a new access token and then calls the API. The API reads the discovery endpoint, finds the jwks
4545
url and then gets the keys from jwks endpoint.
4646
![.NET Aspire dashboard showing Duende IdentityServer traces](images/aspire_traces.png)

src/content/docs/identityserver/reference/services/profile-service.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ redirect_from:
1717
#### Duende.IdentityServer.Services.IProfileService
1818

1919
Encapsulates retrieval of user claims from a data source of your choice.
20-
See [here](/identityserver/samples/ui.md#custom-profile-service) for a sample.
20+
See [here](/identityserver/samples/ui.mdx#custom-profile-service) for a sample.
2121

2222
```cs
2323
/// <summary>

src/content/docs/identityserver/samples/aspid.md

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: "ASP.NET Identity Integration"
3+
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."
4+
sidebar:
5+
order: 30
6+
redirect_from:
7+
- /identityserver/v5/samples/aspid/
8+
- /identityserver/v6/samples/aspid/
9+
- /identityserver/v7/samples/aspid/
10+
---
11+
12+
import { LinkCard } from "@astrojs/starlight/components";
13+
14+
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"
55+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/AspNetIdentity"
56+
title="ASP.NET Identity Sample"
57+
target="_blank"
58+
/>
59+
60+
# ASP.NET Identity Passkey :badge[.NET 10]
61+
62+
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"
83+
href="https://github.com/DuendeSoftware/samples/tree/main/IdentityServer/v7/AspNetIdentityPasskeys"
84+
title="ASP.NET Identity Passkey Sample"
85+
target="_blank"
86+
/>

src/content/docs/identityserver/samples/basics.md renamed to src/content/docs/identityserver/samples/basics.mdx

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ redirect_from:
1010
- /identityserver/v7/samples/basics/
1111
---
1212

13-
This solution contains a collection of common scenarios.
13+
import { LinkCard } from "@astrojs/starlight/components";
14+
15+
This section contains a collection of common scenarios when building a Duende IdentityServer solution.
1416

1517
### Client Credentials
1618

@@ -23,7 +25,12 @@ Key takeaways:
2325
* how to use a shared secret
2426
* how to use an access token
2527

26-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/ClientCredentials)
28+
<LinkCard
29+
description="GitHub Repository for the Client Credentials Sample"
30+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/ClientCredentials"
31+
title="Client Credentials Sample"
32+
target="_blank"
33+
/>
2734

2835
### JWT-based Client Authentication
2936

@@ -36,7 +43,12 @@ Key takeaways:
3643
* use a JWT as a client secret replacement
3744
* configure IdentityServer to accept a JWT as a client secret
3845

39-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/JwtBasedClientAuthentication)
46+
<LinkCard
47+
description="GitHub Repository for the JWT-based Client Authentication Sample"
48+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/ClientCredentials"
49+
title="JWT-based Client Authentication Sample"
50+
target="_blank"
51+
/>
4052

4153
### Introspection & Reference Tokens
4254

@@ -56,9 +68,14 @@ Key takeaways:
5668
* set up an API resource with an API secret
5769
* configure an API to accept and validate reference tokens
5870

59-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/Introspection)
71+
<LinkCard
72+
description="GitHub Repository for the Introspection & Reference Tokens Sample"
73+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/Introspection"
74+
title="Introspection & Reference Tokens Sample"
75+
target="_blank"
76+
/>
6077

61-
### MVC Client Sample
78+
### MVC Client
6279

6380
This sample shows how to use the `authorization_code` grant type. This is typically used for interactive applications
6481
like web applications.
@@ -70,12 +87,16 @@ Key takeaways:
7087
* call an API
7188
* manually refresh tokens
7289

73-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcBasic)
90+
<LinkCard
91+
description="GitHub Repository for the MVC Client Sample"
92+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcBasic"
93+
title="MVC Client Sample"
94+
target="_blank"
95+
/>
7496

7597
### MVC Client with automatic Access Token Management
7698

77-
This sample shows how to
78-
use [Duende.AccessTokenManagement](/accesstokenmanagement) to automatically
99+
This sample shows how to use [Duende.AccessTokenManagement](/accesstokenmanagement) to automatically
79100
manage access tokens.
80101

81102
The sample uses a special client in the sample IdentityServer with a short token lifetime (75 seconds). When repeating
@@ -85,9 +106,14 @@ You can also turn on debug tracing to get more insights in the token management
85106

86107
Key takeaways:
87108

88-
* use Duende.AccessTokenManagement to automate refreshing tokens
109+
* use [Duende.AccessTokenManagement](/accesstokenmanagement) to automate refreshing tokens
89110

90-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcTokenManagement)
111+
<LinkCard
112+
description="GitHub Repository for the MVC Client with automatic Access Token Management Sample"
113+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcTokenManagement"
114+
title="MVC Client with automatic Access Token Management Sample"
115+
target="_blank"
116+
/>
91117

92118
### MVC Client with JAR and JWT-based Authentication
93119

@@ -100,7 +126,12 @@ Key takeaways:
100126
* use JWT-based authentication for automatic token management
101127
* configure a client in IdentityServer to share key material for both front- and back-channel
102128

103-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcJarJwt)
129+
<LinkCard
130+
description="GitHub Repository for the MVC Client with JAR and JWT-based Authentication Sample"
131+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcJarJwt"
132+
title="MVC Client with JAR and JWT-based Authentication Sample"
133+
target="_blank"
134+
/>
104135

105136
### MVC Client with Back-Channel Logout Notifications
106137

@@ -111,7 +142,12 @@ Key takeaways:
111142
* how to implement the back-channel notification endpoint
112143
* how to leverage events on the cookie handler to invalidate the user session
113144

114-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcBackChannelLogout)
145+
<LinkCard
146+
description="GitHub Repository for the MVC Client with Back-Channel Logout Notifications Sample"
147+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcBackChannelLogout"
148+
title="MVC Client with Back-Channel Logout Notifications Sample"
149+
target="_blank"
150+
/>
115151

116152
### MVC Client with Pushed Authorization Requests
117153

@@ -128,10 +164,14 @@ Key takeaways:
128164
:::note
129165
This sample is only relevant if you're using .NET 8 or lower.
130166

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.
133170
:::
134171

135-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcPar)
136-
137-
[ms-learn-par]: 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
172+
<LinkCard
173+
description="GitHub Repository for the MVC Client with Pushed Authorization Requests Sample"
174+
href="https://github.com/DuendeSoftware/Samples/tree/main/IdentityServer/v7/Basics/MvcPar"
175+
title="MVC Client with Pushed Authorization Requests Sample"
176+
target="_blank"
177+
/>

src/content/docs/identityserver/samples/clients.md renamed to src/content/docs/identityserver/samples/clients.mdx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,30 @@ redirect_from:
99
- /identityserver/v7/samples/clients/
1010
---
1111

12-
This section contains a collection of various client technologies connecting to IdentityServer.
12+
import { LinkCard } from "@astrojs/starlight/components";
13+
14+
This section contains a collection of samples demonstrating various client technologies connecting to Duende IdentityServer.
1315

1416
### .NET 4.8 Clients
1517

1618
This sample shows how to add OpenID Connect code flow with PKCE to a .NET 4.8 WebForms client and a .NET 4.8 MVC Client.
1719
Each client can log in, logout, make API requests to a .NET 4.8 WebApi using OAuth, and refresh access tokens.
1820

19-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/various/clients/Owin)
21+
<LinkCard
22+
description="GitHub Repository for the .NET 4.8 Clients Sample"
23+
href="https://github.com/DuendeSoftware/Samples/tree/main/various/clients/Owin"
24+
title=".NET 4.8 Clients Sample"
25+
target="_blank"
26+
/>
2027

21-
### .NET MAUI client
28+
### .NET MAUI Client
2229

2330
This sample shows how to use the [IdentityModel.OidcClient](https://github.com/IdentityModel/IdentityModel.OidcClient)
24-
FOSS library to connect a .NET MAUI app to IdentityServer
31+
open source library to connect a .NET MAUI app to IdentityServer
2532

26-
[link to source code](https://github.com/DuendeSoftware/Samples/tree/main/various/clients/Maui)
33+
<LinkCard
34+
description="GitHub Repository for the .NET MAUI Client Sample"
35+
href="https://github.com/DuendeSoftware/Samples/tree/main/various/clients/Maui"
36+
title=".NET MAUI Client Sample"
37+
target="_blank"
38+
/>

src/content/docs/identityserver/samples/configuration.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)