From 9d20925da630960a633ef373ee4d76c8d39242f3 Mon Sep 17 00:00:00 2001 From: Steve Temple Date: Thu, 24 Oct 2024 10:20:21 +0100 Subject: [PATCH] Fix merge issues following #30 --- ...tBackOfficeExternalLoginProviderOptions.cs | 23 +++++++------------ .../Settings/AzureSSOSettings.cs | 2 +- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Umbraco.Community.AzureSSO/MicrosoftAccountBackOfficeExternalLoginProviderOptions.cs b/src/Umbraco.Community.AzureSSO/MicrosoftAccountBackOfficeExternalLoginProviderOptions.cs index 3ee27f2..75f4a65 100644 --- a/src/Umbraco.Community.AzureSSO/MicrosoftAccountBackOfficeExternalLoginProviderOptions.cs +++ b/src/Umbraco.Community.AzureSSO/MicrosoftAccountBackOfficeExternalLoginProviderOptions.cs @@ -10,20 +10,13 @@ namespace Umbraco.Community.AzureSSO { - public class MicrosoftAccountBackOfficeExternalLoginProviderOptions(AzureSsoSettings settings) + public class MicrosoftAccountBackOfficeExternalLoginProviderOptions( + AzureSsoSettings settings, + ILogger logger) : IConfigureNamedOptions { public const string SchemeName = "MicrosoftAccount"; - - private readonly AzureSsoSettings _settings; - private readonly ILogger _logger; - - public MicrosoftAccountBackOfficeExternalLoginProviderOptions(AzureSsoSettings settings, - ILogger logger) - { - _settings = settings; - _logger = logger; - } + public void Configure(string? name, BackOfficeExternalLoginProviderOptions options) { @@ -101,7 +94,7 @@ private void SetGroups(BackOfficeIdentityUser user, ExternalLoginInfo loginInfo, { user.Roles.Clear(); - var groups = loginInfo.Principal.Claims.Where(c => _settings.GroupLookup.ContainsKey(c.Value)).ToList(); + var groups = loginInfo.Principal.Claims.Where(c => settings.GroupLookup.ContainsKey(c.Value)).ToList(); foreach (var group in groups) { @@ -117,12 +110,12 @@ private void SetGroups(BackOfficeIdentityUser user, ExternalLoginInfo loginInfo, user.AddRole(group); } - if (_settings.LogUnmappedRolesAsWarning) + if (settings.LogUnmappedRolesAsWarning) { - var unmappedGroups = loginInfo.Principal.Claims.Where(c => !_settings.GroupLookup.ContainsKey(c.Value) && c.Value.Contains("\\")).Select(c => c.Value).ToList(); + var unmappedGroups = loginInfo.Principal.Claims.Where(c => !settings.GroupLookup.ContainsKey(c.Value) && c.Value.Contains("\\")).Select(c => c.Value).ToList(); if (unmappedGroups.Any()) { - _logger.LogWarning("The following groups were not mapped to Umbraco roles: {Groups}", string.Join(", ", unmappedGroups)); + logger.LogWarning("The following groups were not mapped to Umbraco roles: {Groups}", string.Join(", ", unmappedGroups)); } } diff --git a/src/Umbraco.Community.AzureSSO/Settings/AzureSSOSettings.cs b/src/Umbraco.Community.AzureSSO/Settings/AzureSSOSettings.cs index 68bb2c5..f9fde48 100644 --- a/src/Umbraco.Community.AzureSSO/Settings/AzureSSOSettings.cs +++ b/src/Umbraco.Community.AzureSSO/Settings/AzureSSOSettings.cs @@ -27,7 +27,7 @@ public class AzureSsoProfileSettings(AzureSSOConfiguration configuration) public string Icon => configuration.Icon ?? "fa fa-lock"; public Dictionary GroupLookup => configuration.GroupBindings; public bool SetGroupsOnLogin => configuration.SetGroupsOnLogin ?? true; - public bool LogUnmappedRolesAsWarning => _configuration.LogUnmappedRolesAsWarning ?? false; + public bool LogUnmappedRolesAsWarning => configuration.LogUnmappedRolesAsWarning ?? false; public string[] DefaultGroups => configuration.DefaultGroups ?? System.Array.Empty(); public bool DenyLocalLogin => configuration.DenyLocalLogin ?? false; public TokenCacheType TokenCacheType => configuration.TokenCacheType;