Skip to content

Commit

Permalink
Add preview 2 features (#32034)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdykstra authored Mar 12, 2024
1 parent 9ca4411 commit 532fdf8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aspnetcore/release-notes/aspnetcore-9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ This section describes new features for minimal APIs.

This section describes new features for authentication and authorization.

[!INCLUDE[](~/release-notes/aspnetcore-9/includes/oidccustomparms.md)]

[!INCLUDE[](~/release-notes/aspnetcore-9/includes/httpsysextendedauth.md)]

## Miscellaneous

The following sections describe miscellaneous new features.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Configure HTTP.sys extended authentication flags

You can now configure the [`HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING`](/windows/win32/api/http/ns-http-http_server_authentication_info) and [`HTTP_AUTH_EX_FLAG_CAPTURE_CREDENTIAL`](/windows/win32/api/http/ns-http-http_server_authentication_info) HTTP.sys flags by using the new `EnableKerberosCredentialCaching` and `CaptureCredentials` properties on the HTTP.sys <xref:Microsoft.AspNetCore.Server.HttpSys.AuthenticationManager> to optimize how Windows authentication is handled. For example:

```csharp
webBuilder.UseHttpSys(options =>
{
options.Authentication.Schemes = AuthenticationSchemes.Negotiate;
options.Authentication.EnableKerberosCredentialCaching = true;
options.Authentication.CaptureCredentials = true;
});
```
25 changes: 25 additions & 0 deletions aspnetcore/release-notes/aspnetcore-9/includes/oidccustomparms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### OIDC and OAuth Parameter Customization

The OAuth and OIDC authentication handlers now have an `AdditionalAuthorizationParameters` option to make it easier to customize authorization message parameters that are usually included as part of the redirect query string. In .NET 8 and earlier, this requires a custom <xref:Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents.OnRedirectToIdentityProvider> callback or overridden <xref:Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler%601.BuildChallengeUrl%2A> method in a custom handler. Here's an example of .NET 8 code:

```csharp
builder.Services.AddAuthentication().AddOpenIdConnect(options =>
{
options.Events.OnRedirectToIdentityProvider = context =>
{
context.ProtocolMessage.SetParameter("prompt", "login");
context.ProtocolMessage.SetParameter("audience", "https://api.example.com");
return Task.CompletedTask;
};
});
```

The preceding example can now be simplified to the following code:

```csharp
builder.Services.AddAuthentication().AddOpenIdConnect(options =>
{
options.AdditionalAuthorizationParameters.Add("prompt", "login");
options.AdditionalAuthorizationParameters.Add("audience", "https://api.example.com");
});
```

0 comments on commit 532fdf8

Please sign in to comment.