|
|
|
@ -71,13 +71,13 @@ public class AuthorizationController : Controller |
|
|
|
// For scenarios where the default authentication handler configured in the ASP.NET Core
|
|
|
|
// authentication options shouldn't be used, a specific scheme can be specified here.
|
|
|
|
var result = await HttpContext.AuthenticateAsync(); |
|
|
|
if (result == null || !result.Succeeded || request.HasPrompt(Prompts.Login) || |
|
|
|
if (result == null || !result.Succeeded || request.HasPrompt(PromptValues.Login) || |
|
|
|
(request.MaxAge != null && result.Properties?.IssuedUtc != null && |
|
|
|
DateTimeOffset.UtcNow - result.Properties.IssuedUtc > TimeSpan.FromSeconds(request.MaxAge.Value))) |
|
|
|
{ |
|
|
|
// If the client application requested promptless authentication,
|
|
|
|
// return an error indicating that the user is not logged in.
|
|
|
|
if (request.HasPrompt(Prompts.None)) |
|
|
|
if (request.HasPrompt(PromptValues.None)) |
|
|
|
{ |
|
|
|
return Forbid( |
|
|
|
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, |
|
|
|
@ -90,7 +90,7 @@ public class AuthorizationController : Controller |
|
|
|
|
|
|
|
// To avoid endless login -> authorization redirects, the prompt=login flag
|
|
|
|
// is removed from the authorization request payload before redirecting the user.
|
|
|
|
var prompt = string.Join(" ", request.GetPrompts().Remove(Prompts.Login)); |
|
|
|
var prompt = string.Join(" ", request.GetPrompts().Remove(PromptValues.Login)); |
|
|
|
|
|
|
|
var parameters = Request.HasFormContentType ? |
|
|
|
Request.Form.Where(parameter => parameter.Key != Parameters.Prompt).ToList() : |
|
|
|
@ -173,7 +173,7 @@ public class AuthorizationController : Controller |
|
|
|
// return an authorization response without displaying the consent form.
|
|
|
|
case ConsentTypes.Implicit: |
|
|
|
case ConsentTypes.External when authorizations.Count is not 0: |
|
|
|
case ConsentTypes.Explicit when authorizations.Count is not 0 && !request.HasPrompt(Prompts.Consent): |
|
|
|
case ConsentTypes.Explicit when authorizations.Count is not 0 && !request.HasPrompt(PromptValues.Consent): |
|
|
|
// Create the claims-based identity that will be used by OpenIddict to generate tokens.
|
|
|
|
var identity = new ClaimsIdentity( |
|
|
|
authenticationType: TokenValidationParameters.DefaultAuthenticationType, |
|
|
|
@ -210,8 +210,8 @@ public class AuthorizationController : Controller |
|
|
|
|
|
|
|
// At this point, no authorization was found in the database and an error must be returned
|
|
|
|
// if the client application specified prompt=none in the authorization request.
|
|
|
|
case ConsentTypes.Explicit when request.HasPrompt(Prompts.None): |
|
|
|
case ConsentTypes.Systematic when request.HasPrompt(Prompts.None): |
|
|
|
case ConsentTypes.Explicit when request.HasPrompt(PromptValues.None): |
|
|
|
case ConsentTypes.Systematic when request.HasPrompt(PromptValues.None): |
|
|
|
return Forbid( |
|
|
|
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, |
|
|
|
properties: new AuthenticationProperties(new Dictionary<string, string> |
|
|
|
|