I'm using a .net core 2 application and have set OpenIDConnect options prompt parameter to consent in ConfigureServices method in Startup.cs
.AddOpenIdConnect(options =>
{
options.prompt ="consent";
}
But in the initial login page I want to just use the prompt ="login" without consent screen.
In Controller page
return Challenge(
new AuthenticationProperties { RedirectUri =
Url.Action("Index") },
OpenIdConnectDefaults.AuthenticationScheme);
Is there any way to change the prompt parameter to "login" from controller. In the previous version we could do this using OwinContext.
HttpContext.GetOwinContext().Environment.Add("Prompt","login");
Any help is appreciated, thanks.
The CallbackPath represents the URL to which the browser should be redirected to and the default value is /signin-oidc. The picture below shows how it is related: Follow this answer to receive notifications. answered Dec 20, 2021 at 12:31.
OpenID Connect (OIDC) extends the OAuth 2.0 authorization protocol for use also as an authentication protocol. You can use OIDC to enable single sign-on (SSO) between your OAuth-enabled applications by using a security token called an ID token.
Select ASP.NET Core Web Application>Choose Web Application (Model-View-Controller) template> Click on the "Change Authentication" button>Select "Work or School Accounts". Choose Cloud - Single Organization. Fill up the field of Domain which is the Azure Active Directory tenant name (say, softdreams.onmicrosoft.com).
Openid-configuration is the OpenID Connect Provider's discovery document. The discovery document describes the provider's API endpoints used during the authentication sequence. Specifying this URL connects the authenticator to a particular OpenID Connect Provider.
You can use the Items
property to communicate arbitrary parameters:
var authenticationProperties = new AuthenticationProperties
{
RedirectUri = Url.Action("Index")
};
authenticationProperties.Items["prompt"] = "login";
return Challenge(
authenticationProperties,
OpenIdConnectDefaults.AuthenticationScheme);
Then you will have to handle the OnRedirectToIdentityProvider
event, something like this:
options.Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProvider = context =>
{
if (context.Properties.Items.TryGetValue("prompt", out string prompt))
{
context.ProtocolMessage.Prompt = prompt;
}
return Task.CompletedTask;
}
};
It looks in the Items if there is a prompt value given, and if so, replaces the existing value with that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With