IdentityServer Interaction Service
Duende.IdentityServer.Services.IIdentityServerInteractionService
Section titled “Duende.IdentityServer.Services.IIdentityServerInteractionService”The IIdentityServerInteractionService interface is intended to provide services to be used by the user interface to
communicate with IdentityServer, mainly pertaining to user interaction.
It is available from the dependency injection system and would normally be injected as a constructor parameter into your
MVC controllers for the user interface of IdentityServer.
IIdentityServerInteractionService APIs
Section titled “IIdentityServerInteractionService APIs”All async methods accept a CancellationToken ct parameter.
-
GetAuthenticationContextAsync(string? returnUrl, CancellationToken ct)Returns the protocol-agnostic authentication context for the current request. Returns an
AuthorizationRequestfor OIDC flows or aSamlAuthenticationRequestfor SAML flows, both behind the commonIAuthenticationContextinterface. Use pattern matching to access protocol-specific details. Returnsnullif the URL does not correspond to a valid pending authorization request. -
GetAuthorizationContextAsync(string? returnUrl, CancellationToken ct)Returns the
AuthorizationRequestbased on thereturnUrlpassed to the login or consent pages. -
IsValidReturnUrl(string? returnUrl)Indicates if the
returnUrlis a valid URL for redirect after login or consent. -
GetErrorContextAsync(string? errorId, CancellationToken ct)Returns the
ErrorMessagebased on theerrorIdpassed to the error page. -
GetLogoutContextAsync(string? logoutId, CancellationToken ct)Returns the
LogoutRequestbased on thelogoutIdpassed to the logout page. -
CreateLogoutContextAsync(CancellationToken ct)Used to create a
logoutIdif there is not one presently. This creates a cookie capturing all the current state needed for signout and thelogoutIdidentifies that cookie. This is typically used when there is no currentlogoutIdand the logout page must capture the current user’s state needed for sign-out prior to redirecting to an external identity provider for signout. The newly createdlogoutIdwould need to be roundtripped to the external identity provider at signout time, and then used on the signout callback page in the same way it would be on the normal logout page. -
GrantConsentAsync(AuthorizationRequest request, ConsentResponse consent, CancellationToken ct, string? subject = null)Accepts a
ConsentResponseto inform IdentityServer of the user’s consent to a particularAuthorizationRequest. -
DenyAuthorizationAsync(AuthorizationRequest request, InteractionError error, CancellationToken ct, string? errorDescription = null)Accepts an
InteractionErrorto inform IdentityServer of the error to return to the client for a particularAuthorizationRequest. This is specific to OIDC flows. For a protocol-agnostic alternative, seeDenyAuthenticationAsync. -
DenyAuthenticationAsync(IAuthenticationContext context, InteractionError error, CancellationToken ct, string? errorDescription = null)A protocol-agnostic way for the login page to signal that the user cancelled or refused the authentication request. Works for both OIDC and SAML flows through the
IAuthenticationContextinterface (retrieved viaGetAuthenticationContextAsync). For OIDC, this is equivalent to callingDenyAuthorizationAsync. For SAML, it writes a denial to the SAML signin state store, causing the callback endpoint to generate an error response back to the service provider. -
GetAllUserGrantsAsync(CancellationToken ct)Returns an
IReadOnlyCollection<Grant>for the user. These represent a user’s consent or a client’s access to a user’s resource. -
RevokeUserConsentAsync(string? clientId, CancellationToken ct)Revokes all of a user’s consents and grants for a client.
-
RevokeTokensForCurrentSessionAsync(CancellationToken ct)Revokes all of a user’s consents and grants for clients the user has signed in to during their current session.
Returned models
Section titled “Returned models”The above methods return various models.
AuthorizationRequest
Section titled “AuthorizationRequest”-
ClientThe client that initiated the request.
-
RedirectUriThe URI to redirect the user to after successful authorization.
-
DisplayModeThe display mode passed from the authorization request.
-
UiLocalesThe UI locales passed from the authorization request.
-
IdPThe external identity provider requested. This is used to bypass home realm discovery (HRD). This is provided via the “idp:” prefix to theacr_valuesparameter on the authorize request. -
TenantThe tenant requested. This is provided via the “tenant:” prefix to the
acr_valuesparameter on the authorize request. -
LoginHintThe expected username the user will use to login. This is requested from the client via the
login_hintparameter on the authorize request. -
PromptModeThe prompt mode requested from the authorization request.
-
AcrValuesThe acr values passed from the authorization request.
-
ValidatedResourcesThe
ResourceValidationResultwhich represents the validated resources from the authorization request. -
ParametersThe entire parameter collection passed to the authorization request.
-
RequestObjectValuesThe validated contents of the request object (if present).
ResourceValidationResult
Section titled “ResourceValidationResult”-
ResourcesThe resources of the result.
-
ParsedScopesThe parsed scopes represented by the result.
-
RawScopeValuesThe original (raw) scope values represented by the validated result.
ErrorMessage
Section titled “ErrorMessage”-
ErrorThe error code.
-
ErrorDescriptionThe error description.
-
DisplayModeThe display mode passed from the authorization request.
-
UiLocalesThe UI locales passed from the authorization request.
-
RequestIdThe per-request identifier. This can be used to display to the end user and can be used in diagnostics.
-
ClientIdThe client id making the request (if available).
-
RedirectUriThe redirect URI back to the client (if available).
LogoutRequest
Section titled “LogoutRequest”-
ClientIdThe client identifier that initiated the request.
-
PostLogoutRedirectUriThe URL to redirect the user to after they have logged out.
-
SessionIdThe user’s current session id.
-
SignOutIFrameUrlThe URL to render in an
<iframe>on the logged out page to enable single sign-out. -
ParametersThe entire parameter collection passed to the end session endpoint.
-
ShowSignoutPromptIndicates if the user should be prompted to signout based upon the parameters passed to the end session endpoint.
ConsentResponse
Section titled “ConsentResponse”-
ScopesValuesConsentedThe collection of scopes the user consented to.
-
RememberConsentFlag indicating if the user’s consent is to be persisted.
-
DescriptionOptional description the user can set for the grant (e.g. the name of the device being used when consent is given). This can be presented back to the user from the persisted grant service.
-
ErrorError, if any, for the consent response. This will be returned to the client in the authorization response.
-
ErrorDescriptionError description. This will be returned to the client in the authorization response.
-
SubjectIdThe subject id that allowed the grant.
-
ClientIdThe client identifier for the grant.
-
DescriptionThe description the user assigned to the client or device being authorized.
-
ScopesThe collection of scopes granted.
-
CreationTimeThe date and time when the grant was granted.
-
ExpirationThe date and time when the grant will expire.