ironmansoftware / powershell-universal

Issue tracker for PowerShell Universal
https://powershelluniversal.com
35 stars 2 forks source link

Hang when logging in using forms authentication #795

Closed adamdriscoll closed 2 years ago

adamdriscoll commented 2 years ago

Steps to Reproduce

Original: https://github.com/ironmansoftware/issues/issues/773#issuecomment-996817614

Set-PSUAuthenticationMethod -ScriptBlock {
param(
[PSCredential]$Credential
)

$Result = [Security.AuthenticationResult]::new()

$CurrentDomain = "LDAP://DC=xxx,DC=xxxx"
$domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain, ($Credential.UserName), $Credential.GetNetworkCredential().password)

if ($domain.name -eq $null) {
    write-host "Authentication failed - please verify your username and password."
    $Result.UserName = ($Credential.UserName)
    $Result.Success = $false 
}
else {
    write-host "Successfully authenticated with domain $($domain.name)"
    $Result.UserName = ($Credential.UserName)
    $winident = [System.Security.Principal.WindowsIdentity]::new($domain.UserName)
    if ($winident.HasClaim("http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid", 'xxxxx')) {
        $Result.Success = $true

    }
    else {
        $Result.Success = $false
    }

}

$Result
}

This error is present in the log.

2021-12-17 16:53:29.136 +01:00 [ERR] Error in job thread
System.ObjectDisposedException: Cannot access a disposed object.
at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
at LiteDB.Engine.LockService.EnterTransaction()
at LiteDB.Engine.TransactionMonitor.GetTransaction(Boolean create, Boolean queryOnly, Boolean& isNew)
at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan)
at LiteDB.Engine.LiteEngine.Query(String collection, Query query)
at LiteDB.LiteQueryable1.ToDocuments()+MoveNext() at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found) at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source)
at UniversalAutomation.ExecutionService.<>c__DisplayClass19_0.<b__4>d.MoveNext() in D:\a\universal\universal\src\Universal.Server\Services\Automation\ExecutionService.cs:line 595

Expected behavior

Forms authentication logs in properly

Actual behavior

Forms authentication hangs and never logs in.

Environment data

PSU 2.6.2

PSU 2.6.1 and 2.5.5 do not exhibit this behavior.

Visuals

No response

rstolpe commented 2 years ago

@adamdriscoll any ide what's the issue are?

adamdriscoll commented 2 years ago

No. Not yet. I haven't been able to reproduce this issue.

rstolpe commented 2 years ago

@adamdriscoll So I did download the latest nightly build that was released today and now it works again.

adamdriscoll commented 2 years ago

Hmmm. Very strange. Nothing new was changed yesterday. Bugs like this worry me.

adamdriscoll commented 2 years ago

I'm closing this for now since it seems resolved on your end and I can't reproduce this on my end.