Skip to content

Commit 4b9771c

Browse files
committed
Merge branch 'v13/dev' into v14/dev
# Conflicts: # Directory.Packages.props # build/azure-pipelines.yml # src/Umbraco.Cms.Api.Common/DependencyInjection/UmbracoBuilderAuthExtensions.cs # src/Umbraco.Cms.Persistence.EFCore/Locking/SqlServerEFCoreDistributedLockingMechanism.cs # src/Umbraco.Core/Configuration/Models/RichTextEditorSettings.cs # src/Umbraco.Core/EmbeddedResources/Lang/da.xml # src/Umbraco.Core/EmbeddedResources/Lang/en.xml # src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml # src/Umbraco.Core/Services/ContentService.cs # src/Umbraco.Web.BackOffice/Authorization/ContentPermissionsQueryStringHandler.cs # src/Umbraco.Web.BackOffice/Authorization/ContentPermissionsResourceHandler.cs # src/Umbraco.Web.BackOffice/Controllers/ContentController.cs # src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs # src/Umbraco.Web.BackOffice/Controllers/MediaController.cs # src/Umbraco.Web.BackOffice/Trees/StaticFilesTreeController.cs # src/Umbraco.Web.UI.Client/package-lock.json # src/Umbraco.Web.UI.Client/package.json # src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbbuttongroup.directive.js # src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js # src/Umbraco.Web.UI.Client/src/common/filters/simpleMarkdown.filter.js # src/Umbraco.Web.UI.Client/src/common/filters/simpleMarkdown.filter.js.js # src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js # src/Umbraco.Web.UI.Client/src/less/components/umb-group-builder.less # src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/mediaentryeditor/mediaentryeditor.less # src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/propertysettings/propertysettings.html # src/Umbraco.Web.UI.Client/src/views/common/overlays/ysod/ysod.controller.js # src/Umbraco.Web.UI.Client/src/views/common/overlays/ysod/ysod.html # src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button-group.html # src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.controller.js # src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockgrid/prevalue/blockgrid.blockconfiguration.overlay.controller.js # src/Umbraco.Web.UI.Client/src/views/propertyeditors/blockgrid/prevalue/blockgrid.blockconfiguration.overlay.html # src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/prevalue/blocklist.blockconfiguration.overlay.controller.js # src/Umbraco.Web.UI.Client/src/views/propertyeditors/blocklist/prevalue/blocklist.blockconfiguration.overlay.html # src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.component.js # src/Umbraco.Web.UI.Client~HEAD # src/Umbraco.Web.UI.Login/package-lock.json # src/Umbraco.Web.UI.Login/package.json # tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/BlockGridEditor/Content/blockGridEditorContent.spec.ts # tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceNotificationTests.cs # tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs # tools/Umbraco.JsonSchema/UmbracoCmsSchema.cs # version.json
2 parents 58d6404 + 60e3fa9 commit 4b9771c

File tree

35 files changed

+11014
-104
lines changed

35 files changed

+11014
-104
lines changed

