Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
900df90
Merge pull request #115 from TechnologyEnhancedLearning/Automatic_ver…
binon Feb 7, 2025
0c3fa62
Merge pull request #116 from TechnologyEnhancedLearning/Automatic_ver…
binon Feb 7, 2025
4ccfe6e
Configuring OpenID Connect Authentication with moodle user id
binon Feb 14, 2025
d784fda
Added moodle client configuration to appsettings.json
ColinBeebyHEE Feb 25, 2025
fb8cd3f
Merge pull request #126 from TechnologyEnhancedLearning/Develop/Featu…
AnjuJose011 Feb 26, 2025
f8b8d3d
Corrected RedirectUris for moodle client
ColinBeebyHEE Feb 27, 2025
a609db2
Merge pull request #129 from TechnologyEnhancedLearning/Develop/Featu…
AnjuJose011 Feb 27, 2025
ccf2104
TD-3732: Missing Security Headers
Swapnamol Feb 28, 2025
1d8c1d7
Merge pull request #130 from TechnologyEnhancedLearning/Developo/Fixe…
swapnamol-abraham Mar 4, 2025
11526c1
TD-3731: Password Change Does Not Invalidate Current Session
Swapnamol Mar 5, 2025
2b4eb35
Merge pull request #132 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Mar 5, 2025
f898a6f
TD-3733:Information Disclosures
Swapnamol Mar 5, 2025
311c3dc
Merge pull request #133 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Mar 5, 2025
3b6a880
Merge pull request #135 from TechnologyEnhancedLearning/Automatic_ver…
AnjuJose011 Mar 7, 2025
76c7bda
TD-5406: Errors are not Getting Logged in Learning Hub Prod logging D…
Swapnamol Mar 10, 2025
4e02018
Merge pull request #136 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Mar 12, 2025
0474fd7
TD-3743: Concurrent Sessions Allowed
Swapnamol Mar 13, 2025
018657e
Merge pull request #138 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Mar 13, 2025
455d035
PR to test error logging in test environment
Swapnamol Mar 17, 2025
df44676
Merge pull request #139 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Mar 17, 2025
8eca960
Reverted the test code
Swapnamol Mar 17, 2025
f95ccc2
Merge pull request #140 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Mar 17, 2025
4f2e533
Merge pull request #143 from TechnologyEnhancedLearning/Dev/Feature/T…
AnjuJose011 Mar 18, 2025
6200dee
CSP updated
Swapnamol Mar 18, 2025
d6deb87
Reverted CSP fixes
Swapnamol Mar 18, 2025
969b770
Reverted in memory store
Swapnamol Mar 19, 2025
cb03bf1
reverted
Swapnamol Mar 19, 2025
72b8cc0
Test
Swapnamol Mar 19, 2025
294deb7
Revert "reverted"
Swapnamol Mar 19, 2025
11714d9
Revert "Test"
Swapnamol Mar 19, 2025
a6fe18a
Added in store memmory ticket store
Swapnamol Mar 19, 2025
79a4bbc
Reverted the chnages
Swapnamol Mar 19, 2025
fb344cc
CSP code added
Swapnamol Mar 19, 2025
2103eea
Removed Sandbox
Swapnamol Mar 20, 2025
b7c7090
Added in memory ticket store
Swapnamol Mar 20, 2025
610f1a5
Reverted in memory ticket store from RC
Swapnamol Mar 20, 2025
4adf6ee
Merge pull request #146 from TechnologyEnhancedLearning/Automatic_ver…
AnjuJose011 Apr 3, 2025
2d3f7b1
TD-3734: Concurrent Sessions Allowed
Swapnamol Apr 4, 2025
58ea79f
Concurrent Sessions Allowed
Swapnamol Apr 4, 2025
e39319a
user null check
Apr 7, 2025
429e9a4
TD-5407: Implemented a fix to avoid SQL exception on LinkExistingUser…
Swapnamol Apr 7, 2025
8d2c273
Merge pull request #150 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Apr 8, 2025
ecf118f
Corrected the datatype
Swapnamol Apr 8, 2025
53c5e61
Merge pull request #151 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Apr 8, 2025
0b6e869
Modified EF call with SP call
Swapnamol Apr 8, 2025
d0c1290
Merge pull request #152 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Apr 8, 2025
08fe2fe
Merge pull request #148 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Apr 8, 2025
972b40c
Merge branch 'RC' into Develop/POC/TD-5284_retrival_of_moodle_user_id
Apr 10, 2025
e52c59f
Merge pull request #156 from TechnologyEnhancedLearning/release-v1.4.…
AnjuJose011 Apr 11, 2025
09ea76d
added new appsetting value - EnableMoodle
Apr 11, 2025
c322872
Merge pull request #157 from TechnologyEnhancedLearning/Automatic_ver…
AnjuJose011 Apr 11, 2025
a9a7009
Merge pull request #158 from TechnologyEnhancedLearning/Develop/POC/T…
binon Apr 14, 2025
1baf49a
Fixed the style cop issue with the user api (Blank line required)
Swapnamol Apr 14, 2025
6762438
TD-5492: Upgrade .NET Framework Version For Database Project
swapnamol-abraham Apr 24, 2025
8766c8e
Merge pull request #162 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham Apr 24, 2025
041b19c
TD-5538: IUncluded web.config in the solution
swapnamol-abraham May 12, 2025
fb0c863
TD-5538: IUncluded web.config in the solution
swapnamol-abraham May 12, 2025
60e679a
corrected
swapnamol-abraham May 12, 2025
04523b5
Merge pull request #171 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham May 12, 2025
3dd19cf
TD-4982-Blocked all IdentityServer4 logs from being processed by late…
swapnamol-abraham May 15, 2025
fe62003
Merge pull request #173 from TechnologyEnhancedLearning/Develop/Fixes…
swapnamol-abraham May 15, 2025
b8c36d4
Merge pull request #179 from TechnologyEnhancedLearning/Automatic_ver…
AnjuJose011 May 27, 2025
0f43fca
TD-3734: Reverting the changes
swapnamol-abraham May 28, 2025
840154c
Merge pull request #181 from TechnologyEnhancedLearning/Develop/Fixes…
AnjuJose011 May 28, 2025
2f2a73d
Merge pull request #182 from TechnologyEnhancedLearning/Automatic_ver…
AnjuJose011 May 29, 2025
9d3aee1
Enabled central package management
Jun 3, 2025
03ea146
Added nuget.config file
Jun 6, 2025
8e3adf0
Update continuous-integration-workflow.yml
binon Jun 12, 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
4 changes: 3 additions & 1 deletion .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
dotnet-version: 8.0.x

