Skip to content

Commit

Permalink
Merge pull request #296 from Yvand/update-logging
Browse files Browse the repository at this point in the history
Update logging
  • Loading branch information
Yvand authored Dec 2, 2024
2 parents 07df58f + 1bc0397 commit 744b570
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 73 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Address security advisory CVE-2024-43485 (related to `System.Text.Json` 6.0.0) by bumping dependencies `Azure.Identity` and `Microsoft.Graph` to their latest version
* Fix a validation issue that impacted guest users, when the identifier property for guest users is the UserPrincipalName
* Fix the noisy logs of category "Azure Identity" due to new level `LogMsalAlways`, by recording logs with level `LogMsalAlways` as `VerboseEx`
* Remove the parameter EventSeverity in method Log(), as it can be deducted from parameter TraceSeverity

## EntraCP v27.0.20240820.36 - enhancements & bug-fixes - Published in August 21, 2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ private void ExecBaseFeatureActivated(Microsoft.SharePoint.SPFeatureReceiverProp
try
{
Logger svc = Logger.Local;
Logger.Log($"[{EntraCP.ClaimsProviderName}] Activating farm-scoped feature for claims provider \"{EntraCP.ClaimsProviderName}\"", TraceSeverity.High, EventSeverity.Information, TraceCategory.Configuration);
Logger.Log($"[{EntraCP.ClaimsProviderName}] Activating farm-scoped feature for claims provider \"{EntraCP.ClaimsProviderName}\"", TraceSeverity.High, TraceCategory.Configuration);
//EntraCPConfig existingConfig = EntraCPConfig.GetConfiguration(ClaimsProviderConstants.CONFIG_NAME);
//if (existingConfig == null)
//{
// EntraCPConfig.CreateDefaultConfiguration();
//}
//else
//{
// ClaimsProviderLogging.Log($"[{EntraCP._ProviderInternalName}] Use configuration \"{ClaimsProviderConstants.CONFIG_NAME}\" found in the configuration database", TraceSeverity.High, EventSeverity.Information, ClaimsProviderLogging.TraceCategory.Configuration);
// ClaimsProviderLogging.Log($"[{EntraCP._ProviderInternalName}] Use configuration \"{ClaimsProviderConstants.CONFIG_NAME}\" found in the configuration database", TraceSeverity.High, ClaimsProviderLogging.TraceCategory.Configuration);
//}
}
catch (Exception ex)
Expand All @@ -63,7 +63,7 @@ public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{
try
{
Logger.Log($"[{EntraCP.ClaimsProviderName}] Uninstalling farm-scoped feature for claims provider \"{EntraCP.ClaimsProviderName}\": Deleting configuration from the farm", TraceSeverity.High, EventSeverity.Information, TraceCategory.Configuration);
Logger.Log($"[{EntraCP.ClaimsProviderName}] Uninstalling farm-scoped feature for claims provider \"{EntraCP.ClaimsProviderName}\": Deleting configuration from the farm", TraceSeverity.High, TraceCategory.Configuration);
//EntraCPConfig.DeleteConfiguration(ClaimsProviderConstants.CONFIG_NAME);
Logger.Unregister();
}
Expand All @@ -80,7 +80,7 @@ public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
try
{
Logger.Log($"[{EntraCP.ClaimsProviderName}] Deactivating farm-scoped feature for claims provider \"{EntraCP.ClaimsProviderName}\": Removing claims provider from the farm (but not its configuration)", TraceSeverity.High, EventSeverity.Information, TraceCategory.Configuration);
Logger.Log($"[{EntraCP.ClaimsProviderName}] Deactivating farm-scoped feature for claims provider \"{EntraCP.ClaimsProviderName}\": Removing claims provider from the farm (but not its configuration)", TraceSeverity.High, TraceCategory.Configuration);
base.RemoveClaimProvider((string)EntraCP.ClaimsProviderName);
}
catch (Exception ex)
Expand Down
4 changes: 2 additions & 2 deletions Yvand.EntraCP/TEMPLATE/ADMIN/EntraCP/GlobalSettings.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected void grdAzureTenants_RowDeleting(object sender, GridViewDeleteEventArg
{
Settings.EntraIDTenants.Remove(tenantToRemove);
CommitChanges();
Logger.Log($"Microsoft Entra ID tenant '{tenantToRemove.Name}' was successfully removed from configuration '{ConfigurationName}'", TraceSeverity.Medium, EventSeverity.Information, TraceCategory.Configuration);
Logger.Log($"Microsoft Entra ID tenant '{tenantToRemove.Name}' was successfully removed from configuration '{ConfigurationName}'", TraceSeverity.Medium, TraceCategory.Configuration);
LabelMessage.Text = String.Format(TextSummaryPersistedObjectInformation, Configuration.Name, Configuration.Version, Configuration.Id);
PopulateConnectionsGrid();
}
Expand Down Expand Up @@ -386,7 +386,7 @@ void AddTenantConnection()
this.Settings.EntraIDTenants.Add(newTenant);

CommitChanges();
Logger.Log($"Microsoft Entra ID tenant '{this.TxtTenantName.Text}' was successfully added to configuration '{ConfigurationName}'", TraceSeverity.Medium, EventSeverity.Information, TraceCategory.Configuration);
Logger.Log($"Microsoft Entra ID tenant '{this.TxtTenantName.Text}' was successfully added to configuration '{ConfigurationName}'", TraceSeverity.Medium, TraceCategory.Configuration);
LabelMessage.Text = String.Format(TextSummaryPersistedObjectInformation, Configuration.Name, Configuration.Version, Configuration.Id);

PopulateConnectionsGrid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public virtual ConfigStatus ValidatePrerequisite()
if (ConfigurationID == Guid.Empty) { Status |= ConfigStatus.PersistedObjectIDPropNotSet; }
if (Status != ConfigStatus.AllGood)
{
Logger.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
Logger.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, TraceCategory.Configuration);
return Status;
}

Expand All @@ -245,7 +245,7 @@ public virtual ConfigStatus ValidatePrerequisite()

if (Status != ConfigStatus.AllGood)
{
Logger.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
Logger.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, TraceCategory.Configuration);
return Status;
}

