diff --git a/README.md b/README.md index 88eddd8..2a49c07 100644 --- a/README.md +++ b/README.md @@ -13,24 +13,26 @@ Ready-to-run bootstrap packages are published on the ## Authentication contract -1. Windows presents one **La Salle** sign-in tile with `Usuario` and `Contraseña`. -2. The user enters a `DO`, `AL`, or `AD` key and the current password once. -3. The tile sends that exact pair over mutually authenticated TLS to the broker, - which validates it against the institutional authority. Only an authoritative - `401`/`403` rejects it. -4. On every valid sign-in, the broker performs an idempotent Active Directory - UPSERT: it creates or repairs the account, its role OU and group, supported - profile fields, and the AD password using the password just validated. -5. The Credential Provider serializes the original `SecureString` to Windows. +1. Windows selects **Acceso Institucional** by default. The built-in + Microsoft password provider stays available for recovery. +2. Ordinary domain usernames go straight to Windows for Active Directory + authentication. A `DO`, `AL`, or `AD` key is checked against SGU first. +3. The tile sends recognized institutional keys and their exact passwords over + mutually authenticated TLS. After SGU accepts the credential, the broker + performs an idempotent Active Directory UPSERT: it creates or repairs the + account, role OU and group, supported profile fields, and AD password. +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, event log, application log, command line, or response. This makes Active Directory the only Windows sign-in account while preserving automatic synchronization: if a person changes their institutional password, -the next successful La Salle sign-in updates the domain password before Windows -continues. A matching prefix alone never creates an account; the institutional -authority must first accept the submitted password. +the next successful Acceso Institucional sign-in updates the domain password +before Windows continues. A matching prefix alone never creates an account; +the institutional authority must first accept the submitted password. For administrative accounts, profile enrichment first verifies the employee number against the incident overview, then reads the structured given names and diff --git a/docs/architecture.md b/docs/architecture.md index 98ebf14..71ad9fa 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -52,22 +52,24 @@ Broker timeout, TLS failure, 429, or 5xx -> only the last AD password succeeds ``` -An explicit `400` or `401` from the broker is different: the provider displays -an error and does not serialize the rejected credential. +An explicit `400` or `401` from SGU does not create or update an account. The +tile submits the unchanged credentials to Windows, which accepts them only if +they match an existing Active Directory account. ## Account synchronization -The visible Windows experience is a single **La Salle** sign-in tile with -`Usuario` and `Contraseña`; the institutional authority is not a separate tile -or second password prompt. The broker normalizes the username to uppercase and -accepts exactly two letters plus six digits. After the authority accepts the -submitted password, it searches `BaseDn` by `sAMAccountName`, creates the user -when absent, moves it to the mapped OU when required, sets `userPrincipalName`, -and passes that same submitted password directly to ADSI `SetPassword`. This is -an idempotent UPSERT performed on every successful sign-in, so the next sign-in -after an institutional password change updates AD before Windows validates the -interactive logon. A matching username pattern alone never provisions an -account. +The visible Windows experience is one **Acceso Institucional** sign-in tile, +selected by default, with `Usuario` and `Contraseña`. Ordinary usernames go +straight to Windows for domain authentication. A `DO`, `AL`, or `AD` key is +checked by the broker against SGU. After SGU accepts the submitted password, +the broker searches `BaseDn` by `sAMAccountName`, creates the user when absent, +moves it to the mapped OU when required, sets `userPrincipalName`, and passes +that same password directly to ADSI `SetPassword`. This is an idempotent UPSERT +performed on every successful sign-in, so the next sign-in after an institutional +password change updates AD before Windows validates the interactive logon. If +SGU rejects the credential or is unavailable, the unchanged credentials go to +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 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 `company` attribute unless deployment configuration supplies another default. -The generic La Salle credential is rendered as a dedicated branded tile instead of -being grouped below the anonymous **Other user** tile. Machine policy assigns +The generic Acceso Institucional credential is rendered as a dedicated +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 disables local-user enumeration while retaining the built-in Microsoft password provider and its **Other user** recovery path. The computer GPO also applies diff --git a/docs/client-enrollment.md b/docs/client-enrollment.md index 38b54b3..5f3186a 100644 --- a/docs/client-enrollment.md +++ b/docs/client-enrollment.md @@ -232,14 +232,15 @@ administradores. 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 -`La Salle`; el encabezado `Iniciar sesión` se publica como `CPFT_LARGE_TEXT` -solamente en el mosaico seleccionado. El usuario captura una sola vez `Usuario` -y `Contraseña`; la sincronización institucional y el UPSERT de Active Directory -ocurren detrás de esa misma pantalla. LogonUI +`Acceso Institucional`; el encabezado `Iniciar sesión` se publica como +`CPFT_LARGE_TEXT` solamente en el mosaico seleccionado. El instalador selecciona +ese proveedor por defecto. Los usuarios de dominio se validan contra Active +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 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 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 diff --git a/docs/lab-runbook.md b/docs/lab-runbook.md index 2358283..9baa75d 100644 --- a/docs/lab-runbook.md +++ b/docs/lab-runbook.md @@ -136,7 +136,7 @@ On Windows 10: ``` 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**. On the domain controller, apply the SGU user and computer policies once: diff --git a/docs/release-0.6.14.md b/docs/release-0.6.14.md new file mode 100644 index 0000000..d6930f7 --- /dev/null +++ b/docs/release-0.6.14.md @@ -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. diff --git a/docs/security.md b/docs/security.md index 25a03b0..2845d34 100644 --- a/docs/security.md +++ b/docs/security.md @@ -87,13 +87,15 @@ Use an enterprise CA with revocation checking in production. ## Recovery and availability -The provider distinguishes an authoritative rejection from unavailable -infrastructure: +The provider distinguishes an SGU rejection from unavailable infrastructure: -- `400`/`401`: fail closed and show an error. -- timeout, TLS/connectivity error, `429`, or `5xx`: submit the unchanged credential - to Windows. Windows must still validate it against AD or the cached domain - verifier, so this does not grant access without the last synchronized password. +- `400`/`401`: do not create or update the account; submit the unchanged + credential to Windows so an existing AD account can authenticate. +- timeout, TLS/connectivity error, `429`, or `5xx`: submit the unchanged + 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 password verifier duplicates attackable credential material, while a reversible diff --git a/docs/windows-client-onboarding.md b/docs/windows-client-onboarding.md index 1229f21..e1550e4 100644 --- a/docs/windows-client-onboarding.md +++ b/docs/windows-client-onboarding.md @@ -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 Microsoft; **Other user** permanece como ruta de recuperación. -Cerrar sesión o reiniciar el equipo. El acceso La Salle debe quedar seleccionado por -defecto y el proveedor de contraseña de Microsoft debe permanecer disponible. +Cerrar sesión o reiniciar el equipo. **Acceso Institucional** debe quedar +seleccionado por defecto; el proveedor nativo de Microsoft permanece disponible +para recuperación. ## 5. Verificación diff --git a/scripts/Install-CredentialProvider.ps1 b/scripts/Install-CredentialProvider.ps1 index 7e22ec8..896d610 100644 --- a/scripts/Install-CredentialProvider.ps1 +++ b/scripts/Install-CredentialProvider.ps1 @@ -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-Item -Path $providerRegistryPath -Force | Out-Null - # Windows PowerShell 5.1 interprets an UTF-8 script without a BOM using the - # 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' + Set-Item -Path $providerRegistryPath -Value 'Acceso Institucional' if (-not $DoNotSetAsDefaultCredentialProvider) { if (-not (Test-Path -LiteralPath $defaultProviderPolicyPath)) { diff --git a/scripts/Install-SguCredentialProviderUpdatePolicy.ps1 b/scripts/Install-SguCredentialProviderUpdatePolicy.ps1 index eb52d84..a4a7793 100644 --- a/scripts/Install-SguCredentialProviderUpdatePolicy.ps1 +++ b/scripts/Install-SguCredentialProviderUpdatePolicy.ps1 @@ -1,12 +1,12 @@ [CmdletBinding(SupportsShouldProcess)] param( - [string]$Version = '0.6.13', + [string]$Version = '0.6.14', [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}$')] - [string]$ClientPackageSha256 = 'C793A62758A067401AB1F42C147B7A65A6DD96B606BE1674A2C9615844405837', + [string]$ClientPackageSha256 = 'A409BC60E90EB13029945FCBBAAC3F17547F98ACE9D58032673F2F9350D17669', [string]$GpoName = 'SGU - Credential Provider update', diff --git a/src/SGU.CredentialProvider/SguCredentialProvider.cs b/src/SGU.CredentialProvider/SguCredentialProvider.cs index 9e4f907..83ce0d2 100644 --- a/src/SGU.CredentialProvider/SguCredentialProvider.cs +++ b/src/SGU.CredentialProvider/SguCredentialProvider.cs @@ -16,10 +16,10 @@ public sealed class SguCredentialProvider : CredentialProviderBase { yield return new CredentialProviderLabelControl( ControlKeys.ProviderLabel, - "La Salle"); + "Acceso Institucional"); yield return new CredentialProviderLogoControl( ControlKeys.ProviderLogo, - "Inicio de sesión La Salle", + "Acceso Institucional", ProviderTileIcon.Create()); yield return new LargeLabelControl(ControlKeys.Heading, "Iniciar sesión") { @@ -29,7 +29,7 @@ public sealed class SguCredentialProvider : CredentialProviderBase }; yield return new SmallLabelControl( 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"); SecurePasswordTextboxControl password = new(ControlKeys.Password, "Contraseña"); yield return password; diff --git a/src/SGU.CredentialProvider/SguCredentialTile.cs b/src/SGU.CredentialProvider/SguCredentialTile.cs index 00194ad..b75318c 100644 --- a/src/SGU.CredentialProvider/SguCredentialTile.cs +++ b/src/SGU.CredentialProvider/SguCredentialTile.cs @@ -34,9 +34,14 @@ internal sealed class SguCredentialTile : CredentialTile3 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; @@ -45,10 +50,16 @@ internal sealed class SguCredentialTile : CredentialTile3 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); try { - ProviderSettings settings; BrokerDecision decision; try { @@ -61,33 +72,25 @@ internal sealed class SguCredentialTile : CredentialTile3 } catch { - settings = TryLoadDomainOnlySettings(); 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 - ? decision.Domain! - : settings.DomainNetbios; - string userName = decision.Kind == BrokerDecisionKind.Authorized - ? decision.UserName! - : identity.UserName; - - return new CredentialResponseSecure - { - IsSuccess = true, - StatusIcon = decision.Kind == BrokerDecisionKind.Unavailable ? StatusIcon.Warning : StatusIcon.None, - 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 - }; + // An SGU rejection does not create an account. Pass the unchanged + // credential to Windows so an existing AD account with the same + // name can still authenticate. A non-existent account is rejected + // by the domain controller. + return DomainCredential( + domain, + userName, + securePassword, + decision.Kind == BrokerDecisionKind.Unavailable + ? "El servicio SGU no está disponible; Windows validará la contraseña guardada en el dominio." + : null); } 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() { IsSuccess = false, diff --git a/tests/SGU.CredentialProvider.SmokeProbe/Program.cs b/tests/SGU.CredentialProvider.SmokeProbe/Program.cs index 292387e..1a59982 100644 --- a/tests/SGU.CredentialProvider.SmokeProbe/Program.cs +++ b/tests/SGU.CredentialProvider.SmokeProbe/Program.cs @@ -14,10 +14,10 @@ internal static class Program private static readonly string[] ExpectedLabels = [ - "La Salle", - "Inicio de sesión La Salle", + "Acceso Institucional", + "Acceso Institucional", "Iniciar sesión", - "Escribe tu usuario y contraseña.", + "Escribe tu usuario institucional o de dominio y contraseña.", "Usuario", "Contraseña", "Iniciar sesión" diff --git a/tests/SGU.CredentialProvider.Tests/ProviderTileIconTests.cs b/tests/SGU.CredentialProvider.Tests/ProviderTileIconTests.cs index 1004e51..a8dd5a4 100644 --- a/tests/SGU.CredentialProvider.Tests/ProviderTileIconTests.cs +++ b/tests/SGU.CredentialProvider.Tests/ProviderTileIconTests.cs @@ -55,7 +55,7 @@ public sealed class ProviderTileIconTests LargeLabelControl heading = Assert.Single(controls.OfType()); SguCredentialTile tile = Assert.IsType(provider.CreateGenericTile()); - Assert.Equal("La Salle", providerLabel.Label); + Assert.Equal("Acceso Institucional", providerLabel.Label); Assert.Equal("Iniciar sesión", heading.Label); Assert.Equal(FieldState.DisplayInSelectedTile, heading.State); Assert.Equal(GenericTileDisplayMode.DisplayAsDedicatedTile, tile.GenericTileDisplayMode);