You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add-PodeRoute-Method Get -Path '/authtest'-Authentication 'Login'-ScriptBlock {
Write-PodeJsonResponse-Value $WebEvent.Session.Data
} -PassThru |Set-PodeOARouteInfo-Summary 'Testing response from service (authtest)'
Launch the server and send a request to /authtest and authenticate
Review the server console logs
Notice the User attribute is always -
Expected Behavior
The User attribute picks up the username of the logged-in user (if it exists). Additionally, provide an option to customize the User attribute if possible.
Screenshots
Example request log entry:
[{"Host":"127.0.0.1","Request":{"Referrer":"","Method":"GET","Protocol":"HTTP/1.1","Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203","Resource":"/authtest"},"RfcUserIdentity":"-","Date":"23-Aug.-2023:14:43:34 -04:00","User":"-","Response":{"StatusCode":200,"StatusDescription":"OK","Size":875}}]
Platform
OS: Linux/Windows
Browser: Chrome
Versions:
Pode: Pode v2.8.0
PowerShell: 7.3.6
Additional Context
Attempts to customize the logging method using $WebEvent.Session.Data did not work and led to a null value for User.
$method=New-PodeLoggingMethod-Custom -Batch 10-BatchTimeout 5-ScriptBlock {
param($item)
$item|ForEach-Object {
$itemInstance=$_$itemInstance.Keys|ForEach-Object {
if ("$_"-eq"User") {
if ([string]::IsNotNullOrEmpty($WebEvent.Session.Data.id_token.preferred_username)) {
Write-Host"Setting `"User`" to `"$($WebEvent.Session.Data.id_token.preferred_username)`" ..."$itemInstance["User"] =$WebEvent.Session.Data.id_token.preferred_username
}
else {
Write-Host"`"`$WebEvent.Session.Data.id_token.preferred_username`" is null."
}
}
}
}
$logValue=ConvertTo-Json-InputObject $item-Depth 25-Compress
$logValue=Protect-PodeLogItem-Item $logValue$logValue|Out-Default
}
$method|Enable-PodeRequestLogging-Raw
$method|Enable-PodeErrorLogging-Raw
The text was updated successfully, but these errors were encountered:
Describe the Bug
The
User
attribute does not pick up the logged-in user's username and is always-
in request logging. Relevant snippet:Pode/src/Private/Logging.ps1
Lines 274 to 292 in 60de12e
Steps to Reproduce
Steps to reproduce the behavior:
/authtest
and authenticateUser
attribute is always-
Expected Behavior
The
User
attribute picks up the username of the logged-in user (if it exists). Additionally, provide an option to customize theUser
attribute if possible.Screenshots
Example request log entry:
Platform
Additional Context
Attempts to customize the logging method using
$WebEvent.Session.Data
did not work and led to anull
value forUser
.The text was updated successfully, but these errors were encountered: