Skip to content

Commit fe9ee0c

Browse files
committed
Client portal - improve documentation #732
1 parent dda4b82 commit fe9ee0c

File tree

1 file changed

+75
-4
lines changed

1 file changed

+75
-4
lines changed

src/content/docs/identityserver/ui/portal.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,83 @@ redirect_from:
99
- /identityserver/v7/ui/portal/
1010
---
1111

12+
You can create a client application portal within your IdentityServer host that contains links to client applications
13+
that are configured with an `InitiateLoginUri`. The `InitiateLoginUri` URI property is optional, and can be used to
14+
[enable identity-provider initiated sign-in](https://openid.net/specs/openid-connect-core-1_0.html#ThirdPartyInitiatedLogin).
15+
16+
Your IdentityServer host can check for clients with this property, and render links to those applications for the
17+
currently authenticated user. Doing so gives the user a client application portal that lets them start using each
18+
application, where navigating to an application link starts an OpenID Connect challenge with the application.
19+
20+
This creates a curious pattern, where the user follows a link from the portal page in the IdentityServer host to
21+
an external application only to have that application immediately redirect back to the IdentityServer host's
22+
`/connect/authorize` endpoint. However, if the user has logged in and created a session at the IdentityServer host,
23+
they will get a single sign on experience as they navigate to the various applications in the portal.
24+
1225
:::tip
13-
**Added in Duende IdentityServer 6.3**
26+
The [Entity Framework Core project template](/identityserver/overview/packaging/#templates) comes with an example
27+
`~/Portal.cshtml` Razor Page that implements this functionality.
1428
:::
1529

16-
You can create a client application portal within your IdentityServer host that contains links to client applications that are configured with an `InitiateLoginUri`. `InitiateLoginUri` is an optional URI that can be used to [initiate login](https://openid.net/specs/openid-connect-core-1_0.html#thirdpartyinitiatedlogin). Your IdentityServer host can check for clients with this property and render links to those applications.
30+
## Third-Party Initiated Login
31+
32+
The [OpenID Connect Core 1.0 specification](https://openid.net/specs/openid-connect-core-1_0.html#ThirdPartyInitiatedLogin)
33+
describes several query string parameters that can be passed from the identity provider to the client application:
34+
35+
* `iss` - a URL (using the https scheme) that identifies the issuer
36+
* `login_hint` - a hint about the end user to be authenticated
37+
* `target_link_uri` - URL that the client application is requested to redirect to after authentication
38+
39+
These query string parameters are not included in the template IdentityServer client application portal, but you can add
40+
them to your implementation when desired.
41+
42+
## Implement Identity-Provider Initiated Sign-In
43+
44+
To support identity-provider initiated sign-in, client applications must:
45+
46+
1. Be registered in IdentityServer with the `InitiateLoginUri` property set to a URL in the client application.
47+
2. Implement an endpoint at that URL which triggers an OpenID Connect authentication challenge.
48+
49+
### Configuring The Client In IdentityServer
50+
51+
In your IdentityServer client configuration, set the `InitiateLoginUri` property:
52+
53+
```csharp {7}
54+
// IdentityServer Configuration
55+
// ...
56+
new Client
57+
{
58+
ClientId = "myclient",
59+
// ... existing config ...
60+
InitiateLoginUri = "https://example.com/signin-idp"
61+
}
62+
```
63+
64+
### Implementing The Endpoint In The Client Application
65+
66+
In your ASP.NET Core client application, implement the endpoint referenced by `InitiateLoginUri`.
67+
This endpoint should trigger the OpenID Connect authentication challenge.
68+
69+
Here's an example ASP.NET Core endpoint that redirects the user to IdentityServer for authorization.
70+
When the user is already authenticated, the user is redirected to the application root.
71+
72+
```csharp
73+
// Program.cs
74+
app.MapGet("/signin-idp", async (HttpContext http) =>
75+
{
76+
if (http.User.Identity is { IsAuthenticated: false })
77+
{
78+
var returnUrl = "https://example.com/";
79+
80+
return Results.Challenge(
81+
new AuthenticationProperties { RedirectUri = returnUrl });
82+
}
83+
84+
return Results.Redirect("/");
85+
});
86+
```
1787

18-
Those links are just links to pages within your client applications that will start an OIDC challenge when the user follows them. This creates a curious pattern, where the user follows a link from the portal page in the IdentityServer host to an external application only to have that application immediately redirect back to the IdentityServer host's `/connect/authorize` endpoint. However, if the user has logged in and created a session at the IdentityServer host, they will get a single sign on experience as they navigate to the various applications in the portal.
88+
For the challenge to work, an OpenID Connect schema must be configured in your client application.
89+
When multiple OpenID Connect schemas are registered, you can also use the `Results.Challenge()` overload that allows
90+
you to target a specific schema.
1991

20-
The quickstart UI contains an example of such a portal in the `~/portal` razor page.

0 commit comments

Comments
 (0)