- name: Add Azure artifact
run: dotnet nuget add source 'https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json' --name 'LearningHubFeed' --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text
run: |
dotnet nuget remove source LearningHubFeed || true
dotnet nuget add source 'https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json' --name 'LearningHubFeed' --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text

- name: Use NuGet 5.8
uses: nuget/setup-nuget@v1
Expand Down
27 changes: 11 additions & 16 deletions Auth/LearningHub.Nhs.Auth.Tests/LearningHub.Nhs.Auth.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
<Platforms>x64</Platforms>
<Platforms>x64</Platforms>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.8" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PackageReference Include="elfhHub.Nhs.Models" />
<PackageReference Include="LearningHub.Nhs.Models" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" />
<PackageReference Include="Moq" />
<PackageReference Include="StyleCop.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\LearningHub.Nhs.Auth\LearningHub.Nhs.Auth.csproj" />
</ItemGroup>

</Project>
</Project>
10 changes: 10 additions & 0 deletions Auth/LearningHub.Nhs.Auth/Configuration/ServiceMappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,22 @@ public static void AddServiceMappings(this IServiceCollection services, IConfigu
ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
});

services.AddHttpClient<IMoodleHttpClient, MoodleHttpClient>()
.ConfigurePrimaryHttpMessageHandler(
() => new HttpClientHandler
{
ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
});
}
else
{
services.AddHttpClient<IUserApiHttpClient, UserApiHttpClient>();
services.AddHttpClient<IMoodleHttpClient, MoodleHttpClient>();
}

