-
Notifications
You must be signed in to change notification settings - Fork 1
Develop/feature/td 5829 5862 shared architecture and bff 2 #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: LHKentia
Are you sure you want to change the base?
Changes from 11 commits
3343656
20ca42e
19d6cfc
247ef8f
2db7358
a8c26db
aa9a1a5
bcd5659
60f1317
230a260
78709c7
dcca696
99fc2b6
6242cfd
c800d32
3279ef6
bcdff4b
ce07ada
8167a97
edd96ee
f06621f
e8943a6
5505e8d
1217fba
15f02cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace LearningHub.Nhs.Shared.Configuration | ||
{ | ||
using LearningHub.Nhs.Shared.Interfaces.Configuration; | ||
/// <summary> | ||
/// Represents configuration values that are safe to expose to clientside frontend applications | ||
/// (such as Blazor WebAssembly) or public-facing APIs. | ||
/// | ||
/// <para> | ||
/// Implements <see cref="IPublicSettings"/> and contains only non-sensitive, non-secret | ||
/// values such as public API endpoints and pagination settings. This separation ensures | ||
/// that secure or private configuration data is not inadvertently exposed to clients. | ||
/// </para> | ||
/// </summary> | ||
public class PublicSettings : IPublicSettings | ||
{ | ||
/// <inheritdoc/> | ||
public string LearningHubApiUrl { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public int ResourceSearchPageSize { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public int CatalogueSearchPageSize { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public int AllCatalogueSearchPageSize { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public IFindwiseSettingsPublic FindwiseSettings { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace LearningHub.Nhs.WebUI.Helpers | ||
namespace LearningHub.Nhs.Shared.Helpers | ||
{ | ||
using LearningHub.Nhs.Models.Enums; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are not using this, it is only for comments here, i think we shouldnt include it. Or use System.X libraries so we don't pull through unneeded dependencies which arn't support in blazor for example, but generally more generic, more framework-neutral options are better for compatibility. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AnjuJose011 I would like a meeting about this i think there isnt enough seperation we have infastructure and presentation concerns in models etc the shared project i think needs to be agnostic, no aspnetcore.asp There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Phil-NHS this is what discussed in today's meeting and seems a real blocker .you can please create a subtask and add more details in that ticket |
||
|
||
/// <summary> | ||
/// Defines the <see cref="ResourceAccessLevelHelper" />. | ||
|
@@ -11,7 +10,7 @@ public static class ResourceAccessLevelHelper | |
/// <summary> | ||
/// Get resource access level text. | ||
/// </summary> | ||
/// <param name="resourceAccessibilityEnum">The htmlhelper<see cref="IHtmlHelper"/>.</param> | ||
/// <param name="resourceAccessibilityEnum">The enum value to get display text for.</param> | ||
/// <returns>The <see cref="string"/>.</returns> | ||
public static string GetResourceAccessLevelText(this ResourceAccessibilityEnum resourceAccessibilityEnum) | ||
{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please correct the name space There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean because we wont be moving it in the scope of this release or that utility helper wouldnt be shared at the top level? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies, in your local branch, the namespace for the utility helper class is currently: namespace LearningHub.Nhs.WebUI.Helpers However, it should be namespace LearningHub.Nhs.Shared.Helpers ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes good catch! (didnt see it in chat part of pr but clear in the code bit :) ) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace LearningHub.Nhs.Shared.Interfaces.Configuration | ||
{ | ||
/// <summary> | ||
/// Represents configuration values related to Findwise search that are safe to expose | ||
/// to client-side applications or public-facing APIs. | ||
/// | ||
/// <para> | ||
/// This includes non-sensitive values such as page sizes for different types of search results. | ||
/// It does not contain any secure credentials or internal service configuration. | ||
/// </para> | ||
/// </summary> | ||
public interface IFindwiseSettingsPublic | ||
{ | ||
/// <summary> | ||
/// Gets or sets the page size for resource search results. | ||
/// </summary> | ||
public int ResourceSearchPageSize { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the CatalogueSearchPageSize. | ||
/// </summary> | ||
public int CatalogueSearchPageSize { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the AllCatalogueSearchPageSize. | ||
/// </summary> | ||
public int AllCatalogueSearchPageSize { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace LearningHub.Nhs.Shared.Interfaces.Configuration | ||
{ | ||
/// <summary> | ||
/// Defines a contract for configuration data that is non-sensitive and safe to expose publicly | ||
/// | ||
/// <para> | ||
/// This interface exposes only data that is safe to be publicly consumed or shared, | ||
/// such as API endpoint URLs or non-sensitive configuration values. | ||
/// It explicitly excludes any private or sensitive information (e.g., authentication tokens, | ||
/// credentials, or secret keys), which should be handled via separate interfaces or services. | ||
/// </para> | ||
/// | ||
/// <para> | ||
/// The data provided by this interface can be safely used in frontend technologies, | ||
/// such as Blazor WebAssembly, JavaScript frameworks, or other client-side applications, | ||
/// without risking exposure of sensitive information. | ||
/// </para> | ||
/// </summary> | ||
public interface IPublicSettings | ||
{ | ||
/// <summary> | ||
/// Gets or sets the LearningHubApiUrl. | ||
/// </summary> | ||
public string LearningHubApiUrl { get; set; } | ||
|
||
public IFindwiseSettingsPublic FindwiseSettings { get; set; } | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace LearningHub.Nhs.Shared.Interfaces.Http | ||
{ | ||
/// <summary> | ||
/// Represents an HTTP client for a specific API. | ||
/// </summary> | ||
public interface IAPIHttpClient | ||
{ | ||
/// <summary> | ||
/// Gets the configured <see cref="HttpClient"/> for the API. | ||
/// </summary> | ||
Task<HttpClient> GetClientAsync(); | ||
|
||
/// <summary> | ||
/// Gets the base URL of the API. | ||
/// </summary> | ||
string ApiUrl { get; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other versions of this functionality in other project dont have APIUrl this comes from the baseHttpClient |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace LearningHub.Nhs.Shared.Interfaces.Http | ||
{ | ||
/// <summary> | ||
/// Marker interface for the LearningHub API HttpClient. | ||
/// | ||
/// <para> | ||
/// Inherits from <see cref="IAPIHttpClient"/> to enable | ||
/// dependency injection of a specific implementation configured with | ||
/// different API endpoints or settings specific to LH API. | ||
/// </para> | ||
/// | ||
/// <para> | ||
/// Currently, this interface is empty and used solely to differentiate implementations | ||
/// that connect to different endpoints via configuration, but it may be extended in the future | ||
/// with LearningHub-specific functionality or properties. | ||
/// </para> | ||
/// </summary> | ||
public interface ILearningHubHttpClient : IAPIHttpClient | ||
{ | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LearningHub.Nhs.Shared.Interfaces.Http | ||
{ | ||
/// <summary> | ||
/// Marker interface for the IOpenAPIHttpClient API HttpClient. | ||
/// | ||
/// <para> | ||
/// Inherits from <see cref="IAPIHttpClient"/> to enable | ||
/// dependency injection of a specific implementation configured with | ||
/// a openapi-related API endpoint or settings. | ||
/// </para> | ||
/// | ||
/// <para> | ||
/// This interface is currently empty and used solely to differentiate | ||
/// implementations that connect to different endpoints via configuration. | ||
/// It may be extended in the future with user-specific functionality or properties. | ||
/// </para> | ||
/// </summary> | ||
public interface IOpenApiHttpClient : IAPIHttpClient | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The introduction of marker interface is so we can standardised the apis. This allows the blazor client and other projects share them and implement them differently. However another facade has been introduced, for openapi, during these tasks being created. it is probably worth at this point whether we should (i think so) we standardised and define the apis, and interfaces and how they are hit. or if its all already thought through share the outcome. |
||
{ | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace LearningHub.Nhs.Shared.Interfaces.Http | ||
{ | ||
/// <summary> | ||
/// Marker interface for the User API HttpClient. | ||
/// | ||
/// <para> | ||
/// Inherits from <see cref="IAPIHttpClient"/> to enable | ||
/// dependency injection of a specific implementation configured with | ||
/// a user-related API endpoint or settings. | ||
/// </para> | ||
/// | ||
/// <para> | ||
/// This interface is currently empty and used solely to differentiate | ||
/// implementations that connect to different endpoints via configuration. | ||
/// It may be extended in the future with user-specific functionality or properties. | ||
/// </para> | ||
/// </summary> | ||
public interface IUserApiHttpClient : IAPIHttpClient | ||
{ | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" /> | ||
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Models\Contribute\" /> | ||
<Folder Include="Models\Paging\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we remove ////qqq comment from here or can you please add a meaningful message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep good catch its because its not going into production. but this is a mistake you may see again if i dont tidy up after myself its how i rememember to comeback to things. here is it is there to mark the breaking library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Settings was broken up into more classes/objs in the appsettings we could inject just the bits we are using, -> least knowledge and interface segregation. But I expect there would be alot involved in doing this so I am expect appsetting will stay the same and we will inject PublicSettings and have PublicX per obj, (public may be the wrong word choice).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binon Do you agree with this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, naming PublicSettings might be misleading if it implies exposure to external clients; it’s important to be very explicit about who “public” means in this context to avoid confusion among developers. Adapting more granular approach is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, theyre not really public theyre just not secret because they get exposed so they need some naming to signify "Do not put Sensitive Information Here" or something. i couldnt think of anything better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreeing with binon's opinion-it can create confusion. can we use some FrontendConfig or some other names ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I want a consistent word so that i can do Settings : ISettings, IPublicSettings
So that we know whenever we use settings it can provide the implementations to either. so repeating the original name of the interface with an additional word to signify a subset of it I think is frontend ... in the previous meeting it was suggested we can rely on the comments to enforce not putting sensative data where it shoudnt be. But a word that really communicates it i think would be ideal.
FrontendConfig i dont think is right because though the front end does prefer not to expose it actualy the service is being given far more scope that it wants. So frontend i dont think is right.
Config I like better if it was Settings: ISecretSettings, IConfigSettings
but i dont think we will split it like this i think we will be leaving ISettings the same and then interfacing to capture a subset of the same values, (for convenience no other reason).
Other options
Settings: ISettings, IExposableSettings <-- this is my favourate so far?
Settings : ISettings, INonSensitiveSettings
Settings : ISettings, IUnsecuredSettings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Settings: ISettings, IExposableSettings <-- -I think we can go ahead with this naming convention