Directory.Packages.props

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@
1212
</ItemGroup>
1313
<!-- Microsoft packages -->
1414
<ItemGroup>
15-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.8" />
16-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.8" />
15+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.11" />
16+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.11" />
1717
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
18-
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.8" />
19-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
20-
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
21-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8" />
18+
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.11" />
19+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.11" />
20+
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
21+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.11" />
2222
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
2323
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
2424
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
2525
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
26-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
27-
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.8" />
26+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
27+
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.11" />
2828
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="8.0.0" />
2929
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
30-
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
31-
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="8.0.8" />
32-
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="8.0.8" />
33-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
30+
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
31+
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="8.0.11" />
32+
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="8.0.11" />
33+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.1" />
3434
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" />
3535
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
3636
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
@@ -45,14 +45,14 @@
4545
<PackageVersion Include="Asp.Versioning.Mvc" Version="8.1.0" />
4646
<PackageVersion Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
4747
<PackageVersion Include="Dazinator.Extensions.FileProviders" Version="2.0.0" />
48-
<PackageVersion Include="Examine" Version="3.3.0" />
49-
<PackageVersion Include="Examine.Core" Version="3.3.0" />
50-
<PackageVersion Include="HtmlAgilityPack" Version="1.11.65" />
48+
<PackageVersion Include="Examine" Version="3.5.0" />
49+
<PackageVersion Include="Examine.Core" Version="3.5.0" />
50+
<PackageVersion Include="HtmlAgilityPack" Version="1.11.71" />
5151
<PackageVersion Include="JsonPatch.Net" Version="3.1.1" />
5252
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
53-
<PackageVersion Include="MailKit" Version="4.7.1.1" />
53+
<PackageVersion Include="MailKit" Version="4.8.0" />
5454
<PackageVersion Include="Markdown" Version="2.2.1" />
55-
<PackageVersion Include="MessagePack" Version="2.5.187" />
55+
<PackageVersion Include="MessagePack" Version="2.5.192" />
5656
<PackageVersion Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" />
5757
<PackageVersion Include="MiniProfiler.Shared" Version="4.3.8" />
5858
<PackageVersion Include="ncrontab" Version="3.3.3" />
@@ -62,32 +62,34 @@
6262
<PackageVersion Include="OpenIddict.AspNetCore" Version="5.7.0" />
6363
<PackageVersion Include="OpenIddict.EntityFrameworkCore" Version="5.7.0" />
6464
<PackageVersion Include="Serilog" Version="3.1.1" />
65-
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.2" />
65+
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.3" />
6666
<PackageVersion Include="Serilog.Enrichers.Process" Version="2.0.2" />
6767
<PackageVersion Include="Serilog.Enrichers.Thread" Version="3.1.0" />
6868
<PackageVersion Include="Serilog.Expressions" Version="4.0.0" />
6969
<PackageVersion Include="Serilog.Extensions.Hosting" Version="8.0.0" />
7070
<PackageVersion Include="Serilog.Formatting.Compact" Version="2.0.0" />
7171
<PackageVersion Include="Serilog.Formatting.Compact.Reader" Version="3.0.0" />
72-
<PackageVersion Include="Serilog.Settings.Configuration" Version="8.0.2" />
72+
<PackageVersion Include="Serilog.Settings.Configuration" Version="8.0.4" />
7373
<PackageVersion Include="Serilog.Sinks.Async" Version="1.5.0" />
7474
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
7575
<PackageVersion Include="Serilog.Sinks.Map" Version="1.0.2" />
76-
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.5" />
76+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.6" />
7777
<PackageVersion Include="SixLabors.ImageSharp.Web" Version="3.1.3" />
78-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.7.3" />
78+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.9.0" />
7979
</ItemGroup>
8080
<!-- Transitive pinned versions (only required because our direct dependencies have vulnerable versions of transitive dependencies) -->
8181
<ItemGroup>
8282
<!-- Both Microsoft.EntityFrameworkCore.SqlServer and NPoco.SqlServer bring in a vulnerable version of Azure.Identity -->
83-
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
83+
<PackageVersion Include="Azure.Identity" Version="1.13.1" />
8484
<!-- Dazinator.Extensions.FileProviders brings in a vulnerable version of System.Net.Http -->
8585
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
8686
<!-- Examine brings in a vulnerable version of System.Security.Cryptography.Xml -->
87-
<PackageVersion Include="System.Security.Cryptography.Xml" Version="8.0.1" />
87+
<PackageVersion Include="System.Security.Cryptography.Xml" Version="8.0.2" />
8888
<!-- Both Dazinator.Extensions.FileProviders and MiniProfiler.AspNetCore.Mvc bring in a vulnerable version of System.Text.RegularExpressions -->
8989
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
9090
<!-- Both OpenIddict.AspNetCore, Npoco.SqlServer and Microsoft.EntityFrameworkCore.SqlServer bring in a vulnerable version of Microsoft.IdentityModel.JsonWebTokens -->
9191
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.7.1" />
92+
<!-- Examine.Lucene bring in a vulnerable version of Lucene.Net.Replicator -->
93+
<PackageVersion Include="Lucene.Net.Replicator" Version="4.8.0-beta00017" />
9294
</ItemGroup>
9395
</Project>

