Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
779242f
chore: make indexing more resiliant
bielu1 Jun 3, 2024
ad5ccef
POC: add populator information to reindex model
bielu Jun 15, 2024
eb97962
Render folders before files in static files picker. (#18701)
AndyButland Mar 18, 2025
5570583
Fixes issue with macro rendering in an RTE when GUIDs are used for ba…
AndyButland Mar 18, 2025
68acc2a
Bumped version to 13.9.0-rc.
AndyButland Mar 19, 2025
eb91f4f
Make preview check for delivery API content case insensitive. (#18731)
AndyButland Mar 20, 2025
9284b9e
Make preview check for delivery API content case insensitive. (#18731)
AndyButland Mar 20, 2025
42a81be
V13 hotfix sqlserver integration tests (#18744)
andr317c Mar 20, 2025
fdca086
build(deps): bump @umbraco-ui/uui from 1.12.2 to 1.13.0 (#18830)
iOvergaard Mar 26, 2025
05a7d33
Check we have matched a preview URL by ID when exiting preview. (#18841)
AndyButland Apr 3, 2025
3e9ff6b
Check we have matched a preview URL by ID when exiting preview. (#18841)
AndyButland Apr 3, 2025
d60a2a2
Verify endpoint selection candidates with host attribute are ignored …
AndyButland Apr 3, 2025
a3db456
Move database cache rebuild to a background task with polling (13) (#…
AndyButland Apr 3, 2025
0f02584
attempted fix for Datepicker v13 issue #16008 (#18903)
Navya-Sinhaa Apr 4, 2025
0e0aca5
Verify endpoint selection candidates with host attribute are ignored …
AndyButland Apr 3, 2025
3c8a621
Merge branch 'v13/dev' into v13/contrib
AndyButland Apr 4, 2025
a486d5d
Bumped version to 13.8.0.
AndyButland Apr 10, 2025
7d9a2c6
Merge branch 'release/13.8.0' into v13/dev
AndyButland Apr 10, 2025
ab31fbb
Bump version to 13.8.1.
AndyButland Apr 17, 2025
c6effef
Handle file paths as not found in delivery API by route requests (#19…
AndyButland Apr 22, 2025
afa6fa5
attempted fix for Save and Preview button #15360 (#19138)
Navya-Sinhaa Apr 25, 2025
a22dcf0
Merge branch 'v13/contrib' into v13/dev
AndyButland Apr 28, 2025
a62fa93
Use windows agent for nuget push
nikolajlauridsen Apr 28, 2025
097d045
V13 QA updated pipeline for acceptance to avoid issue when installing…
andr317c Apr 29, 2025
8d85259
Upgrade examine to 3.7.1 (#19186)
dawoe Apr 29, 2025
d499655
Merge branch 'v13/contrib' into v13/dev
AndyButland Apr 29, 2025
1efe860
V13: Clear Member Username Cache in Load Balanced Environments (#19191)
nikolajlauridsen Apr 29, 2025
3caa43a
Fix root path regression for the Delivery API (#19216)
kjac May 3, 2025
83107bb
Fix: #18421 - Added Max Length validation to PropertyTypeBasic Alias …
danielhnelson May 5, 2025
34709be
Merge commit from fork
AndyButland May 6, 2025
e94e165
Fixed pipeline definition.
AndyButland May 6, 2025
dcbbed4
Fixed failures in unit tests.
AndyButland May 6, 2025
5ba40c6
Merge branch 'release/13.8.1' into v13/dev
AndyButland May 6, 2025
643f073
`TimedScope` improvements and login duration clean-up (#19243)
ronaldbarendse May 7, 2025
6a4aa04
Handle existing RichTextEditorValue when parsing from markup or JSON …
AndyButland May 8, 2025
0eee307
Added custom RichTextRegexValidator to validate markup instead of JSO…
tomvanenckevort May 8, 2025
3d44a6f
Invalidate external login session on removal of provider (#19273)
AndyButland May 9, 2025
c0a0a34
Backport variable name updates and fix found porting the invalidation…
AndyButland May 9, 2025
0fb91ef
add single blocklist delete (#18073)
Migaroez May 12, 2025
e471c1f
[V13] User notifications not sent correctly when having more than 400…
May 13, 2025
0597662
Fix for block grid styling regression issue #15973 (#19014)
Lili-Rossiter May 13, 2025
4f1604f
V13/bugfix/partial cache (#19314)
Migaroez May 14, 2025
6c2f93e
V13 QA Updated linux test images to match actual (#19309)
andr317c May 14, 2025
0fc5b2a
Avoids unnecessary additional domain save notification publishing whe…
AndyButland May 14, 2025
87b2153
Adds support for retrieval of data type references when data type is …
AndyButland May 14, 2025
8433b2b
User invite email fails if visited more than once without completing …
dchallener May 14, 2025
7d6a1e5
Optimize the member save as part of the member login process, by-pass…
AndyButland May 20, 2025
127c6c4
Optimize the member save as part of the member login process, by-pass…
AndyButland May 20, 2025
eee04f4
fix: check for NullRepresentationInCache in AppCacheExtensions (#19350)
AndyButland May 22, 2025
5556b0f
Fixed check for navigation to list after delete of member (#19364)
AndyButland May 22, 2025
c609caf
Fixed check for navigation to list after delete of member (#19364)
AndyButland May 22, 2025
d4e6af5
Merge branch 'release/13.9' into v13/dev
AndyButland May 22, 2025
d677e94
Fix issue with requests to delivery API by path where URL segment con…
AndyButland May 23, 2025
4d8ca45
Removes unnecessary newlines from rich text as JSON delivery API outp…
AndyButland May 23, 2025
7f4a8d5
Merge branch 'v13/dev' into v13/main
AndyButland May 27, 2025
b348b84
Lock appropriate tree for media operations (#19422)
rbottema May 27, 2025
4b83a74
Resolved exception thrown from NuCache locking mechanism on near-simu…
AndyButland May 28, 2025
ebd228c
Ensure tag operations are case insensitive on insert across database …
AndyButland May 30, 2025
0bcae3e
Fix null member edgecase (#19463)
Migaroez Jun 3, 2025
97cc3ca
Bumped version to 13.9.0.
AndyButland Jun 5, 2025
1d6e7f1
Bumped version to 13.9.1.
AndyButland Jun 5, 2025
a01382d
Merge branch 'release/13.9' into v13/dev
AndyButland Jun 5, 2025
28570b4
Fix issues with removal of user logins on change to external login pr…
AndyButland Jun 10, 2025
f6dbe0f
Bumped version to 13.9.2.
AndyButland Jun 10, 2025
e1b9e5e
Merge branch 'release/13.9.1' into v13/dev
AndyButland Jun 10, 2025
1e66fb6
Add a warning to the `CreateContentFromBlueprint` method xml docs (#1…
lauraneto Jun 13, 2025
881535a
Merge branch 'v13/dev' into v13/main
AndyButland Jun 13, 2025
4ad18dc
Preserve word boundaries when indexing RTE content with <br> tags (#1…
steveatkiss Jun 23, 2025
b414456
Merge commit from fork
kjac Jun 24, 2025
1f5c21c
Fix pagination in Content Delivery API Index Helper (#19606)
Brynjarth Jul 1, 2025
990e379
Ensures that null values aren't used to create a CompositeStringStrin…
AndyButland Jul 1, 2025
fd95dc3
Merge branch 'release/13.9.2' into v13/dev
AndyButland Jul 2, 2025
a60ccd3
#16772 partial fix backoffice redirect after login (#19663)
kows Jul 7, 2025
13a2cd7
Clear member cache by older user name when member user name is update…
AndyButland Jul 7, 2025
53cc663
Register no-op implementation of IMemberPartialViewCacheInvalidator i…
AndyButland Jul 8, 2025
2748fdf
Adds variation by the header name Accept-Language to the delivery API…
AndyButland Jul 11, 2025
ce40103
Add support for programmatic creation of property types providing the…
AndyButland Jul 15, 2025
417f151
Parse update date before sorting in media list view (#19711)
AndyButland Jul 16, 2025
ebd0017
Bumped version to 13.9.3.
AndyButland Jul 21, 2025
67abecc
Add defensive coding to the member application initializer (#19760)
kjac Jul 21, 2025
59ad072
Retrieve only user external logins when invalidate following removal …
AndyButland Jul 22, 2025
22f7481
Bumped version to 13.11.0-rc.
AndyButland Jul 22, 2025
509a2e1
The filter param should be urlencoded (#19774)
AaronSadlerUK Jul 23, 2025
0d94f8b
Fix issue with use of EF Core scopes within notification handlers (ta…
Migaroez Jul 25, 2025
9f37db1
Merge commit from fork
AndyButland Jul 29, 2025
8eff28b
Merge branch 'release/13.9.3' into v13/dev
AndyButland Jul 29, 2025
a352c42
Merge branch 'release/13.9.3' into release/13.10
AndyButland Jul 29, 2025
b622e7e
Content picker search with start node configured not taking user star…
lauraneto Aug 1, 2025
214f3fb
Umbraco Engage UmbracoUrlAlias Fix - Fixes #19654 (#19827)
cornehoskam Aug 4, 2025
784e09e
Use a regex to filter our invalid culture codes rather than relying o…
AndyButland Aug 6, 2025
c2890e1
Bumped version to 13.10.0
AndyButland Aug 14, 2025
33e201c
Merge branch 'release/13.10' into v13/dev
AndyButland Aug 14, 2025
85aa6d3
Add Arabic (ar) backoffice translation (#19896)
tarikrital Aug 15, 2025
45f7b7a
Retain original backoffice location on login after timeout (#19984)
AndyButland Sep 15, 2025
60f84f7
Support querystring and anchor for local links in Delivery API output
kjac Sep 15, 2025
fe358b8
Merge branch 'v13/bugfix/18475-locallinks-parsing' of https://github.…
AndyButland Sep 16, 2025
a282002
Support querystring and anchor for local links in Delivery API output…
kjac Sep 16, 2025
e119186
Avoid throwing an exception on getting references when migrating cont…
AndyButland Sep 16, 2025
7c180f6
Merge branch 'v13/dev' of https://github.com/umbraco/Umbraco-CMS into…
AndyButland Sep 16, 2025
301be35
Make notification service able to handle segmented content (#20160)
kjac Sep 17, 2025
37e6d1e
Merge branch 'v13/dev' into feat/make-indexing-more-resiliant
nielslyngsoe Sep 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<EnableStrictModeForCompatibleTfms>true</EnableStrictModeForCompatibleTfms>
</PropertyGroup>

<!-- Calculate version only once for the whole repository -->
<!-- Calculate version only once for the whole repository -->
<PropertyGroup>
<GitVersionBaseDirectory>$(MSBuildThisFileDirectory)</GitVersionBaseDirectory>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<PackageVersion Include="Asp.Versioning.Mvc" Version="7.1.1" />
<PackageVersion Include="Asp.Versioning.Mvc.ApiExplorer" Version="7.1.0" />
<PackageVersion Include="Dazinator.Extensions.FileProviders" Version="2.0.0" />
<PackageVersion Include="Examine" Version="3.7.0" />
<PackageVersion Include="Examine.Core" Version="3.7.0" />
<PackageVersion Include="Examine" Version="3.7.1" />
<PackageVersion Include="Examine.Core" Version="3.7.1" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.71" />
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageVersion Include="MailKit" Version="4.8.0" />
Expand Down
42 changes: 34 additions & 8 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ stages:
# Integration Tests (SQL Server)
- job:
timeoutInMinutes: 120
condition: or(eq(stageDependencies.Build.A.outputs['build.NBGV_PublicRelease'], 'True'), ${{parameters.sqlServerIntegrationTests}})
# We are currently encountering issues when running SQL Server Linux tests Microsoft.Data.SqlClient.SqlException (0x80131904)
# condition: or(eq(stageDependencies.Build.A.outputs['build.NBGV_PublicRelease'], 'True'), ${{parameters.sqlServerIntegrationTests}})
condition: eq(${{parameters.sqlServerIntegrationTests}}, True)
displayName: Integration Tests (SQL Server)
strategy:
matrix:
Expand Down Expand Up @@ -529,8 +531,8 @@ stages:
workingDirectory: tests/Umbraco.Tests.AcceptanceTest

# Install Playwright and dependencies
- pwsh: npx playwright install --with-deps
displayName: Install Playwright
- pwsh: npx playwright install chromium
displayName: Install Playwright only with Chromium browser
workingDirectory: tests/Umbraco.Tests.AcceptanceTest

# Test
Expand Down Expand Up @@ -560,13 +562,24 @@ stages:
displayName: Copy Playwright results
condition: succeededOrFailed()

# Publish
# Publish test artifacts
- task: PublishPipelineArtifact@1
displayName: Publish test artifacts
condition: succeededOrFailed()
inputs:
targetPath: $(Build.ArtifactStagingDirectory)
artifact: "Acceptance Test Results - $(Agent.JobName) - Attempt #$(System.JobAttempt)"

# Publish test results
- task: PublishTestResults@2
displayName: "Publish test results"
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '*.xml'
searchFolder: "tests/Umbraco.Tests.AcceptanceTest/results"
testRunTitle: "$(Agent.JobName)"

- job:
displayName: E2E Tests (SQL Server)
condition: or(eq(stageDependencies.Build.A.outputs['build.NBGV_PublicRelease'], 'True'), ${{parameters.sqlServerAcceptanceTests}})
Expand Down Expand Up @@ -685,14 +698,13 @@ stages:
workingDirectory: tests/Umbraco.Tests.AcceptanceTest

# Install Playwright and dependencies
- pwsh: npx playwright install --with-deps
displayName: Install Playwright
- pwsh: npx playwright install chromium
displayName: Install Playwright only with Chromium browser
workingDirectory: tests/Umbraco.Tests.AcceptanceTest

# Test
- pwsh: $(testCommand)
displayName: Run Playwright tests
continueOnError: true
workingDirectory: tests/Umbraco.Tests.AcceptanceTest
env:
CI: true
Expand Down Expand Up @@ -725,14 +737,24 @@ stages:
displayName: Copy Playwright results
condition: succeededOrFailed()

# Publish
# Publish test artifacts
- task: PublishPipelineArtifact@1
displayName: Publish test artifacts
condition: succeededOrFailed()
inputs:
targetPath: $(Build.ArtifactStagingDirectory)
artifact: "Acceptance Test Results - $(Agent.JobName) - Attempt #$(System.JobAttempt)"

# Publish test results
- task: PublishTestResults@2
displayName: "Publish test results"
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '*.xml'
searchFolder: "tests/Umbraco.Tests.AcceptanceTest/results"
testRunTitle: "$(Agent.JobName)"

###############################################
## Release
###############################################
Expand All @@ -745,6 +767,8 @@ stages:
condition: and(succeeded(), or(eq(dependencies.Build.outputs['A.build.NBGV_PublicRelease'], 'True'), ${{parameters.myGetDeploy}}))
jobs:
- job:
pool:
vmImage: "windows-latest" # NuGetCommand@2 is no longer supported on Ubuntu 24.04 so we'll use windows until an alternative is available.
displayName: Push to pre-release feed
steps:
- checkout: none
Expand All @@ -771,6 +795,8 @@ stages:
condition: and(succeeded(), or(eq(dependencies.Build.outputs['A.build.NBGV_PublicRelease'], 'True'), ${{parameters.nuGetDeploy}}))
jobs:
- job:
pool:
vmImage: "windows-latest" # NuGetCommand@2 is no longer supported on Ubuntu 24.04 so we'll use windows until an alternative is available.
displayName: Push to NuGet
steps:
- checkout: none
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
using Microsoft.AspNetCore.OutputCaching;
using Microsoft.AspNetCore.OutputCaching;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Primitives;
using Umbraco.Cms.Core.DeliveryApi;

namespace Umbraco.Cms.Api.Delivery.Caching;

internal sealed class DeliveryApiOutputCachePolicy : IOutputCachePolicy
{
private readonly TimeSpan _duration;
private readonly StringValues _varyByHeaderNames;

public DeliveryApiOutputCachePolicy(TimeSpan duration)
=> _duration = duration;
public DeliveryApiOutputCachePolicy(TimeSpan duration, StringValues varyByHeaderNames)
{
_duration = duration;
_varyByHeaderNames = varyByHeaderNames;
}

ValueTask IOutputCachePolicy.CacheRequestAsync(OutputCacheContext context, CancellationToken cancellationToken)
{
Expand All @@ -18,8 +23,14 @@ ValueTask IOutputCachePolicy.CacheRequestAsync(OutputCacheContext context, Cance
.RequestServices
.GetRequiredService<IRequestPreviewService>();

context.EnableOutputCaching = requestPreviewService.IsPreview() is false;
IApiAccessService apiAccessService = context
.HttpContext
.RequestServices
.GetRequiredService<IApiAccessService>();

context.EnableOutputCaching = requestPreviewService.IsPreview() is false && apiAccessService.HasPublicAccess();
context.ResponseExpirationTimeSpan = _duration;
context.CacheVaryByRules.HeaderNames = _varyByHeaderNames;

return ValueTask.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ByRouteContentApiController : ContentApiItemControllerBase
private readonly IRequestRedirectService _requestRedirectService;
private readonly IRequestPreviewService _requestPreviewService;
private readonly IRequestMemberAccessService _requestMemberAccessService;
private const string PreviewContentRequestPathPrefix = $"/{Constants.DeliveryApi.Routing.PreviewContentPathPrefix}";
private const string PreviewContentRequestPathPrefix = $"/{Umbraco.Cms.Core.Constants.DeliveryApi.Routing.PreviewContentPathPrefix}";

[Obsolete($"Please use the constructor that does not accept {nameof(IPublicAccessService)}. Will be removed in V14.")]
public ByRouteContentApiController(
Expand Down Expand Up @@ -145,6 +145,11 @@ private async Task<IActionResult> HandleRequest(string path)
path = DecodePath(path);
path = path.Length == 0 ? "/" : path;

if (_apiContentPathResolver.IsResolvablePath(path) is false)
{
return NotFound();
}

IPublishedContent? contentItem = GetContent(path);
if (contentItem is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Primitives;
using Umbraco.Cms.Api.Common.DependencyInjection;
using Umbraco.Cms.Api.Delivery.Accessors;
using Umbraco.Cms.Api.Delivery.Caching;
Expand Down Expand Up @@ -108,12 +109,20 @@ private static IUmbracoBuilder AddOutputCache(this IUmbracoBuilder builder)

if (outputCacheSettings.ContentDuration.TotalSeconds > 0)
{
options.AddPolicy(Constants.DeliveryApi.OutputCache.ContentCachePolicy, new DeliveryApiOutputCachePolicy(outputCacheSettings.ContentDuration));
options.AddPolicy(
Constants.DeliveryApi.OutputCache.ContentCachePolicy,
new DeliveryApiOutputCachePolicy(
outputCacheSettings.ContentDuration,
new StringValues([Constants.DeliveryApi.HeaderNames.AcceptLanguage, Constants.DeliveryApi.HeaderNames.StartItem])));
}

if (outputCacheSettings.MediaDuration.TotalSeconds > 0)
{
options.AddPolicy(Constants.DeliveryApi.OutputCache.MediaCachePolicy, new DeliveryApiOutputCachePolicy(outputCacheSettings.MediaDuration));
options.AddPolicy(
Constants.DeliveryApi.OutputCache.MediaCachePolicy,
new DeliveryApiOutputCachePolicy(
outputCacheSettings.MediaDuration,
Constants.DeliveryApi.HeaderNames.StartItem));
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using Umbraco.Cms.Api.Delivery.Configuration;
Expand All @@ -21,7 +21,7 @@ protected override void ApplyOperation(OpenApiOperation operation, OperationFilt

operation.Parameters.Add(new OpenApiParameter
{
Name = "Accept-Language",
Name = Core.Constants.DeliveryApi.HeaderNames.AcceptLanguage,
In = ParameterLocation.Header,
Required = false,
Description = "Defines the language to return. Use this when querying language variant content items.",
Expand All @@ -37,7 +37,7 @@ protected override void ApplyOperation(OpenApiOperation operation, OperationFilt

operation.Parameters.Add(new OpenApiParameter
{
Name = "Preview",
Name = Core.Constants.DeliveryApi.HeaderNames.Preview,
In = ParameterLocation.Header,
Required = false,
Description = "Whether to request draft content.",
Expand All @@ -46,7 +46,7 @@ protected override void ApplyOperation(OpenApiOperation operation, OperationFilt

operation.Parameters.Add(new OpenApiParameter
{
Name = "Start-Item",
Name = Core.Constants.DeliveryApi.HeaderNames.StartItem,
In = ParameterLocation.Header,
Required = false,
Description = "URL segment or GUID of a root content item.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
Expand Down Expand Up @@ -63,7 +63,7 @@ protected void AddFields(OpenApiOperation operation, OperationFilterContext cont
protected void AddApiKey(OpenApiOperation operation) =>
operation.Parameters.Add(new OpenApiParameter
{
Name = "Api-Key",
Name = Core.Constants.DeliveryApi.HeaderNames.ApiKey,
In = ParameterLocation.Header,
Required = false,
Description = "API key specified through configuration to authorize access to the API.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;
using Umbraco.Cms.Infrastructure.Security;

namespace Umbraco.Cms.Api.Delivery.Handlers;
Expand All @@ -16,16 +17,21 @@ internal sealed class InitializeMemberApplicationNotificationHandler : INotifica
private readonly ILogger<InitializeMemberApplicationNotificationHandler> _logger;
private readonly DeliveryApiSettings _deliveryApiSettings;
private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IServerRoleAccessor _serverRoleAccessor;
private static readonly SemaphoreSlim _locker = new(1);
private static bool _isInitialized = false;

public InitializeMemberApplicationNotificationHandler(
IRuntimeState runtimeState,
IOptions<DeliveryApiSettings> deliveryApiSettings,
ILogger<InitializeMemberApplicationNotificationHandler> logger,
IServiceScopeFactory serviceScopeFactory)
IServiceScopeFactory serviceScopeFactory,
IServerRoleAccessor serverRoleAccessor)
{
_runtimeState = runtimeState;
_logger = logger;
_serviceScopeFactory = serviceScopeFactory;
_serverRoleAccessor = serverRoleAccessor;
_deliveryApiSettings = deliveryApiSettings.Value;
}

Expand All @@ -36,34 +42,55 @@ public async Task HandleAsync(UmbracoApplicationStartingNotification notificatio
return;
}

// we cannot inject the IMemberApplicationManager because it ultimately takes a dependency on the DbContext ... and during
// install that is not allowed (no connection string means no DbContext)
using IServiceScope scope = _serviceScopeFactory.CreateScope();
IMemberApplicationManager memberApplicationManager = scope.ServiceProvider.GetRequiredService<IMemberApplicationManager>();

if (_deliveryApiSettings.MemberAuthorization?.AuthorizationCodeFlow?.Enabled is not true)
if (_serverRoleAccessor.CurrentServerRole is ServerRole.Subscriber)
{
await memberApplicationManager.DeleteMemberApplicationAsync(cancellationToken);
// subscriber instances should not alter the member application
return;
}

if (ValidateRedirectUrls(_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LoginRedirectUrls) is false)
try
{
await memberApplicationManager.DeleteMemberApplicationAsync(cancellationToken);
return;
}
await _locker.WaitAsync(cancellationToken);
if (_isInitialized)
{
return;
}

_isInitialized = true;

// we cannot inject the IMemberApplicationManager because it ultimately takes a dependency on the DbContext ... and during
// install that is not allowed (no connection string means no DbContext)
using IServiceScope scope = _serviceScopeFactory.CreateScope();
IMemberApplicationManager memberApplicationManager = scope.ServiceProvider.GetRequiredService<IMemberApplicationManager>();

if (_deliveryApiSettings.MemberAuthorization?.AuthorizationCodeFlow?.Enabled is not true)
{
await memberApplicationManager.DeleteMemberApplicationAsync(cancellationToken);
return;
}

if (_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LogoutRedirectUrls.Any()
&& ValidateRedirectUrls(_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LogoutRedirectUrls) is false)
if (ValidateRedirectUrls(_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LoginRedirectUrls) is false)
{
await memberApplicationManager.DeleteMemberApplicationAsync(cancellationToken);
return;
}

if (_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LogoutRedirectUrls.Any()
&& ValidateRedirectUrls(_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LogoutRedirectUrls) is false)
{
await memberApplicationManager.DeleteMemberApplicationAsync(cancellationToken);
return;
}

await memberApplicationManager.EnsureMemberApplicationAsync(
_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LoginRedirectUrls,
_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LogoutRedirectUrls,
cancellationToken);
}
finally
{
await memberApplicationManager.DeleteMemberApplicationAsync(cancellationToken);
return;
_locker.Release();
}

await memberApplicationManager.EnsureMemberApplicationAsync(
_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LoginRedirectUrls,
_deliveryApiSettings.MemberAuthorization.AuthorizationCodeFlow.LogoutRedirectUrls,
cancellationToken);
}

private bool ValidateRedirectUrls(Uri[] redirectUrls)
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Cms.Api.Delivery/Services/ApiAccessService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.DeliveryApi;
Expand Down Expand Up @@ -29,7 +29,7 @@ public ApiAccessService(IHttpContextAccessor httpContextAccessor, IOptionsMonito
private bool IfEnabled(Func<bool> condition) => _deliveryApiSettings.Enabled && condition();

private bool HasValidApiKey() => _deliveryApiSettings.ApiKey.IsNullOrWhiteSpace() == false
&& _deliveryApiSettings.ApiKey.Equals(GetHeaderValue("Api-Key"));
&& _deliveryApiSettings.ApiKey.Equals(GetHeaderValue(Core.Constants.DeliveryApi.HeaderNames.ApiKey));

private bool IfMediaEnabled(Func<bool> condition) => _deliveryApiSettings is { Enabled: true, Media.Enabled: true } && condition();
}
Loading
Loading