Skip to content

Commit

Permalink
Merge pull request #3 from FHIR/dev
Browse files Browse the repository at this point in the history
Fix: .Net 8 issue with Antiforgery when launching with UI disabled.
  • Loading branch information
GinoCanessa authored Aug 28, 2024
2 parents 316b355 + 9ac6e1a commit be69fce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 54 deletions.
25 changes: 3 additions & 22 deletions src/fhir-candle/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,18 @@
// </copyright>

using SCL = System.CommandLine; // this is present to disambiguate Option from System.CommandLine and Microsoft.FluentUI.AspNetCore.Components
using System;
using System.CommandLine.Binding;
using System.CommandLine.Invocation;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using fhir.candle.Models;
using fhir.candle.Services;
using FhirCandle.Extensions;
using FhirCandle.Models;
using FhirCandle.Storage;
using FhirCandle.Utils;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Hosting.StaticWebAssets;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.FluentUI.AspNetCore.Components;
using fhir.candle;
using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using System.Text;
using System.CommandLine;
using FhirCandle.Configuration;
using System.Reflection;
using static Org.BouncyCastle.Math.EC.ECCurve;
using BlazorMonaco.Languages;

namespace fhir.candle;

Expand Down Expand Up @@ -217,6 +196,7 @@ public static async Task<int> RunServer(SCL.Parsing.ParseResult pr, Cancellation
builder.Services.AddHostedService<ISmartAuthManager>(sp => sp.GetRequiredService<ISmartAuthManager>());

builder.Services.AddControllers();
builder.Services.AddHttpClient();

if (config.DisableUi == true)
{
Expand All @@ -226,6 +206,8 @@ public static async Task<int> RunServer(SCL.Parsing.ParseResult pr, Cancellation
Console.WriteLine("fhir-candle <<< ERROR: Cannot disable UI when SMART is configured.");
return -1;
}

builder.Services.AddAntiforgery();
}
else
{
Expand All @@ -236,7 +218,6 @@ public static async Task<int> RunServer(SCL.Parsing.ParseResult pr, Cancellation
// options.Conventions.AddPageRoute("/store", "/store/{storeName}");
//});
//builder.Services.AddServerSideBlazor();
builder.Services.AddHttpClient();
builder.Services.AddFluentUIComponents();

// set our default UI page
Expand Down
1 change: 1 addition & 0 deletions src/fhir-candle/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"profiles": {
"candle": {
"commandName": "Project",
"commandLineArgs": " --r4 r4 --disable-ui",
"launchBrowser": true,
"applicationUrl": "http://localhost:5826",
"environmentVariables": {
Expand Down
32 changes: 0 additions & 32 deletions src/fhir-candle/Services/FhirStoreManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,6 @@ private void LoadPackagePages()
// get all page types
List<PackagePageInfo> pages = [];

//pages.AddRange(System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
// .Where(t => t.GetInterfaces().Contains(typeof(IPackagePage)))
// .Select(pt => new PackagePageInfo()
// {
// ContentFor = pt.GetProperty("ContentFor", typeof(string))?.GetValue(null) as string ?? string.Empty,
// PageName = pt.GetProperty("PageName", typeof(string))?.GetValue(null) as string ?? string.Empty,
// Description = pt.GetProperty("Description", typeof(string))?.GetValue(null) as string ?? string.Empty,
// RoutePath = pt.GetProperty("RoutePath", typeof(string))?.GetValue(null, null) as string ?? string.Empty,
// FhirVersionLiteral = pt.GetProperty("FhirVersionLiteral", typeof(string))?.GetValue(null) as string ?? string.Empty,
// FhirVersionNumeric = pt.GetProperty("FhirVersionNumeric", typeof(string))?.GetValue(null) as string ?? string.Empty,
// OnlyShowOnEndpoint = pt.GetProperty("OnlyShowOnEndpoint", typeof(string))?.GetValue(null) as string ?? string.Empty,
// }));

pages.AddRange(typeof(fhir.candle.Pages.RI.subscriptions.Tour).Assembly.GetTypes()
.Where(t => t.GetInterfaces().Contains(typeof(IPackagePage)))
.Select(pt => new PackagePageInfo()
Expand Down Expand Up @@ -370,23 +357,6 @@ private void LoadPackagePages()
}
}

/// <summary>
/// A record struct that represents a loaded package.
/// </summary>
/// <param name="directive">The directive of the loaded package.</param>
/// <param name="name">The name of the loaded package.</param>
/// <param name="version">The version of the loaded package.</param>
/// <param name="directory">The directory where the loaded package is located.</param>
/// <param name="supplementDirectory">The directory of the supplemental content for the loaded package.</param>
/// <param name="fhirVersion">The FHIR version of the loaded package.</param>
private record struct LoadedPackageRec(
string directive,
string name,
string version,
string directory,
string supplementDirectory,
FhirReleases.FhirSequenceCodes fhirVersion);

/// <summary>Loads ri contents.</summary>
/// <param name="dir">The dir.</param>
public void LoadRiContents(string dir)
Expand Down Expand Up @@ -518,8 +488,6 @@ public async Task LoadRequestedPackages(string supplementalRoot, bool loadExampl
return;
}

List<LoadedPackageRec> loadRecs = [];

List<FhirReleases.FhirSequenceCodes> allTenantFhirVersions = _tenants.Values.Select(t => t.FhirVersion).Distinct().ToList();

List<PackageReference> localPackages = await _packageService.InstallPackages(
Expand Down

0 comments on commit be69fce

Please sign in to comment.