src/Umbraco.Cms.Api.Common/DependencyInjection/UmbracoBuilderAuthExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ private static void ConfigureOpenIddict(IUmbracoBuilder builder)
4646
Paths.BackOfficeApi.LogoutEndpoint.TrimStart(Constants.CharArrays.ForwardSlash))
4747
.SetRevocationEndpointUris(
4848
Paths.MemberApi.RevokeEndpoint.TrimStart(Constants.CharArrays.ForwardSlash),
49-
Paths.BackOfficeApi.RevokeEndpoint.TrimStart(Constants.CharArrays.ForwardSlash));
49+
Paths.BackOfficeApi.RevokeEndpoint.TrimStart(Constants.CharArrays.ForwardSlash))
50+
.SetUserinfoEndpointUris(
51+
Paths.MemberApi.UserinfoEndpoint.TrimStart(Constants.CharArrays.ForwardSlash));
5052

5153
// Enable authorization code flow with PKCE
5254
options
@@ -58,7 +60,8 @@ private static void ConfigureOpenIddict(IUmbracoBuilder builder)
5860
options
5961
.UseAspNetCore()
6062
.EnableAuthorizationEndpointPassthrough()
61-
.EnableLogoutEndpointPassthrough();
63+
.EnableLogoutEndpointPassthrough()
64+
.EnableUserinfoEndpointPassthrough();
6265

6366
// Enable reference tokens
6467
// - see https://documentation.openiddict.com/configuration/token-storage.html

src/Umbraco.Cms.Api.Common/Security/Paths.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public static class MemberApi
3131

3232
public static readonly string RevokeEndpoint = EndpointPath($"{EndpointTemplate}/revoke");
3333

34+
public static readonly string UserinfoEndpoint = EndpointPath($"{EndpointTemplate}/userinfo");
35+
3436
// NOTE: we're NOT using /api/v1.0/ here because it will clash with the Delivery API docs
3537
private static string EndpointPath(string relativePath) => $"/umbraco/delivery/api/v1/{relativePath}";
3638
}

