Files
aza/AzA march 2026 - Kopie/deploy/openapi_auth_inspect.ps1
2026-03-30 07:59:11 +02:00

100 lines
2.3 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<#
AZA Diagnose: Inspect OpenAPI for /license/status auth expectations
Run (with server running):
cd "C:\Users\surov\Documents\AZA\backup 24.2.26"
powershell -ExecutionPolicy Bypass -File .\deploy\openapi_auth_inspect.ps1
#>
[CmdletBinding()]
param(
[string]$BaseUrl = "http://127.0.0.1:8000"
)
function SafeJson($obj) {
try { return ($obj | ConvertTo-Json -Depth 20 -Compress) } catch { return "" }
}
$base = $BaseUrl.TrimEnd("/")
$url = "$base/openapi.json"
Write-Host "[AZA] OpenAPI auth inspect"
Write-Host (" BaseUrl: " + $base)
Write-Host ""
try {
$api = Invoke-RestMethod -Method GET -Uri $url -TimeoutSec 15
} catch {
Write-Host "ERROR: cannot fetch /openapi.json"
Write-Host $_.Exception.Message
exit 1
}
# 1) Components securitySchemes
Write-Host "components.securitySchemes:"
try {
$schemes = $api.components.securitySchemes
if (-not $schemes) {
Write-Host " (none)"
} else {
foreach ($p in $schemes.PSObject.Properties) {
$name = $p.Name
$val = $p.Value
$type = $val.type
$inLoc = $val.in
$paramName = $val.name
Write-Host (" - " + $name + ": type=" + $type + " in=" + $inLoc + " name=" + $paramName)
}
}
} catch {
Write-Host " (failed to read)"
}
Write-Host ""
# 2) Global security
Write-Host "top-level security:"
try {
if ($api.security) { Write-Host (" " + (SafeJson $api.security)) } else { Write-Host " (none)" }
} catch { Write-Host " (failed to read)" }
Write-Host ""
# 3) /license/status GET details
$path = "/license/status"
Write-Host ("path: " + $path)
try {
$item = $api.paths.$path
if (-not $item) {
Write-Host " (path not present in openapi.json)"
exit 0
}
$get = $item.get
if (-not $get) {
Write-Host " (GET not present for this path)"
exit 0
}
Write-Host " operationId:"
Write-Host (" " + $get.operationId)
Write-Host " security:"
if ($get.security) { Write-Host (" " + (SafeJson $get.security)) } else { Write-Host " (none)" }
Write-Host " parameters:"
if ($get.parameters) {
foreach ($par in $get.parameters) {
$pname = $par.name
$pin = $par.in
$preq = $par.required
Write-Host (" - " + $pname + " in=" + $pin + " required=" + $preq)
}
} else {
Write-Host " (none)"
}
} catch {
Write-Host " (failed to read path details)"
}
Write-Host ""
Write-Host "Done."