Skip to content

Commit

Permalink
Fix merge issues following #30
Browse files Browse the repository at this point in the history
  • Loading branch information
stevetemple committed Oct 24, 2024
1 parent 3019bf5 commit 9d20925
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@

namespace Umbraco.Community.AzureSSO
{
public class MicrosoftAccountBackOfficeExternalLoginProviderOptions(AzureSsoSettings settings)
public class MicrosoftAccountBackOfficeExternalLoginProviderOptions(
AzureSsoSettings settings,
ILogger<MicrosoftAccountBackOfficeExternalLoginProviderOptions> logger)
: IConfigureNamedOptions<BackOfficeExternalLoginProviderOptions>
{
public const string SchemeName = "MicrosoftAccount";

private readonly AzureSsoSettings _settings;
private readonly ILogger<MicrosoftAccountBackOfficeExternalLoginProviderOptions> _logger;

public MicrosoftAccountBackOfficeExternalLoginProviderOptions(AzureSsoSettings settings,
ILogger<MicrosoftAccountBackOfficeExternalLoginProviderOptions> logger)
{
_settings = settings;
_logger = logger;
}


public void Configure(string? name, BackOfficeExternalLoginProviderOptions options)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AzureSsoProfileSettings(AzureSSOConfiguration configuration)
public string Icon => configuration.Icon ?? "fa fa-lock";
public Dictionary<string, string> 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<string>();
public bool DenyLocalLogin => configuration.DenyLocalLogin ?? false;
public TokenCacheType TokenCacheType => configuration.TokenCacheType;
Expand Down

0 comments on commit 9d20925

Please sign in to comment.