Unify AD and SGU sign-in in Acceso Institucional

This commit is contained in:
alexrg committed 2026-09-22 16:00:16 -06:00
1 parent 2e972a06bd
commit 771dc60f7d
13 files changed
+151 -79

No files matched your search

+14 -12
View File
@@ -13,24 +13,26 @@ Ready-to-run bootstrap packages are published on the
## Authentication contract ## Authentication contract
1. Windows presents one **La Salle** sign-in tile with `Usuario` and `Contraseña`. 1. Windows selects **Acceso Institucional** by default. The built-in
2. The user enters a `DO`, `AL`, or `AD` key and the current password once. Microsoft password provider stays available for recovery.
3. The tile sends that exact pair over mutually authenticated TLS to the broker, 2. Ordinary domain usernames go straight to Windows for Active Directory
which validates it against the institutional authority. Only an authoritative authentication. A `DO`, `AL`, or `AD` key is checked against SGU first.
`401`/`403` rejects it. 3. The tile sends recognized institutional keys and their exact passwords over
4. On every valid sign-in, the broker performs an idempotent Active Directory mutually authenticated TLS. After SGU accepts the credential, the broker
UPSERT: it creates or repairs the account, its role OU and group, supported performs an idempotent Active Directory UPSERT: it creates or repairs the
profile fields, and the AD password using the password just validated. account, role OU and group, supported profile fields, and AD password.
5. The Credential Provider serializes the original `SecureString` to Windows. 4. If SGU rejects the key or is unavailable, the unchanged credentials go to
Windows. Existing AD accounts can authenticate there; unknown or misspelled
accounts are rejected by Windows and are never created.
No derived password is created. Passwords are not written to a database, file, No derived password is created. Passwords are not written to a database, file,
event log, application log, command line, or response. event log, application log, command line, or response.
This makes Active Directory the only Windows sign-in account while preserving This makes Active Directory the only Windows sign-in account while preserving
automatic synchronization: if a person changes their institutional password, automatic synchronization: if a person changes their institutional password,
the next successful La Salle sign-in updates the domain password before Windows the next successful Acceso Institucional sign-in updates the domain password
continues. A matching prefix alone never creates an account; the institutional before Windows continues. A matching prefix alone never creates an account;
authority must first accept the submitted password. the institutional authority must first accept the submitted password.
For administrative accounts, profile enrichment first verifies the employee For administrative accounts, profile enrichment first verifies the employee
number against the incident overview, then reads the structured given names and number against the incident overview, then reads the structured given names and
+18 -15
View File
@@ -52,22 +52,24 @@ Broker timeout, TLS failure, 429, or 5xx
-> only the last AD password succeeds -> only the last AD password succeeds
``` ```
An explicit `400` or `401` from the broker is different: the provider displays An explicit `400` or `401` from SGU does not create or update an account. The
an error and does not serialize the rejected credential. tile submits the unchanged credentials to Windows, which accepts them only if
they match an existing Active Directory account.
## Account synchronization ## Account synchronization
The visible Windows experience is a single **La Salle** sign-in tile with The visible Windows experience is one **Acceso Institucional** sign-in tile,
`Usuario` and `Contraseña`; the institutional authority is not a separate tile selected by default, with `Usuario` and `Contraseña`. Ordinary usernames go
or second password prompt. The broker normalizes the username to uppercase and straight to Windows for domain authentication. A `DO`, `AL`, or `AD` key is
accepts exactly two letters plus six digits. After the authority accepts the checked by the broker against SGU. After SGU accepts the submitted password,
submitted password, it searches `BaseDn` by `sAMAccountName`, creates the user the broker searches `BaseDn` by `sAMAccountName`, creates the user when absent,
when absent, moves it to the mapped OU when required, sets `userPrincipalName`, moves it to the mapped OU when required, sets `userPrincipalName`, and passes
and passes that same submitted password directly to ADSI `SetPassword`. This is that same password directly to ADSI `SetPassword`. This is an idempotent UPSERT
an idempotent UPSERT performed on every successful sign-in, so the next sign-in performed on every successful sign-in, so the next sign-in after an institutional
after an institutional password change updates AD before Windows validates the password change updates AD before Windows validates the interactive logon. If
interactive logon. A matching username pattern alone never provisions an SGU rejects the credential or is unavailable, the unchanged credentials go to
account. Windows; only an existing AD account can then authenticate. A matching username
pattern alone never provisions an account.
Before an account becomes usable, the broker applies explicit deny ACEs for the Before an account becomes usable, the broker applies explicit deny ACEs for the
Active Directory `Change Password` extended right to SELF and Everyone. Users Active Directory `Change Password` extended right to SELF and Everyone. Users
@@ -132,8 +134,9 @@ Windows client maps the group into its local **Remote Desktop Users** group.
Every synchronized user also receives `La Salle` in the AD Every synchronized user also receives `La Salle` in the AD
`company` attribute unless deployment configuration supplies another default. `company` attribute unless deployment configuration supplies another default.
The generic La Salle credential is rendered as a dedicated branded tile instead of The generic Acceso Institucional credential is rendered as a dedicated
being grouped below the anonymous **Other user** tile. Machine policy assigns branded tile instead of being grouped below the anonymous **Other user** tile.
Machine policy assigns
the provider CLSID as the default provider, hides the last signed-in identity, and the provider CLSID as the default provider, hides the last signed-in identity, and
disables local-user enumeration while retaining the built-in Microsoft password disables local-user enumeration while retaining the built-in Microsoft password
provider and its **Other user** recovery path. The computer GPO also applies provider and its **Other user** recovery path. The computer GPO also applies
+6 -5
View File
@@ -232,14 +232,15 @@ administradores.
El proveedor usa un mosaico genérico dedicado, no una credencial asociada al SID El proveedor usa un mosaico genérico dedicado, no una credencial asociada al SID
anónimo de **Other user**. Windows muestra la imagen institucional y la etiqueta anónimo de **Other user**. Windows muestra la imagen institucional y la etiqueta
`La Salle`; el encabezado `Iniciar sesión` se publica como `CPFT_LARGE_TEXT` `Acceso Institucional`; el encabezado `Iniciar sesión` se publica como
solamente en el mosaico seleccionado. El usuario captura una sola vez `Usuario` `CPFT_LARGE_TEXT` solamente en el mosaico seleccionado. El instalador selecciona
y `Contraseña`; la sincronización institucional y el UPSERT de Active Directory ese proveedor por defecto. Los usuarios de dominio se validan contra Active
ocurren detrás de esa misma pantalla. LogonUI Directory; las claves institucionales aceptadas por SGU hacen el UPSERT en AD
desde ese mismo mosaico. LogonUI
elige la familia, el peso y el tamaño final y no expone opciones de tipografía a elige la familia, el peso y el tamaño final y no expone opciones de tipografía a
un Credential Provider. un Credential Provider.
La configuración soportada garantiza que SGU queda seleccionado por defecto y La configuración soportada garantiza que Acceso Institucional queda seleccionado por defecto y
que no se conserva el último usuario. El orden vertical exacto de mosaicos lo que no se conserva el último usuario. El orden vertical exacto de mosaicos lo
decide LogonUI y no tiene una directiva pública. Por seguridad no se filtra ni decide LogonUI y no tiene una directiva pública. Por seguridad no se filtra ni
se elimina **Other user**: Microsoft recomienda conservar al menos un proveedor se elimina **Other user**: Microsoft recomienda conservar al menos un proveedor
+1 -1
View File
@@ -136,7 +136,7 @@ On Windows 10:
``` ```
Use Lithnet's `Invoke-CredUI` test utility when available, or sign out/restart Use Lithnet's `Invoke-CredUI` test utility when available, or sign out/restart
the VM and select **La Salle**. Keep the built-in Windows the VM and select **Acceso Institucional**. Keep the built-in Windows
password provider available through **Other user**. password provider available through **Other user**.
On the domain controller, apply the SGU user and computer policies once: On the domain controller, apply the SGU user and computer policies once:
+18
View File
@@ -0,0 +1,18 @@
# SGU Credential Provider 0.6.14
El mosaico predeterminado se llama **Acceso Institucional**. En él se pueden
usar tanto cuentas existentes de Active Directory como claves institucionales
DO, AL y AD:
- Los usuarios de dominio que no son claves institucionales se envían
directamente a Windows para validación por Active Directory.
- Las claves institucionales se validan primero contra SGU. Si SGU las acepta,
el broker enriquece o actualiza la cuenta y sincroniza la contraseña con AD.
- Si SGU rechaza la clave o no está disponible, Windows valida la credencial
existente contra AD o las credenciales de dominio guardadas en caché. Una
cuenta inexistente no se crea sin una validación SGU correcta.
- El instalador y la GPO seleccionan **Acceso Institucional** como predeterminado
y conservan el proveedor de contraseña de Microsoft para recuperación.
El mosaico recopila el usuario y la contraseña una sola vez. La contraseña no
se deriva ni se guarda en un archivo, base de datos o registro.
+8 -6
View File
@@ -87,13 +87,15 @@ Use an enterprise CA with revocation checking in production.
## Recovery and availability ## Recovery and availability
The provider distinguishes an authoritative rejection from unavailable The provider distinguishes an SGU rejection from unavailable infrastructure:
infrastructure:
- `400`/`401`: fail closed and show an error. - `400`/`401`: do not create or update the account; submit the unchanged
- timeout, TLS/connectivity error, `429`, or `5xx`: submit the unchanged credential credential to Windows so an existing AD account can authenticate.
to Windows. Windows must still validate it against AD or the cached domain - timeout, TLS/connectivity error, `429`, or `5xx`: submit the unchanged
verifier, so this does not grant access without the last synchronized password. credential to Windows. Windows must still validate it against AD or its cached
domain verifier, so this does not grant access without a domain credential.
- usernames that do not match the institutional key format go directly to
Windows and are never sent to SGU or provisioned by the broker.
Redis is deliberately not used for password continuity. A second persistent Redis is deliberately not used for password continuity. A second persistent
password verifier duplicates attackable credential material, while a reversible password verifier duplicates attackable credential material, while a reversible
+3 -2
View File
@@ -97,8 +97,9 @@ usuario que cerró sesión y deshabilita la enumeración de usuarios locales en
equipo unido al dominio. No modifica ni oculta el proveedor de contraseña de equipo unido al dominio. No modifica ni oculta el proveedor de contraseña de
Microsoft; **Other user** permanece como ruta de recuperación. Microsoft; **Other user** permanece como ruta de recuperación.
Cerrar sesión o reiniciar el equipo. El acceso La Salle debe quedar seleccionado por Cerrar sesión o reiniciar el equipo. **Acceso Institucional** debe quedar
defecto y el proveedor de contraseña de Microsoft debe permanecer disponible. seleccionado por defecto; el proveedor nativo de Microsoft permanece disponible
para recuperación.
## 5. Verificación ## 5. Verificación
+1 -4
View File
@@ -300,10 +300,7 @@ if ($PSCmdlet.ShouldProcess($installPath, 'Install and register the SGU Credenti
New-ItemProperty -Path $classRegistryPath -Name ThreadingModel -Value Both -PropertyType String -Force | Out-Null New-ItemProperty -Path $classRegistryPath -Name ThreadingModel -Value Both -PropertyType String -Force | Out-Null
New-Item -Path $providerRegistryPath -Force | Out-Null New-Item -Path $providerRegistryPath -Force | Out-Null
# Windows PowerShell 5.1 interprets an UTF-8 script without a BOM using the Set-Item -Path $providerRegistryPath -Value 'Acceso Institucional'
# current ANSI code page. Construct the middle dot from its Unicode value so
# the LogonUI registry label remains correct on every client locale.
Set-Item -Path $providerRegistryPath -Value 'La Salle'
if (-not $DoNotSetAsDefaultCredentialProvider) { if (-not $DoNotSetAsDefaultCredentialProvider) {
if (-not (Test-Path -LiteralPath $defaultProviderPolicyPath)) { if (-not (Test-Path -LiteralPath $defaultProviderPolicyPath)) {
@@ -1,12 +1,12 @@
[CmdletBinding(SupportsShouldProcess)] [CmdletBinding(SupportsShouldProcess)]
param( param(
[string]$Version = '0.6.13', [string]$Version = '0.6.14',
[ValidatePattern('^https://')] [ValidatePattern('^https://')]
[string]$ClientPackageUri = 'https://gitea.lci.ulsa.mx/alexrg/SGU-CredentialProvider/releases/download/v0.6.13/sgu-windows-client-bootstrap-0.6.13.zip', [string]$ClientPackageUri = 'https://gitea.lci.ulsa.mx/alexrg/SGU-CredentialProvider/releases/download/v0.6.14/sgu-windows-client-bootstrap-0.6.14.zip',
[ValidatePattern('^[0-9A-Fa-f]{64}$')] [ValidatePattern('^[0-9A-Fa-f]{64}$')]
[string]$ClientPackageSha256 = 'C793A62758A067401AB1F42C147B7A65A6DD96B606BE1674A2C9615844405837', [string]$ClientPackageSha256 = 'A409BC60E90EB13029945FCBBAAC3F17547F98ACE9D58032673F2F9350D17669',
[string]$GpoName = 'SGU - Credential Provider update', [string]$GpoName = 'SGU - Credential Provider update',
@@ -16,10 +16,10 @@ public sealed class SguCredentialProvider : CredentialProviderBase
{ {
yield return new CredentialProviderLabelControl( yield return new CredentialProviderLabelControl(
ControlKeys.ProviderLabel, ControlKeys.ProviderLabel,
"La Salle"); "Acceso Institucional");
yield return new CredentialProviderLogoControl( yield return new CredentialProviderLogoControl(
ControlKeys.ProviderLogo, ControlKeys.ProviderLogo,
"Inicio de sesión La Salle", "Acceso Institucional",
ProviderTileIcon.Create()); ProviderTileIcon.Create());
yield return new LargeLabelControl(ControlKeys.Heading, "Iniciar sesión") yield return new LargeLabelControl(ControlKeys.Heading, "Iniciar sesión")
{ {
@@ -29,7 +29,7 @@ public sealed class SguCredentialProvider : CredentialProviderBase
}; };
yield return new SmallLabelControl( yield return new SmallLabelControl(
ControlKeys.InformationLabel, ControlKeys.InformationLabel,
"Escribe tu usuario y contraseña."); "Escribe tu usuario institucional o de dominio y contraseña.");
yield return new TextboxControl(ControlKeys.UserName, "Usuario"); yield return new TextboxControl(ControlKeys.UserName, "Usuario");
SecurePasswordTextboxControl password = new(ControlKeys.Password, "Contraseña"); SecurePasswordTextboxControl password = new(ControlKeys.Password, "Contraseña");
yield return password; yield return password;
+72 -24
View File
@@ -34,9 +34,14 @@ internal sealed class SguCredentialTile : CredentialTile3
protected override CredentialResponseBase GetCredentials() protected override CredentialResponseBase GetCredentials()
{ {
if (!UserIdentityClassifier.TryParse(userNameControl.Text, out UserIdentity? identity) || identity is null) ProviderSettings settings = TryLoadDomainOnlySettings();
if (!TryGetWindowsLogonName(
userNameControl.Text,
settings.DomainNetbios,
out string domain,
out string userName))
{ {
return Failure("El usuario debe usar DO, AL o AD seguido de seis dígitos."); return Failure("Escribe un usuario válido.");
} }
SecureString securePassword = passwordControl.Password; SecureString securePassword = passwordControl.Password;
@@ -45,10 +50,16 @@ internal sealed class SguCredentialTile : CredentialTile3
return Failure("La contraseña es requerida."); return Failure("La contraseña es requerida.");
} }
// Ordinary Active Directory accounts go straight to Windows. Only an
// institutional key needs SGU validation and the account UPSERT.
if (!UserIdentityClassifier.TryParse(userNameControl.Text, out UserIdentity? identity) || identity is null)
{
return DomainCredential(domain, userName, securePassword);
}
string plainTextPassword = CopyToManagedString(securePassword); string plainTextPassword = CopyToManagedString(securePassword);
try try
{ {
ProviderSettings settings;
BrokerDecision decision; BrokerDecision decision;
try try
{ {
@@ -61,33 +72,25 @@ internal sealed class SguCredentialTile : CredentialTile3
} }
catch catch
{ {
settings = TryLoadDomainOnlySettings();
decision = BrokerDecision.Unavailable("LOCAL_CONFIGURATION_OR_TLS_ERROR"); decision = BrokerDecision.Unavailable("LOCAL_CONFIGURATION_OR_TLS_ERROR");
} }
if (decision.Kind == BrokerDecisionKind.InvalidCredentials) if (decision.Kind == BrokerDecisionKind.Authorized)
{ {
return Failure("Usuario o contraseña incorrectos."); return DomainCredential(decision.Domain!, decision.UserName!, securePassword);
} }
string domain = decision.Kind == BrokerDecisionKind.Authorized // An SGU rejection does not create an account. Pass the unchanged
? decision.Domain! // credential to Windows so an existing AD account with the same
: settings.DomainNetbios; // name can still authenticate. A non-existent account is rejected
string userName = decision.Kind == BrokerDecisionKind.Authorized // by the domain controller.
? decision.UserName! return DomainCredential(
: identity.UserName; domain,
userName,
return new CredentialResponseSecure securePassword,
{ decision.Kind == BrokerDecisionKind.Unavailable
IsSuccess = true, ? "El servicio SGU no está disponible; Windows validará la contraseña guardada en el dominio."
StatusIcon = decision.Kind == BrokerDecisionKind.Unavailable ? StatusIcon.Warning : StatusIcon.None, : null);
StatusText = decision.Kind == BrokerDecisionKind.Unavailable
? "El servicio de autenticación no está disponible; Windows validará la última contraseña de dominio registrada."
: null,
Domain = domain,
Username = userName,
Password = securePassword
};
} }
finally finally
{ {
@@ -111,6 +114,51 @@ internal sealed class SguCredentialTile : CredentialTile3
} }
} }
private static bool TryGetWindowsLogonName(
string? enteredName,
string defaultDomain,
out string domain,
out string userName)
{
domain = string.Empty;
userName = enteredName?.Trim() ?? string.Empty;
if (userName.Length is 0 or > 256 || userName.Any(char.IsControl))
{
return false;
}
int slash = userName.LastIndexOf('\\');
if (slash >= 0)
{
domain = userName[..slash];
userName = userName[(slash + 1)..];
if (domain.Length is 0 or > 256 || domain.Contains('\\') || userName.Length == 0)
{
return false;
}
}
else if (!userName.Contains('@'))
{
domain = defaultDomain;
}
return userName.Length > 0 && domain.Length <= 256 && !domain.Any(char.IsControl);
}
private static CredentialResponseSecure DomainCredential(
string domain,
string userName,
SecureString password,
string? statusText = null) => new()
{
IsSuccess = true,
StatusIcon = statusText is null ? StatusIcon.None : StatusIcon.Warning,
StatusText = statusText,
Domain = domain,
Username = userName,
Password = password
};
private static CredentialResponseSecure Failure(string message) => new() private static CredentialResponseSecure Failure(string message) => new()
{ {
IsSuccess = false, IsSuccess = false,
@@ -14,10 +14,10 @@ internal static class Program
private static readonly string[] ExpectedLabels = private static readonly string[] ExpectedLabels =
[ [
"La Salle", "Acceso Institucional",
"Inicio de sesión La Salle", "Acceso Institucional",
"Iniciar sesión", "Iniciar sesión",
"Escribe tu usuario y contraseña.", "Escribe tu usuario institucional o de dominio y contraseña.",
"Usuario", "Usuario",
"Contraseña", "Contraseña",
"Iniciar sesión" "Iniciar sesión"
@@ -55,7 +55,7 @@ public sealed class ProviderTileIconTests
LargeLabelControl heading = Assert.Single(controls.OfType<LargeLabelControl>()); LargeLabelControl heading = Assert.Single(controls.OfType<LargeLabelControl>());
SguCredentialTile tile = Assert.IsType<SguCredentialTile>(provider.CreateGenericTile()); SguCredentialTile tile = Assert.IsType<SguCredentialTile>(provider.CreateGenericTile());
Assert.Equal("La Salle", providerLabel.Label); Assert.Equal("Acceso Institucional", providerLabel.Label);
Assert.Equal("Iniciar sesión", heading.Label); Assert.Equal("Iniciar sesión", heading.Label);
Assert.Equal(FieldState.DisplayInSelectedTile, heading.State); Assert.Equal(FieldState.DisplayInSelectedTile, heading.State);
Assert.Equal(GenericTileDisplayMode.DisplayAsDedicatedTile, tile.GenericTileDisplayMode); Assert.Equal(GenericTileDisplayMode.DisplayAsDedicatedTile, tile.GenericTileDisplayMode);