services.AddScoped<IMoodleApiService, MoodleApiService>();
services.AddDistributedMemoryCache();
services.AddScoped<IExternalSystemService, ExternalSystemService>();
services.AddTransient<IRegistrationService, RegistrationService>();
Expand Down
12 changes: 11 additions & 1 deletion Auth/LearningHub.Nhs.Auth/Configuration/WebSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,15 @@ public class WebSettings
/// Gets or sets the SupportFeedbackForm.
/// </summary>
public string SupportFeedbackForm { get; set; }
}

/// <summary>
/// Gets or sets a value indicating whether IsPasswordUpdate.
/// </summary>
public bool IsPasswordUpdate { get; set; }

/// <summary>
/// Gets or sets a value indicating whether gets or sets a value to Enable Moodle.
/// </summary>
public bool EnableMoodle { get; set; }
}
}
23 changes: 15 additions & 8 deletions Auth/LearningHub.Nhs.Auth/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@
using LearningHub.Nhs.Auth.Models.Account;
using LearningHub.Nhs.Caching;
using LearningHub.Nhs.Models.Common;
using LearningHub.Nhs.Models.Entities.Reporting;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NHSUKViewComponents.Web.ViewModels;

/// <summary>
/// Account Controller operations.
Expand Down Expand Up @@ -72,7 +68,7 @@ public AccountController(
this.authConfig = authConfig?.Value;
this.webSettings = webSettings;
this.logger = logger;
}
}

/// <summary>
/// Shows the Login page.
Expand Down Expand Up @@ -214,9 +210,9 @@ await this.UserService.AddLogonToUserHistory(
this.ModelState.AddModelError(string.Empty, loginResult.ErrorMessage);
}

showFormWithError:
showFormWithError:

// something went wrong, show form with error
// something went wrong, show form with error
var vm = await this.BuildLoginViewModelAsync(model);
if ((vm.ClientId == "learninghubwebclient") || (vm.ClientId == "learninghubadmin"))
{
Expand Down Expand Up @@ -268,6 +264,9 @@ public async Task<IActionResult> Logout(LogoutInputModel model)
// delete local authentication cookie
await this.HttpContext.SignOutAsync();

// Delete the authentication cookie to ensure it is invalidated
this.HttpContext.Response.Cookies.Delete(".AspNetCore.Identity.Application");

// raise the logout event
await this.Events.RaiseAsync(new UserLogoutSuccessEvent(this.User.GetSubjectId(), this.User.GetDisplayName()));

Expand Down Expand Up @@ -296,7 +295,15 @@ public async Task<IActionResult> Logout(LogoutInputModel model)
return this.SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
}

return this.View("LoggedOut", vm);
if (this.webSettings.IsPasswordUpdate)
{
var redirectUri = $"{this.webSettings.LearningHubWebClient}Home/ChangePasswordAcknowledgement";
return this.Redirect(redirectUri);
}
else
{
return this.View("LoggedOut", vm);
}
}

/// <summary>
Expand Down
21 changes: 21 additions & 0 deletions Auth/LearningHub.Nhs.Auth/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ public async Task<IActionResult> Error()
return this.View("Error");
}

/// <summary>
/// IsPasswordUpdateMethod.
/// </summary>
/// <param name="isLogout">The Logout.</param>
/// <returns>The <see cref="ActionResult"/>.</returns>
[HttpGet]
public IActionResult SetIsPasswordUpdate(bool isLogout)
{
if (isLogout)
{
this.webSettings.IsPasswordUpdate = false;
}
else
{
this.webSettings.IsPasswordUpdate = true;
}

var redirectUri = $"{this.webSettings.LearningHubWebClient}Home/UserLogout";
return this.Redirect(redirectUri);
}

