Skip to content

Commit eb76b46

Browse files
committed
Moved all shared code snippets to the top
1 parent 6749925 commit eb76b46

1 file changed

Lines changed: 25 additions & 29 deletions

File tree

  • astro/src/content/docs/identityserver/configuration

astro/src/content/docs/identityserver/configuration/dcr.mdx

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ redirect_from:
1818

1919
import { Code, Steps } from "@astrojs/starlight/components";
2020

21+
export const addMainPackageSnippet = `
22+
cd Configuration
23+
dotnet add package Duende.IdentityServer.Configuration
24+
`;
25+
26+
export const addStoragePackageSnippet = `dotnet add package Duende.IdentityServer.Configuration.EntityFramework`;
27+
2128
export const licenseSnippet = `
2229
builder.Services.AddIdentityServerConfiguration(opt =>
2330
opt.LicenseKey = "<license>";
@@ -35,6 +42,11 @@ builder.Services.AddConfigurationDbContext<ConfigurationDbContext>(options =>
3542
});
3643
`;
3744

45+
export const mapDcrEndpointSnippet = `
46+
app.MapDynamicClientRegistration()
47+
.RequireAuthorization("DCR");
48+
`;
49+
3850
Dynamic Client Registration (DCR) is the process of registering OAuth clients
3951
dynamically. It allows OAuth client applications to programmatically register
4052
themselves with an authorization server at runtime, rather than requiring manual
@@ -78,12 +90,9 @@ create a new ASP.NET Core Web application which will host the Configuration API.
7890
```
7991

8092
2. **Add the `Duende.IdentityServer.Configuration` package**
81-
82-
```bash title=Terminal
83-
cd Configuration
84-
dotnet add package Duende.IdentityServer.Configuration
85-
```
86-
93+
94+
<Code code={addMainPackageSnippet} lang="bash" title="Terminal" />
95+
8796
3. **Configure services to include the Configuration API**
8897

8998
<Code code={licenseSnippet} lang="csharp" title="Program.cs" />
@@ -103,10 +112,8 @@ create a new ASP.NET Core Web application which will host the Configuration API.
103112
the interface yourself. See [the IClientConfigurationStore reference](/identityserver/reference/stores/index.md)
104113
for more details. If you wish to use the built-in implementation, install its NuGet
105114
package and add it to the ASP.NET Core service provider.
106-
107-
```bash title=Terminal
108-
dotnet add package Duende.IdentityServer.Configuration.EntityFramework
109-
```
115+
116+
<Code code={addStoragePackageSnippet} lang="bash" title="Terminal" />
110117

111118
The `AddClientConfigurationStore()` extension method registers the built-in
112119
implementation of the `IClientConfigurationStore` interface with the service
@@ -116,13 +123,9 @@ create a new ASP.NET Core Web application which will host the Configuration API.
116123
<Code code={dbConfigurationSnippet} lang="csharp" title="Program.cs" mark={[3]} />
117124

118125
5. **Map the Configuration API endpoints**
119-
120-
```csharp
121-
// Program.cs
122-
app.MapDynamicClientRegistration()
123-
.RequireAuthorization("DCR");
124-
```
125-
126+
127+
<Code code={mapDcrEndpointSnippet} lang="csharp" title="Program.cs" />
128+
126129
The `MapDynamicClientRegistration` extension method registers the DCR endpoints
127130
and returns an `IEndpointConventionBuilder` which you can use to define authorization
128131
requirements for your DCR endpoint.
@@ -139,12 +142,10 @@ You'll need to add the Configuration API's services to the service collection,
139142
and configure the store implementation.
140143

141144
<Steps>
145+
142146
1. **Add the `Duende.IdentityServer.Configuration` package**
143147

144-
```bash title=Terminal
145-
cd Configuration
146-
dotnet add package Duende.IdentityServer.Configuration
147-
```
148+
<Code code={addMainPackageSnippet} lang="bash" title="Terminal" />
148149

149150
2. **Configure services to include the Configuration API**
150151

@@ -166,9 +167,7 @@ and configure the store implementation.
166167
for more details. If you wish to use the built-in implementation, install its NuGet
167168
package and add it to the ASP.NET Core service provider.
168169

169-
```bash title=Terminal
170-
dotnet add package Duende.IdentityServer.Configuration.EntityFramework
171-
```
170+
<Code code={addStoragePackageSnippet} lang="bash" title="Terminal" />
172171

173172
The `AddClientConfigurationStore()` extension method registers the built-in
174173
implementation of the `IClientConfigurationStore` interface with the service
@@ -180,18 +179,15 @@ and configure the store implementation.
180179

181180
4. **Map the Configuration API endpoints**
182181

183-
```csharp
184-
// Program.cs
185-
app.MapDynamicClientRegistration()
186-
.RequireAuthorization("DCR");
187-
```
182+
<Code code={mapDcrEndpointSnippet} lang="csharp" title="Program.cs" />
188183

189184
The `MapDynamicClientRegistration` extension method registers the DCR endpoints
190185
and returns an `IEndpointConventionBuilder` which you can use to define authorization
191186
requirements for your DCR endpoint.
192187

193188
See [Authorization](#authorization) for more details about implementing authorization for
194189
the DCR endpoint.
190+
195191
</Steps>
196192

197193
## Authorization

0 commit comments

Comments
 (0)