Expand All @@ -266,7 +266,7 @@ public virtual ConfigStatus ValidatePrerequisite()

if (Status != ConfigStatus.AllGood)
{
Logger.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
Logger.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, TraceCategory.Configuration);
}
return Status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ protected void InitializeValidation(List<ClaimTypeConfig> runtimeClaimTypesList)
!x.UseMainClaimTypeOfDirectoryObject);
if (incomingEntityClaimTypeConfig == null)
{
Logger.Log($"[{EntraCP.ClaimsProviderName}] Unable to validate entity \"{this.IncomingEntity.Value}\" because its claim type \"{this.IncomingEntity.ClaimType}\" was not found in the ClaimTypes list of current configuration.", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
Logger.Log($"[{EntraCP.ClaimsProviderName}] Unable to validate entity \"{this.IncomingEntity.Value}\" because its claim type \"{this.IncomingEntity.ClaimType}\" was not found in the ClaimTypes list of current configuration.", TraceSeverity.Unexpected, TraceCategory.Configuration);
throw new InvalidOperationException($"[{EntraCP.ClaimsProviderName}] Unable validate entity \"{this.IncomingEntity.Value}\" because its claim type \"{this.IncomingEntity.ClaimType}\" was not found in the ClaimTypes list of current configuration.");
}
this.CurrentClaimTypeConfigList = new List<ClaimTypeConfig>(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static ClaimTypeConfigCollection ReturnDefaultClaimTypesConfig(string cla
SPTrustedLoginProvider spTrust = Utils.GetSPTrustAssociatedWithClaimsProvider(claimsProviderName);
if (spTrust == null)
{
Logger.Log($"No SPTrustedLoginProvider associated with claims provider '{claimsProviderName}' was found.", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Core);
Logger.Log($"No SPTrustedLoginProvider associated with claims provider '{claimsProviderName}' was found.", TraceSeverity.Unexpected, TraceCategory.Core);
return null;
}

Expand Down Expand Up @@ -473,7 +473,7 @@ public override void Update()
{
this.ValidateConfiguration();
base.Update();
Logger.Log($"Successfully updated configuration '{this.Name}' with Id {this.Id}", TraceSeverity.High, EventSeverity.Information, TraceCategory.Core);
Logger.Log($"Successfully updated configuration '{this.Name}' with Id {this.Id}", TraceSeverity.High, TraceCategory.Core);
}

/// <summary>
Expand All @@ -484,7 +484,7 @@ public override void Update(bool ensure)
{
this.ValidateConfiguration();
base.Update(ensure);
Logger.Log($"Successfully updated configuration '{this.Name}' with Id {this.Id}", TraceSeverity.High, EventSeverity.Information, TraceCategory.Core);
Logger.Log($"Successfully updated configuration '{this.Name}' with Id {this.Id}", TraceSeverity.High, TraceCategory.Core);
}

/// <summary>
Expand Down Expand Up @@ -581,7 +581,7 @@ public virtual void ValidateConfiguration()
public override void Delete()
{
base.Delete();
Logger.Log($"Successfully deleted configuration '{this.Name}' with Id {this.Id}", TraceSeverity.High, EventSeverity.Information, TraceCategory.Core);
Logger.Log($"Successfully deleted configuration '{this.Name}' with Id {this.Id}", TraceSeverity.High, TraceCategory.Core);
}

/// <summary>
Expand Down Expand Up @@ -663,7 +663,7 @@ public void ResetClaimTypesList()
ClaimTypes.Clear();
ClaimTypes = ReturnDefaultClaimTypesConfig();
Logger.Log($"Claim types list of configuration '{Name}' was successfully reset to default configuration",
TraceSeverity.High, EventSeverity.Information, TraceCategory.Core);
TraceSeverity.High, TraceCategory.Core);
}

/// <summary>
Expand Down Expand Up @@ -699,11 +699,11 @@ public static void DeleteGlobalConfiguration(Guid configurationId)
EntraIDProviderConfiguration configuration = GetGlobalConfiguration(configurationId);
if (configuration == null)
{
Logger.Log($"Configuration ID '{configurationId}' was not found in configuration database", TraceSeverity.Medium, EventSeverity.Error, TraceCategory.Core);
Logger.Log($"Configuration ID '{configurationId}' was not found in configuration database", TraceSeverity.Medium, TraceCategory.Core);
return;
}
configuration.Delete();
Logger.Log($"Configuration ID '{configurationId}' was successfully deleted from configuration database", TraceSeverity.High, EventSeverity.Information, TraceCategory.Core);
Logger.Log($"Configuration ID '{configurationId}' was successfully deleted from configuration database", TraceSeverity.High, TraceCategory.Core);
}

