Skip to content

Commit fbd02f5

Browse files
authored
Merge pull request #980 from DuendeSoftware/mb/bulk
Update code snippets to use consistent `csharp` syntax highlighting across IdentityServer documentation.
2 parents 58de602 + 2eb2edd commit fbd02f5

File tree

79 files changed

+187
-187
lines changed

Some content is hidden

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

79 files changed

+187
-187
lines changed

src/content/docs/accesstokenmanagement/advanced/client-credentials.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ The client registration object has two additional properties to customize the HT
318318
</Tabs>
319319

320320

321-
```cs
321+
```csharp
322322
// Program.cs
323323
services.AddClientCredentialsTokenManagement(options =>
324324
{

src/content/docs/accesstokenmanagement/advanced/dpop.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Once you have a JWK you wish to use, then it must be configured or made availabl
4444

4545
Here's a sample configuring the key in an application using `AddOpenIdConnectAccessTokenManagement` in the startup code:
4646

47-
```cs
47+
```csharp
4848
// Program.cs
4949
services.AddOpenIdConnectAccessTokenManagement(options =>
5050
{
@@ -54,7 +54,7 @@ services.AddOpenIdConnectAccessTokenManagement(options =>
5454

5555
Similarly, for an application using `AddClientCredentialsTokenManagement`, it would look like this:
5656

57-
```cs
57+
```csharp
5858
// Program.cs
5959
services.AddClientCredentialsTokenManagement()
6060
.AddClient("client_name", options =>

src/content/docs/accesstokenmanagement/blazor-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Once registered and initialized, `Duende.AccessTokenManagement` will keep the st
7171

7272
If you've registered your token store with `AddBlazorServerAccessTokenManagement`, Duende.AccessTokenManagement will register the services necessary to attach tokens to outgoing HTTP requests automatically, using the same API as a non-blazor application. You inject an HTTP client factory and resolve named HTTP clients where ever you need to make HTTP requests, and you register the HTTP client's that use access tokens in the ASP.NET Core service provider with our extension method:
7373

74-
```cs
74+
```csharp
7575
// Program.cs
7676
builder.Services.AddUserAccessTokenHttpClient("demoApiClient", configureClient: client =>
7777
{

src/content/docs/bff/diagnostics/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ To start emitting OpenTelemetry data in Duende Backend for Frontend (BFF), you n
3535

3636
The following configuration adds the OpenTelemetry configuration to your service setup, and exports data to an [OTLP exporter](https://learn.microsoft.com/en-us/dotnet/core/diagnostics/observability-with-otel):
3737

38-
```cs
38+
```csharp
3939
// Program.cs
4040
var openTelemetry = builder.Services.AddOpenTelemetry();
4141

src/content/docs/bff/extensibility/http-forwarder.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var client = new HttpMessageInvoker(new SocketsHttpHandler
3535

3636
If you want to customize the HTTP client you can implement the `IForwarderHttpClientFactory` interface, e.g.:
3737

38-
```cs
38+
```csharp
3939
public class MyInvokerFactory : IForwarderHttpClientFactory
4040
{
4141
public HttpMessageInvoker CreateClient(ForwarderHttpClientContext context)
@@ -59,7 +59,7 @@ public class MyInvokerFactory : IForwarderHttpClientFactory
5959

6060
...and override our registration:
6161

62-
```cs
62+
```csharp
6363
services.AddSingleton<IForwarderHttpClientFactory, MyInvokerFactory>();
6464
```
6565

src/content/docs/bff/fundamentals/apis/yarp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ providing a robust security guarantee.
222222

223223
You can add the anti-forgery protection to all YARP routes by calling the *AsBffApiEndpoint* extension method:
224224

225-
```cs
225+
```csharp
226226
app.MapReverseProxy()
227227
.AsBffApiEndpoint();
228228

@@ -253,7 +253,7 @@ the route configuration by adding the *Duende.Bff.Yarp.AntiforgeryCheck* metadat
253253

254254
This is also possible in code:
255255

256-
```cs
256+
```csharp
257257
yarpBuilder.LoadFromMemory(
258258
new[]
259259
{
@@ -278,7 +278,7 @@ You can combine the token management feature with the anti-forgery check.
278278

279279
To enforce the presence of the anti-forgery headers, you need to add a middleware to the YARP pipeline:
280280

281-
```cs
281+
```csharp
282282
// Program.cs
283283
app.MapReverseProxy(proxyApp =>
284284
{

src/content/docs/identitymodel-oidcclient/automatic.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ For a simple example, the following code shows how to use the
8484
to invoke a browser on the host desktop platform. The `SystemBrowser` is a naive implementation that uses the
8585
[System.Diagnostics.Process](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process) class to start the system default browser.
8686

87-
```cs
87+
```csharp
8888
var options = new OidcClientOptions
8989
{
9090
Authority = "https://demo.duendesoftware.com",
@@ -99,7 +99,7 @@ var client = new OidcClient(options);
9999

100100
Once the `IBrowser` is configured, the `LoginAsync` method can be invoked to start the authentication flow.
101101

102-
```cs
102+
```csharp
103103
var result = await client.LoginAsync();
104104
```
105105

src/content/docs/identitymodel-oidcclient/logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ redirect_from:
1111
`OidcClient` logs errors, warnings, and diagnostic information using
1212
`Microsoft.Extensions.Logging.ILogger`, the standard .NET logging library.
1313

14-
```cs
14+
```csharp
1515
using Duende.IdentityModel;
1616
using Duende.IdentityModel.OidcClient;
1717

src/content/docs/identitymodel/endpoints/general-usage.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ implementation that parses the status codes and response content. The
4747
following code snippet would parse the raw HTTP response from a token
4848
endpoint and turn it into a `TokenResponse` object:
4949

50-
```cs
50+
```csharp
5151
var tokenResponse = await ProtocolResponse
5252
.FromHttpResponseAsync<TokenResponse>(httpResponse);
5353
```
@@ -65,7 +65,7 @@ object.
6565
It is your responsibility to set up and manage the lifetime of the
6666
`HttpClient`, e.g. manually:
6767

68-
```cs
68+
```csharp
6969
var client = new HttpClient();
7070

7171
var response = await client.RequestClientCredentialsTokenAsync(
@@ -80,7 +80,7 @@ var response = await client.RequestClientCredentialsTokenAsync(
8080
You might want to use other techniques to obtain an `HttpClient`, e.g.
8181
via the HTTP client factory:
8282

83-
```cs
83+
```csharp
8484
var client = HttpClientFactory.CreateClient("my_named_token_client");
8585

8686
var response = await client.RequestClientCredentialsTokenAsync(
@@ -112,7 +112,7 @@ Any request type implementing `ProtocolRequest` has the ability to configure
112112
the client credential style, which specifies how the client will transmit the client ID and secret.
113113
`ClientCredentialStyle` options include `PostBody` and the default value of `AuthorizationHeader`.
114114

115-
```cs
115+
```csharp
116116
var client = HttpClientFactory.CreateClient("my_named_token_client");
117117

118118
var response = await client.RequestClientCredentialsTokenAsync(

src/content/docs/identityserver/apis/aspnetcore/authorization.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The access token will include additional claims that can be used for authorizati
1515

1616
In ASP.NET core, the contents of the JWT payload get transformed into claims and packaged up in a `ClaimsPrincipal`. So you can always write custom validation or authorization logic in C#:
1717

18-
```cs
18+
```csharp
1919
public IActionResult Get()
2020
{
2121
var isAllowed = User.HasClaim("scope", "read");
@@ -28,7 +28,7 @@ For better encapsulation and re-use, consider using the ASP.NET Core [authorizat
2828

2929
With this approach, you would first turn the claim requirement(s) into a named policy:
3030

31-
```cs
31+
```csharp
3232
builder.Services.AddAuthorization(options =>
3333
{
3434
options.AddPolicy("read_access", policy =>
@@ -38,13 +38,13 @@ builder.Services.AddAuthorization(options =>
3838

3939
...and then enforce it, e.g. using the routing table:
4040

41-
```cs
41+
```csharp
4242
app.MapControllers().RequireAuthorization("read_access");
4343
```
4444

4545
...or imperatively inside the endpoint handler:
4646

47-
```cs
47+
```csharp
4848
app.MapGet("/", async (IAuthorizationService authz, ClaimsPrincipal user) =>
4949
{
5050
var allowed = await authz.AuthorizeAsync(user, "read_access");
@@ -60,7 +60,7 @@ app.MapGet("/", async (IAuthorizationService authz, ClaimsPrincipal user) =>
6060

6161
... or declaratively:
6262

63-
```cs
63+
```csharp
6464
app.MapGet("/", () =>
6565
{
6666
// rest omitted
@@ -73,7 +73,7 @@ Historically, Duende IdentityServer emitted the `scope` claims as an array in th
7373

7474
The newer *JWT Profile for OAuth* [spec](/identityserver/overview/specs.md) mandates that the scope claim is a single space delimited string. You can switch the format by setting the `EmitScopesAsSpaceDelimitedStringInJwt` on the [options](/identityserver/reference/options.md). But this means that the code consuming access tokens might need to be adjusted. The following code can do a conversion to the *multiple claims* format that .NET prefers:
7575

76-
```cs
76+
```csharp
7777
namespace IdentityModel.AspNetCore.AccessTokenValidation;
7878

7979
/// <summary>

0 commit comments

Comments
 (0)