/// <summary>
/// Shows the HealthCheck response.
/// </summary>
Expand Down
104 changes: 104 additions & 0 deletions Auth/LearningHub.Nhs.Auth/Helpers/InMemoryTicketStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
namespace LearningHub.Nhs.Auth.Helpers
{
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;

/// <summary>
/// Defines the <see cref="InMemoryTicketStore" />.
/// </summary>
public class InMemoryTicketStore : ITicketStore
{
private readonly ConcurrentDictionary<string, AuthenticationTicket> cache;

/// <summary>
/// Initializes a new instance of the <see cref="InMemoryTicketStore"/> class.
/// The InMemoryTicketStore.
/// </summary>
/// <param name="cache">the cache.</param>
public InMemoryTicketStore(ConcurrentDictionary<string, AuthenticationTicket> cache)
{
this.cache = cache;
}

/// <summary>
/// The StoreAsync.
/// </summary>
/// <param name="ticket">The ticket.</param>
/// <returns>The key.</returns>
public async Task<string> StoreAsync(AuthenticationTicket ticket)
{
var ticketUserId = ticket.Principal.Claims.Where(c => c.Type == "sub")
.FirstOrDefault()
.Value;
var matchingAuthTicket = this.cache.Values.FirstOrDefault(
t => t.Principal.Claims.FirstOrDefault(
c => c.Type == "sub"
&& c.Value == ticketUserId) != null);
if (matchingAuthTicket != null)
{
var cacheKey = this.cache.Where(
entry => entry.Value == matchingAuthTicket)
.Select(entry => entry.Key)
.FirstOrDefault();
this.cache.TryRemove(
cacheKey,
out _);
}

var key = Guid
.NewGuid()
.ToString();
await this.RenewAsync(
key,
ticket);
return key;
}

/// <summary>
/// The RenewAsync.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="ticket">The ticket.</param>
/// <returns>The Task.</returns>
public Task RenewAsync(
string key,
AuthenticationTicket ticket)
{
this.cache.AddOrUpdate(
key,
ticket,
(_, _) => ticket);
return Task.CompletedTask;
}

/// <summary>
/// The RetrieveAsync.
/// </summary>
/// <param name="key">The Key.</param>
/// <returns>The Task.</returns>
public Task<AuthenticationTicket> RetrieveAsync(string key)
{
this.cache.TryGetValue(
key,
out var ticket);
return Task.FromResult(ticket);
}

/// <summary>
/// The RemoveAsync.
/// </summary>
/// <param name="key">The key.</param>
/// <returns>The Task.</returns>
public Task RemoveAsync(string key)
{
this.cache.TryRemove(
key,
out _);
return Task.CompletedTask;
}
}
}
17 changes: 17 additions & 0 deletions Auth/LearningHub.Nhs.Auth/Interfaces/IMoodleApiService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace LearningHub.Nhs.Auth.Interfaces
{
using System.Threading.Tasks;

/// <summary>
/// IMoodleApiService.
/// </summary>
public interface IMoodleApiService
{
/// <summary>
/// GetResourcesAsync.
/// </summary>
/// <param name="currentUserId">The current User Id.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
Task<int> GetMoodleUserIdByUsernameAsync(int currentUserId);
}
}
23 changes: 23 additions & 0 deletions Auth/LearningHub.Nhs.Auth/Interfaces/IMoodleHttpClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace LearningHub.Nhs.Auth.Interfaces
{
using System.Net.Http;
using System.Threading.Tasks;

/// <summary>
/// The Moodle Http Client interface.
/// </summary>
public interface IMoodleHttpClient
{
/// <summary>
/// The get cient async.
/// </summary>
/// <returns>The <see cref="Task"/>.</returns>
Task<HttpClient> GetClient();

/// <summary>
/// GetDefaultParameters.
/// </summary>
/// <returns>defaultParameters.</returns>
string GetDefaultParameters();
}
}
Loading
Loading