src/Umbraco.Cms.Api.Delivery/Controllers/Content/ContentApiControllerBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace Umbraco.Cms.Api.Delivery.Controllers.Content;
1515
[ApiExplorerSettings(GroupName = "Content")]
1616
[LocalizeFromAcceptLanguageHeader]
1717
[ValidateStartItem]
18+
[AddVaryHeader]
1819
[OutputCache(PolicyName = Constants.DeliveryApi.OutputCache.ContentCachePolicy)]
1920
public abstract class ContentApiControllerBase : DeliveryApiControllerBase
2021
{
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Asp.Versioning;
2+
using Microsoft.AspNetCore.Authorization;
3+
using Microsoft.AspNetCore.Mvc;
4+
using OpenIddict.Server.AspNetCore;
5+
using Umbraco.Cms.Api.Delivery.Routing;
6+
using Umbraco.Cms.Api.Delivery.Services;
7+
8+
namespace Umbraco.Cms.Api.Delivery.Controllers.Security;
9+
10+
[ApiVersion("1.0")]
11+
[ApiController]
12+
[VersionedDeliveryApiRoute(Common.Security.Paths.MemberApi.EndpointTemplate)]
13+
[ApiExplorerSettings(IgnoreApi = true)]
14+
[Authorize(AuthenticationSchemes = OpenIddictServerAspNetCoreDefaults.AuthenticationScheme)]
15+
public class CurrentMemberController : DeliveryApiControllerBase
16+
{
17+
private readonly ICurrentMemberClaimsProvider _currentMemberClaimsProvider;
18+
19+
public CurrentMemberController(ICurrentMemberClaimsProvider currentMemberClaimsProvider)
20+
=> _currentMemberClaimsProvider = currentMemberClaimsProvider;
21+
22+
[HttpGet("userinfo")]
23+
public async Task<IActionResult> Userinfo()
24+
{
25+
Dictionary<string, object> claims = await _currentMemberClaimsProvider.GetClaimsAsync();
26+
return Ok(claims);
27+
}
28+
}

src/Umbraco.Cms.Api.Delivery/DependencyInjection/UmbracoBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public static IUmbracoBuilder AddDeliveryApi(this IUmbracoBuilder builder)
6060
builder.Services.AddSingleton<IApiMediaQueryService, ApiMediaQueryService>();
6161
builder.Services.AddTransient<IMemberApplicationManager, MemberApplicationManager>();
6262
builder.Services.AddTransient<IRequestMemberAccessService, RequestMemberAccessService>();
63+
builder.Services.AddTransient<ICurrentMemberClaimsProvider, CurrentMemberClaimsProvider>();
6364

6465
builder.Services.ConfigureOptions<ConfigureUmbracoDeliveryApiSwaggerGenOptions>();
6566
builder.AddUmbracoApiOpenApiUI();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.AspNetCore.Mvc.Filters;
2+
3+
namespace Umbraco.Cms.Api.Delivery.Filters;
4+
5+
public sealed class AddVaryHeaderAttribute : ActionFilterAttribute
6+
{
7+
private const string Vary = "Accept-Language, Preview, Start-Item";
8+
9+
public override void OnResultExecuting(ResultExecutingContext context)
10+
=> context.HttpContext.Response.Headers.Vary = context.HttpContext.Response.Headers.Vary.Count > 0
11+
? $"{context.HttpContext.Response.Headers.Vary}, {Vary}"
12+
: Vary;
13+
}

src/Umbraco.Cms.Api.Delivery/Querying/Filters/ContentTypeFilter.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Umbraco.Cms.Api.Delivery.Indexing.Filters;
22
using Umbraco.Cms.Core.DeliveryApi;
3-
using Umbraco.Extensions;
43

54
namespace Umbraco.Cms.Api.Delivery.Querying.Filters;
65

@@ -15,15 +14,15 @@ public bool CanHandle(string query)
1514
/// <inheritdoc/>
1615
public FilterOption BuildFilterOption(string filter)
1716
{
18-
var alias = filter.Substring(ContentTypeSpecifier.Length);
17+
var filterValue = filter.Substring(ContentTypeSpecifier.Length);
18+
var negate = filterValue.StartsWith('!');
19+
var aliases = filterValue.TrimStart('!').Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
1920

2021
return new FilterOption
2122
{
2223
FieldName = ContentTypeFilterIndexer.FieldName,
23-
Values = alias.IsNullOrWhiteSpace() == false
24-
? new[] { alias.TrimStart('!') }
25-
: Array.Empty<string>(),
26-
Operator = alias.StartsWith('!')
24+
Values = aliases,
25+
Operator = negate
2726
? FilterOperation.IsNot
2827
: FilterOperation.Is
2928
};

src/Umbraco.Cms.Api.Delivery/Querying/Selectors/AncestorsSelector.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
using Microsoft.Extensions.DependencyInjection;
12
using Umbraco.Cms.Api.Delivery.Indexing.Selectors;
23
using Umbraco.Cms.Core.DeliveryApi;
4+
using Umbraco.Cms.Core.DependencyInjection;
35
using Umbraco.Cms.Core.Models.PublishedContent;
46
using Umbraco.Cms.Core.PublishedCache;
57
using Umbraco.Extensions;
@@ -10,10 +12,22 @@ public sealed class AncestorsSelector : QueryOptionBase, ISelectorHandler
1012
{
1113
private const string AncestorsSpecifier = "ancestors:";
1214
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
15+
private readonly IRequestPreviewService _requestPreviewService;
1316

14-
public AncestorsSelector(IPublishedSnapshotAccessor publishedSnapshotAccessor, IRequestRoutingService requestRoutingService)
15-
: base(publishedSnapshotAccessor, requestRoutingService) =>
17+
[Obsolete("Please use the non-obsolete constructor. Will be removed in V17.")]
18+
public AncestorsSelector(
19+
IPublishedSnapshotAccessor publishedSnapshotAccessor,
20+
IRequestRoutingService requestRoutingService)
21+
: this(publishedSnapshotAccessor, requestRoutingService, StaticServiceProvider.Instance.GetRequiredService<IRequestPreviewService>())
22+
{
23+
}
24+
25+
public AncestorsSelector(IPublishedSnapshotAccessor publishedSnapshotAccessor, IRequestRoutingService requestRoutingService, IRequestPreviewService requestPreviewService)
26+
: base(publishedSnapshotAccessor, requestRoutingService)
27+
{
1628
_publishedSnapshotAccessor = publishedSnapshotAccessor;
29+
_requestPreviewService = requestPreviewService;
30+
}
1731

1832
/// <inheritdoc />
1933
public bool CanHandle(string query)
@@ -37,10 +51,20 @@ public SelectorOption BuildSelectorOption(string selector)
3751
};
3852
}
3953

40-
IPublishedSnapshot publishedSnapshot = _publishedSnapshotAccessor.GetRequiredPublishedSnapshot();
54+
IPublishedContentCache contentCache = _publishedSnapshotAccessor.GetRequiredPublishedSnapshot()?.Content
55+
?? throw new InvalidOperationException("Could not obtain the content cache");
56+
57+
IPublishedContent? contentItem = contentCache.GetById(_requestPreviewService.IsPreview(), id.Value);
4158

42-
IPublishedContent contentItem = publishedSnapshot.Content?.GetById((Guid)id)
43-
?? throw new InvalidOperationException("Could not obtain the content cache");
59+
if (contentItem is null)
60+
{
61+
// no such content item, make sure the selector does not yield any results
62+
return new SelectorOption
63+
{
64+
FieldName = AncestorsSelectorIndexer.FieldName,
65+
Values = Array.Empty<string>()
66+
};
67+
}
4468

4569
var ancestorKeys = contentItem.Ancestors().Select(a => a.Key.ToString("D")).ToArray();
4670

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using OpenIddict.Abstractions;
2+
using Umbraco.Cms.Core.Security;
3+
4+
namespace Umbraco.Cms.Api.Delivery.Services;
5+
6+
// NOTE: this is public and unsealed to allow overriding the default claims with minimal effort.
7+
public class CurrentMemberClaimsProvider : ICurrentMemberClaimsProvider
8+
{
9+
private readonly IMemberManager _memberManager;
10+
11+
public CurrentMemberClaimsProvider(IMemberManager memberManager)
12+
=> _memberManager = memberManager;
13+
14+
public virtual async Task<Dictionary<string, object>> GetClaimsAsync()
15+
{
16+
MemberIdentityUser? memberIdentityUser = await _memberManager.GetCurrentMemberAsync();
17+
return memberIdentityUser is not null
18+
? await GetClaimsForMemberIdentityAsync(memberIdentityUser)
19+
: throw new InvalidOperationException("Could not retrieve the current member. This method should only ever be invoked when a member has been authorized.");
20+
}
21+
22+
protected virtual async Task<Dictionary<string, object>> GetClaimsForMemberIdentityAsync(MemberIdentityUser memberIdentityUser)
23+
{
24+
var claims = new Dictionary<string, object>
25+
{
26+
[OpenIddictConstants.Claims.Subject] = memberIdentityUser.Key
27+
};
28+
29+
if (memberIdentityUser.Name is not null)
30+
{
31+
claims[OpenIddictConstants.Claims.Name] = memberIdentityUser.Name;
32+
}
33+
34+
if (memberIdentityUser.Email is not null)
35+
{
36+
claims[OpenIddictConstants.Claims.Email] = memberIdentityUser.Email;
37+
}
38+
39+
claims[OpenIddictConstants.Claims.Role] = await _memberManager.GetRolesAsync(memberIdentityUser);
40+
41+
return claims;
42+
}
43+
}

0 commit comments

Comments
 (0)