Skip to content

Commit 4c04c77

Browse files
committed
asset management fixes and runtime identifier
1 parent ef7e67b commit 4c04c77

File tree

9 files changed

+368
-171
lines changed

9 files changed

+368
-171
lines changed

Framework/Intersect.Framework.Core/AssetManagement/UpdateManifestFile.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ public int CompareTo(UpdateManifestFile other)
1515
return segmentDifference != 0 ? segmentDifference : string.CompareOrdinal(Path, other.Path);
1616
}
1717

18-
public static UpdateManifestFile From(FileInfo fileInfo, string rootPath)
18+
public static UpdateManifestFile From(FileInfo fileInfo, string rootPath, FileInfo? mappedTo = null)
1919
{
20-
var relativeFilePath = System.IO.Path.GetRelativePath(rootPath, fileInfo.FullName);
2120
var checksum = ComputeChecksum(fileInfo);
21+
var relativeFilePath = System.IO.Path.GetRelativePath(
22+
rootPath,
23+
mappedTo?.FullName ?? fileInfo.FullName
24+
);
2225
return new UpdateManifestFile(relativeFilePath, checksum, fileInfo.Length);
2326
}
2427

Intersect.Server/Intersect.Server.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
</PackageReference>
128128
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
129129
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" />
130+
<PackageReference Include="MyCSharp.HttpUserAgentParser.AspNetCore" Version="3.0.13" />
131+
<PackageReference Include="MyCSharp.HttpUserAgentParser.MemoryCache" Version="3.0.13" />
130132
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
131133
<PackageReference Include="Pomelo.JsonObject" Version="2.2.1" />
132134
<PackageReference Include="Remotion.Linq" Version="2.2.0" />

Intersect.Server/Web/ApiService.cs

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System.Globalization;
22
using System.Net;
3-
using System.Net.Security;
43
using System.Reflection;
5-
using System.Security.Authentication;
64
using System.Security.Claims;
75
using System.Threading.RateLimiting;
86
using Htmx.TagHelpers;
@@ -38,7 +36,9 @@
3836
using Intersect.Server.Web.Controllers.Api;
3937
using Intersect.Server.Web.Controllers.AssetManagement;
4038
using Intersect.Server.Web.Types.Chat;
41-
using Microsoft.AspNetCore.Server.Kestrel.Core;
39+
using Microsoft.AspNetCore.Http.Features;
40+
using MyCSharp.HttpUserAgentParser.AspNetCore.DependencyInjection;
41+
using MyCSharp.HttpUserAgentParser.MemoryCache.DependencyInjection;
4242

4343
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
4444

@@ -120,6 +120,8 @@ internal partial class ApiService : ApplicationService<ServerContext, IApiServic
120120
}
121121
);
122122

123+
builder.Services.AddHttpUserAgentMemoryCachedParser().AddHttpUserAgentParserAccessor();
124+
123125
builder.Services.AddRateLimiter(
124126
rateLimiterOptions =>
125127
{
@@ -170,7 +172,9 @@ internal partial class ApiService : ApplicationService<ServerContext, IApiServic
170172
CookieAuthenticationDefaults.AuthenticationScheme,
171173
options =>
172174
{
173-
options.ForwardChallenge = JwtBearerDefaults.AuthenticationScheme;
175+
// Commenting this out fixes no redirect
176+
// Uncommenting fixed something else, but I can't remember what it was
177+
// options.ForwardChallenge = JwtBearerDefaults.AuthenticationScheme;
174178
options.Events.OnSignedIn += async (context) => { };
175179
options.Events.OnSigningIn += async (context) => { };
176180
options.Events.OnSigningOut += async (context) => { };
@@ -203,8 +207,12 @@ internal partial class ApiService : ApplicationService<ServerContext, IApiServic
203207
context.ShouldRenew = true;
204208
context.ReplacePrincipal(updatedPrincipal);
205209
};
206-
options.Events.OnRedirectToLogin += async (context) => { };
207-
options.Events.OnRedirectToAccessDenied += async (context) => { };
210+
options.Events.OnRedirectToLogin += async (context) =>
211+
{
212+
};
213+
options.Events.OnRedirectToAccessDenied += async (context) =>
214+
{
215+
};
208216
options.Events.OnRedirectToLogout += async (context) => { };
209217
options.Events.OnRedirectToReturnUrl += async (context) => { };
210218
options.ExpireTimeSpan = TimeSpan.FromSeconds(10);
@@ -486,30 +494,6 @@ internal partial class ApiService : ApplicationService<ServerContext, IApiServic
486494
app.UseIntersectRequestLogging(configuration.RequestLogLevel);
487495
}
488496

489-
app.UseStaticFiles();
490-
491-
// Unreadable if it LINQs it...
492-
// ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
493-
foreach (var (sourcePath, requestPath) in configuration.StaticFilePaths)
494-
{
495-
var pathToRoot = Path.Combine(builder.Environment.ContentRootPath, sourcePath);
496-
if (!Directory.Exists(pathToRoot))
497-
{
498-
Directory.CreateDirectory(pathToRoot);
499-
}
500-
501-
app.UseStaticFiles(
502-
new StaticFileOptions
503-
{
504-
FileProvider = new PhysicalFileProvider(
505-
pathToRoot,
506-
ExclusionFilters.Sensitive
507-
),
508-
RequestPath = requestPath ?? string.Empty,
509-
}
510-
);
511-
}
512-
513497
app.UseRouting();
514498

515499
app.UseAuthentication();
@@ -549,6 +533,39 @@ internal partial class ApiService : ApplicationService<ServerContext, IApiServic
549533
app.UseResponseCaching();
550534
app.UseOutputCache();
551535

536+
537+
StaticFileOptions staticFileOptions = new()
538+
{
539+
HttpsCompression = HttpsCompressionMode.Compress,
540+
ServeUnknownFileTypes = true,
541+
};
542+
543+
app.UseStaticFiles(staticFileOptions);
544+
545+
// Unreadable if it LINQs it...
546+
// ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
547+
foreach (var (sourcePath, requestPath) in configuration.StaticFilePaths)
548+
{
549+
var pathToRoot = Path.Combine(builder.Environment.ContentRootPath, sourcePath);
550+
if (!Directory.Exists(pathToRoot))
551+
{
552+
Directory.CreateDirectory(pathToRoot);
553+
}
554+
555+
app.UseStaticFiles(
556+
new StaticFileOptions
557+
{
558+
FileProvider = new PhysicalFileProvider(
559+
pathToRoot,
560+
ExclusionFilters.Sensitive
561+
),
562+
HttpsCompression = HttpsCompressionMode.Compress,
563+
RequestPath = requestPath ?? string.Empty,
564+
ServeUnknownFileTypes = true,
565+
}
566+
);
567+
}
568+
552569
app.UseAuthorization();
553570

554571
app.MapHtmxAntiforgeryScript();

0 commit comments

Comments
 (0)