Table of Contents

Class DefaultConsentService

Namespace
Fdyay.IdentityServer.Services
Assembly
Fdyay.IdentityServer.AspNetCore.dll

Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.

public sealed class DefaultConsentService : IConsentService
Inheritance
DefaultConsentService
Implements
Inherited Members

Constructors

DefaultConsentService(IUserConsentStore, TimeProvider)

Creates the service, as the container resolves it.

public DefaultConsentService(IUserConsentStore store, TimeProvider time)

Parameters

store IUserConsentStore

Where remembered consent is kept.

time TimeProvider

The clock a remembered decision's creation time and expiry are computed from.

Methods

RequiresConsentAsync(string, Client, IEnumerable<ParsedScopeValue>, CancellationToken)

Whether the user must be asked before this request can be answered.

public Task<bool> RequiresConsentAsync(string subjectId, Client client, IEnumerable<ParsedScopeValue> parsedScopes, CancellationToken cancellationToken = default)

Parameters

subjectId string

The signed-in user.

client Client

The client whose request is waiting.

parsedScopes IEnumerable<ParsedScopeValue>

The scopes the request asked for, as the scope parser read them — Duende's type, so a parameterized scope can be told from a plain one. Enumerated once and not held, so a caller can hand over the request's own collection rather than copying it.

cancellationToken CancellationToken

Cancels the lookup.

Returns

Task<bool>

Remarks

False for a client that does not require consent, or for a request with no scopes. True, without reading the store, for a client that does not allow consent to be remembered, or for a request with a parameterized scope or offline_access. Otherwise true unless a remembered consent covers every requested scope.

Exceptions

ArgumentNullException

client or parsedScopes is null.

UpdateConsentAsync(string, Client, ConsentResponse, CancellationToken)

Records the user's decision, so far as it is to outlive the request that prompted it.

public Task UpdateConsentAsync(string subjectId, Client client, ConsentResponse consent, CancellationToken cancellationToken = default)

Parameters

subjectId string
client Client
consent ConsentResponse
cancellationToken CancellationToken

Returns

Task

Remarks

A grant the user chose to remember, for a client that allows it, is stored with the scopes consented and an expiry of Client.ConsentLifetime seconds (none when it is null). Anything else removes whatever was remembered.

Exceptions

ArgumentNullException

client or consent is null.