mirror of
https://gitee.com/dcren/openiddict-documentation.git
synced 2025-07-16 07:59:46 +08:00
Update the documentation pages
This commit is contained in:
parent
036d584a7b
commit
928c228ad8
@ -79,9 +79,9 @@ and explicitly attached to a <code>ClaimsPrincipal</code> using the OpenIddict-s
|
||||
For that, a "consent type" can be defined per-application, as in the following example:</p>
|
||||
<pre><code class="lang-csharp">// Retrieve the application details from the database.
|
||||
var application = await _applicationManager.FindByClientIdAsync(request.ClientId) ??
|
||||
throw new InvalidOperationException("Details concerning the calling client application cannot be found.");
|
||||
throw new InvalidOperationException("The application cannot be found.");
|
||||
|
||||
// Retrieve the permanent authorizations associated with the user and the calling client application.
|
||||
// Retrieve the permanent authorizations associated with the user and the application.
|
||||
var authorizations = await _authorizationManager.FindAsync(
|
||||
subject: await _userManager.GetUserIdAsync(user),
|
||||
client : await _applicationManager.GetIdAsync(application),
|
||||
@ -98,7 +98,8 @@ switch (await _applicationManager.GetConsentTypeAsync(application))
|
||||
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme,
|
||||
properties: new AuthenticationProperties(new Dictionary<string, string>
|
||||
{
|
||||
[OpenIddictServerAspNetCoreConstants.Properties.Error] = Errors.ConsentRequired,
|
||||
[OpenIddictServerAspNetCoreConstants.Properties.Error] =
|
||||
Errors.ConsentRequired,
|
||||
[OpenIddictServerAspNetCoreConstants.Properties.ErrorDescription] =
|
||||
"The logged in user is not allowed to access this client application."
|
||||
}));
|
||||
@ -107,14 +108,16 @@ switch (await _applicationManager.GetConsentTypeAsync(application))
|
||||
// return an authorization response without displaying the consent form.
|
||||
case ConsentTypes.Implicit:
|
||||
case ConsentTypes.External when authorizations.Any():
|
||||
case ConsentTypes.Explicit when authorizations.Any() && !request.HasPrompt(Prompts.Consent):
|
||||
case ConsentTypes.Explicit when authorizations.Any() &&
|
||||
!request.HasPrompt(Prompts.Consent):
|
||||
var principal = await _signInManager.CreateUserPrincipalAsync(user);
|
||||
|
||||
// Note: in this sample, the granted scopes match the requested scope
|
||||
// but you may want to allow the user to uncheck specific scopes.
|
||||
// For that, simply restrict the list of scopes before calling SetScopes.
|
||||
principal.SetScopes(request.GetScopes());
|
||||
principal.SetResources(await _scopeManager.ListResourcesAsync(principal.GetScopes()).ToListAsync());
|
||||
principal.SetResources(await _scopeManager.ListResourcesAsync(
|
||||
principal.GetScopes()).ToListAsync());
|
||||
|
||||
// Automatically create a permanent authorization to avoid requiring explicit consent
|
||||
// for future authorization or token requests containing the same scopes.
|
||||
@ -146,7 +149,8 @@ switch (await _applicationManager.GetConsentTypeAsync(application))
|
||||
authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme,
|
||||
properties: new AuthenticationProperties(new Dictionary<string, string>
|
||||
{
|
||||
[OpenIddictServerAspNetCoreConstants.Properties.Error] = Errors.ConsentRequired,
|
||||
[OpenIddictServerAspNetCoreConstants.Properties.Error] =
|
||||
Errors.ConsentRequired,
|
||||
[OpenIddictServerAspNetCoreConstants.Properties.ErrorDescription] =
|
||||
"Interactive user consent is required."
|
||||
}));
|
||||
|
@ -9861,7 +9861,7 @@
|
||||
"output": {
|
||||
".html": {
|
||||
"relative_path": "configuration/authorization-storage.html",
|
||||
"hash": "u/HsIJFZPle5GhsRMjBbeA=="
|
||||
"hash": "OFSAAR/675OwAhhWVsS24w=="
|
||||
}
|
||||
},
|
||||
"is_incremental": false,
|
||||
|
Loading…
Reference in New Issue
Block a user