Improve domain enrollment and desktop personalization
This commit is contained in:
@@ -36,6 +36,12 @@ public static class SguProfileParser
|
||||
private const string StudentPostalCodeId = "ctl00_contenedor_HistorialAlumno1_lblCPAlumnoHP";
|
||||
|
||||
public static InstitutionalProfile? ParseAdministrative(string html, string expectedEmployeeNumber)
|
||||
=> ParseStaffHeader(html, expectedEmployeeNumber);
|
||||
|
||||
public static InstitutionalProfile? ParseProfessorPayroll(string html, string expectedEmployeeNumber)
|
||||
=> ParseStaffHeader(html, expectedEmployeeNumber);
|
||||
|
||||
private static InstitutionalProfile? ParseStaffHeader(string html, string expectedEmployeeNumber)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(html);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(expectedEmployeeNumber);
|
||||
|
||||
@@ -49,6 +49,7 @@ public sealed class BrokerOptions
|
||||
Ntlm.AdministrativePersonalProfilePath,
|
||||
Ntlm.AdministrativeLocationProfilePath,
|
||||
Ntlm.StudentProfilePath,
|
||||
Ntlm.ProfessorPayrollProfilePath,
|
||||
Ntlm.MenuProfilePath
|
||||
})
|
||||
{
|
||||
@@ -141,6 +142,9 @@ public sealed class NtlmOptions
|
||||
public string StudentProfilePath { get; init; } =
|
||||
"/psulsa/alumnos/consultainformacionalumnos/consultainformacion.aspx";
|
||||
|
||||
public string ProfessorPayrollProfilePath { get; init; } =
|
||||
"/psulsa/gadmon/nomina/consultanomina.aspx";
|
||||
|
||||
public string MenuProfilePath { get; init; } = "/psulsa/menu.aspx";
|
||||
|
||||
public int MaxProfileBytes { get; init; } = 512 * 1024;
|
||||
|
||||
@@ -344,7 +344,7 @@ public sealed class NtlmCredentialValidator : INtlmCredentialValidator
|
||||
profile = await TryEnrichStaffProfileAsync(
|
||||
client,
|
||||
profile!,
|
||||
identity.Role,
|
||||
identity,
|
||||
allowedHosts,
|
||||
timeout.Token,
|
||||
cancellationToken,
|
||||
@@ -413,18 +413,27 @@ public sealed class NtlmCredentialValidator : INtlmCredentialValidator
|
||||
private async Task<InstitutionalProfile> TryEnrichStaffProfileAsync(
|
||||
HttpClient client,
|
||||
InstitutionalProfile baseProfile,
|
||||
InstitutionalRole role,
|
||||
UserIdentity identity,
|
||||
HashSet<string> allowedHosts,
|
||||
CancellationToken timeoutToken,
|
||||
CancellationToken requestCancellationToken,
|
||||
Stopwatch elapsed)
|
||||
{
|
||||
InstitutionalProfile profile = baseProfile;
|
||||
(string Path, Func<string, InstitutionalProfile?> Parser)[] pages =
|
||||
[
|
||||
(options.AdministrativePersonalProfilePath, SguProfileParser.ParseAdministrativePersonal),
|
||||
(options.AdministrativeLocationProfilePath, SguProfileParser.ParseAdministrativeLocation)
|
||||
];
|
||||
List<(string Path, Func<string, InstitutionalProfile?> Parser)> pages = [];
|
||||
if (identity.Role == InstitutionalRole.Professor)
|
||||
{
|
||||
pages.Add((
|
||||
options.ProfessorPayrollProfilePath,
|
||||
html => SguProfileParser.ParseProfessorPayroll(html, identity.NumericId)));
|
||||
}
|
||||
|
||||
pages.Add((
|
||||
options.AdministrativePersonalProfilePath,
|
||||
SguProfileParser.ParseAdministrativePersonal));
|
||||
pages.Add((
|
||||
options.AdministrativeLocationProfilePath,
|
||||
SguProfileParser.ParseAdministrativeLocation));
|
||||
|
||||
foreach ((string path, Func<string, InstitutionalProfile?> parser) in pages)
|
||||
{
|
||||
@@ -441,7 +450,7 @@ public sealed class NtlmCredentialValidator : INtlmCredentialValidator
|
||||
BrokerEventIds.ProfilePageUnavailable,
|
||||
"Optional SGU profile page {Path} did not return usable HTML for role {Role}; preserving fields already collected.",
|
||||
path,
|
||||
role);
|
||||
identity.Role);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -452,7 +461,7 @@ public sealed class NtlmCredentialValidator : INtlmCredentialValidator
|
||||
BrokerEventIds.ProfileHtmlUnexpected,
|
||||
"Optional SGU profile page {Path} returned HTML without its supported field IDs for role {Role}; preserving fields already collected.",
|
||||
path,
|
||||
role);
|
||||
identity.Role);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -463,7 +472,7 @@ public sealed class NtlmCredentialValidator : INtlmCredentialValidator
|
||||
logger.LogWarning(
|
||||
BrokerEventIds.ProfileEnrichmentTimeout,
|
||||
"SGU optional staff profile enrichment for role {Role} reached its total timeout after {ElapsedMilliseconds} ms; preserving fields already collected.",
|
||||
role,
|
||||
identity.Role,
|
||||
elapsed.ElapsedMilliseconds);
|
||||
break;
|
||||
}
|
||||
@@ -473,7 +482,7 @@ public sealed class NtlmCredentialValidator : INtlmCredentialValidator
|
||||
BrokerEventIds.ProfileEnrichmentFailure,
|
||||
exception,
|
||||
"An optional SGU staff profile page for role {Role} failed after {ElapsedMilliseconds} ms; preserving fields already collected.",
|
||||
role,
|
||||
identity.Role,
|
||||
elapsed.ElapsedMilliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"AdministrativePersonalProfilePath": "/psulsa/gadmon/capitalhumano/datos/personales.aspx",
|
||||
"AdministrativeLocationProfilePath": "/psulsa/gadmon/capitalhumano/datos/ubicacion.aspx",
|
||||
"StudentProfilePath": "/psulsa/alumnos/consultainformacionalumnos/consultainformacion.aspx",
|
||||
"ProfessorPayrollProfilePath": "/psulsa/gadmon/nomina/consultanomina.aspx",
|
||||
"MenuProfilePath": "/psulsa/menu.aspx",
|
||||
"MaxProfileBytes": 524288,
|
||||
"AllowedRedirectHosts": [
|
||||
|
||||
Reference in New Issue
Block a user