Table of Contents

Class ConsentModel

Namespace
Fdyay.IdentityServer.UI.Pages.Account
Assembly
Fdyay.IdentityServer.UI.dll

The consent page: shows the scopes a pending authorization request asks for, and records the signed-in user's answer.

[Authorize]
public class ConsentModel : PageModel, IAsyncPageFilter, IPageFilter, IFilterMetadata
Inheritance
ConsentModel
Implements
Inherited Members

Constructors

ConsentModel(IIdentityServerInteractionService, IMessageStore<ErrorMessage>, IOptions<IdentityServerOptions>, IEventService, TimeProvider)

Creates the page model, as the container resolves it.

public ConsentModel(IIdentityServerInteractionService interaction, IMessageStore<ErrorMessage> errorMessages, IOptions<IdentityServerOptions> options, IEventService events, TimeProvider time)

Parameters

interaction IIdentityServerInteractionService

Resolves the return URL to the pending request, and records the grant or denial.

errorMessages IMessageStore<ErrorMessage>

Where the error page's message is written when the return URL names no request.

options IOptions<IdentityServerOptions>

The server options: the return URL parameter, the allowed link targets and the error page.

events IEventService

Receives the ConsentGrantedEvent or ConsentDeniedEvent.

time TimeProvider

The clock that stamps an error message's creation time.

Properties

AuthContext

The pending authorization request the return URL names, set by OnGetAsync(); null until then.

public AuthorizationRequest? AuthContext { get; set; }

Property Value

AuthorizationRequest

ClientLinkUri

The client's own web address, when it is one this page is willing to offer as a link.

public string? ClientLinkUri { get; }

Property Value

string

Remarks

Client.ClientUri is controlled by the client, and the page renders it as an anchor. Razor encodes the attribute, so no markup escapes — but javascript: survives encoding unchanged and runs on click, and this is the one page in the server where a click grants an application access to a user's data. The interactive pages' CSP is default-src 'none' with no script-src, which already stops that navigation in a browser that enforces it; this is the layer that does not depend on the browser. A client whose address this server would not navigate to is named without a link, not hidden.

Input

The posted form: which button was pressed, the return URL, the ticked scopes, remember-consent and the grant's name.

[BindProperty]
public ConsentModel.InputModel Input { get; set; }

Property Value

ConsentModel.InputModel

Scopes

What the page offers, one row per scope this request validated.

public IReadOnlyList<ConsentScope> Scopes { get; }

Property Value

IReadOnlyList<ConsentScope>

Methods

OnGetAsync()

Renders the scope list for the request waiting behind the return URL.

public Task<IActionResult> OnGetAsync()

Returns

Task<IActionResult>

Remarks

Read by the configured name rather than bound by a fixed one, for the reason set out on the login page: ConsentReturnUrlParameter decides what the authorize endpoint puts on the redirect, and a page binding returnUrl could not see it at any other value.

OnPostAsync()

Records the user's answer and sends the browser back to the authorize endpoint: Allow with at least one scope ticked grants those scopes; Deny, or Allow with nothing ticked, denies the request with access_denied. A return URL that names no pending request goes to the error page instead.

public Task<IActionResult> OnPostAsync()

Returns

Task<IActionResult>

A redirect to the return URL, or to the error page.