Skip to content

Commit abd014a

Browse files
committed
catch exceptions for test-cippaccess and return unauthorized
1 parent 7107bb6 commit abd014a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Modules/CippEntrypoints/CippEntrypoints.psm1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,16 @@ function Receive-CippHttpTrigger {
5353
if ($FunctionName -eq 'Invoke-Me') {
5454
return
5555
}
56-
56+
} catch {
57+
Write-Information "Access denied for $FunctionName : $($_.Exception.Message)"
58+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
59+
StatusCode = [HttpStatusCode]::Forbidden
60+
Body = $_.Exception.Message
61+
})
62+
return
63+
}
64+
65+
try {
5766
Write-Information "Access: $Access"
5867
if ($Access) {
5968
& $FunctionName @HttpTrigger

0 commit comments

Comments
 (0)