/// <summary>
Expand Down Expand Up @@ -734,7 +734,7 @@ public static EntraIDProviderConfiguration CreateGlobalConfiguration(Guid config
DeleteGlobalConfiguration(configurationID);
}

Logger.Log($"Creating configuration '{configurationName}' with Id {configurationID}...", TraceSeverity.VerboseEx, EventSeverity.Error, TraceCategory.Core);
Logger.Log($"Creating configuration '{configurationName}' with Id {configurationID}...", TraceSeverity.VerboseEx, TraceCategory.Core);
//ConstructorInfo ctorWithParameters = T.GetConstructor(new[] { typeof(string), typeof(SPFarm), typeof(string) });
//EntraIDProviderConfiguration globalConfiguration = (EntraIDProviderConfiguration)ctorWithParameters.Invoke(new object[] { configurationName, SPFarm.Local, claimsProviderName });
//TSettings defaultSettings = globalConfiguration.GetDefaultSettings();
Expand All @@ -743,7 +743,7 @@ public static EntraIDProviderConfiguration CreateGlobalConfiguration(Guid config
globalConfiguration.ApplySettings(defaultSettings, false);
globalConfiguration.Id = configurationID;
globalConfiguration.Update(true);
Logger.Log($"Created configuration '{configurationName}' with Id {globalConfiguration.Id}", TraceSeverity.High, EventSeverity.Information, TraceCategory.Core);
Logger.Log($"Created configuration '{configurationName}' with Id {globalConfiguration.Id}", TraceSeverity.High, TraceCategory.Core);
return globalConfiguration;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,17 @@ public void InitializeAuthentication(int timeout, string proxyAddress)
{
if (String.IsNullOrWhiteSpace(this.ClientSecret) && this.ClientCertificateWithPrivateKey == null)
{
Logger.Log($"[{EntraCP.ClaimsProviderName}] Cannot initialize authentication for tenant {this.Name} because both properties {nameof(ClientSecret)} and {nameof(ClientCertificateWithPrivateKey)} are not set.", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
Logger.Log($"[{EntraCP.ClaimsProviderName}] Cannot initialize authentication for tenant {this.Name} because both properties {nameof(ClientSecret)} and {nameof(ClientCertificateWithPrivateKey)} are not set.", TraceSeverity.Unexpected, TraceCategory.Configuration);
return;
}
if (String.IsNullOrWhiteSpace(this.ClientId))
{
Logger.Log($"[{EntraCP.ClaimsProviderName}] Cannot initialize authentication for tenant {this.Name} because the property {nameof(ClientId)} is not set.", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
Logger.Log($"[{EntraCP.ClaimsProviderName}] Cannot initialize authentication for tenant {this.Name} because the property {nameof(ClientId)} is not set.", TraceSeverity.Unexpected, TraceCategory.Configuration);
return;
}
if (String.IsNullOrWhiteSpace(this.Name))
{
Logger.Log($"[{EntraCP.ClaimsProviderName}] Cannot initialize authentication because the property {nameof(Name)} of current tenant is not set.", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration);
Logger.Log($"[{EntraCP.ClaimsProviderName}] Cannot initialize authentication because the property {nameof(Name)} of current tenant is not set.", TraceSeverity.Unexpected, TraceCategory.Configuration);
return;
}

Expand Down Expand Up @@ -250,7 +250,7 @@ public void InitializeAuthentication(int timeout, string proxyAddress)
HttpClient httpClient = GraphClientFactory.Create(handlers: handlers, proxy: webProxy, nationalCloud: cloudInstanceSettings.NameInGraphCore);
httpClient.Timeout = TimeSpan.FromMilliseconds(requestsTimeout);
this.GraphService = new GraphServiceClient(httpClient, tokenCredential, new[] { cloudInstanceSettings.GraphScope });
Logger.Log($"[{EntraCP.ClaimsProviderName}] Initialized authentication for tenant \"{this.Name}\" on cloud instance \"{cloudInstanceSettings.Name}\" (authority \"{cloudInstanceSettings.Authority}\" and scope \"{cloudInstanceSettings.GraphScope}\").", TraceSeverity.High, EventSeverity.Information, TraceCategory.Configuration);
Logger.Log($"[{EntraCP.ClaimsProviderName}] Initialized authentication for tenant \"{this.Name}\" on cloud instance \"{cloudInstanceSettings.Name}\" (authority \"{cloudInstanceSettings.Authority}\" and scope \"{cloudInstanceSettings.GraphScope}\").", TraceSeverity.High, TraceCategory.Configuration);
}

public async Task<bool> TestConnectionAsync(string proxyAddress)
Expand Down
Loading

0 comments on commit 744b570

Please sign in to comment.