add OIDC and OAuth Parameter Customization (#33625)

* add OIDC and OAuth Parameter Customization

* add OIDC and OAuth Parameter Customization
pull/33641/head
Rick Anderson 2024-09-17 15:48:21 -10:00 committed by GitHub
parent 5e4eb1ae6b
commit 903e12d2c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 33 additions and 0 deletions

View File

@ -500,6 +500,12 @@ Alternatively, logging in using OTP with Identity:
![Logging in using OTP with Identity](~/security/authentication/mfa/_static/require_mfa_oidc_01.png)
### OIDC and OAuth Parameter Customization
The OAuth and OIDC authentication handlers [`AdditionalAuthorizationParameters`](https://source.dot.net/#Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs,ddb988460467cfbf) option allows customization of authorization message parameters that are usually included as part of the redirect query string:
:::code language="csharp" source="~/security/authentication/mfa/samples9/WebAddOpenIdConnect/Program.cs" id="snippet_1" :::
## Additional resources
* [Enable QR Code generation for TOTP authenticator apps in ASP.NET Core](xref:security/authentication/identity-enable-qrcodes)

View File

@ -0,0 +1,14 @@
var builder = WebApplication.CreateBuilder(args);
// <snippet_1>
builder.Services.AddAuthentication().AddOpenIdConnect(options =>
{
options.AdditionalAuthorizationParameters.Add("prompt", "login");
options.AdditionalAuthorizationParameters.Add("audience", "https://api.example.com");
});
// </snippet_1>
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.Run();

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.0-rc.1.24452.1" />
</ItemGroup>
</Project>