Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
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
cc0ff4e
Bump @babel/core from 7.26.9 to 7.26.10 in /Auth/LearningHub.Nhs.Auth…
dependabot[bot] 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
0318db8
Bump sass from 1.85.1 to 1.86.0 in /Auth/LearningHub.Nhs.Auth
dependabot[bot] Mar 18, 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
cd3cb8d
Merge pull request #141 from TechnologyEnhancedLearning/dependabot/np…
AnjuJose011 Mar 25, 2025
7908510
Bump sass from 1.86.0 to 1.86.1 in /Auth/LearningHub.Nhs.Auth (#144)
dependabot[bot] Apr 1, 2025
928bca2
Bump sass from 1.86.1 to 1.86.2 in /Auth/LearningHub.Nhs.Auth (#145)
dependabot[bot] Apr 3, 2025
4adf6ee
Merge pull request #146 from TechnologyEnhancedLearning/Automatic_ver…
AnjuJose011 Apr 3, 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
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
5 changes: 5 additions & 0 deletions Auth/LearningHub.Nhs.Auth/Configuration/WebSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,10 @@ 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; }
}
}
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;
}
}
}
6 changes: 5 additions & 1 deletion Auth/LearningHub.Nhs.Auth/ServiceCollectionExtension.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace LearningHub.Nhs.Auth
{
using System;
using System.Collections.Concurrent;
using System.Security.Cryptography.X509Certificates;
using Azure.Identity;
using IdentityServer4;
using LearningHub.Nhs.Auth.Configuration;
using LearningHub.Nhs.Auth.Helpers;
using LearningHub.Nhs.Auth.Middleware;
using LearningHub.Nhs.Caching;
using LearningHub.Nhs.Models.Enums;
Expand Down Expand Up @@ -70,7 +72,9 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie().AddOpenIdConnect(
})
.AddCookie()
.AddOpenIdConnect(
"oidc_oa",
options =>
{
Expand Down
5 changes: 2 additions & 3 deletions Auth/LearningHub.Nhs.Auth/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
"ElfhHub": "",
"Rcr": "",
"SupportForm": "https://support.learninghub.nhs.uk/support/tickets/new",
"SupportFeedbackForm": "https://forms.office.com/e/C8tteweEhG"


"SupportFeedbackForm": "https://forms.office.com/e/C8tteweEhG",
"IsPasswordUpdate": "false"
},
"AllowOpenAthensDebug": false,
"OaLhClients": {
Expand Down
70 changes: 35 additions & 35 deletions Auth/LearningHub.Nhs.Auth/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading