Initial commit
This commit is contained in:
99
backup 24.2.26 - Kopie (61)/deploy/openapi_auth_inspect.ps1
Normal file
99
backup 24.2.26 - Kopie (61)/deploy/openapi_auth_inspect.ps1
Normal file
@@ -0,0 +1,99 @@
|
||||
<#
|
||||
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."
|
||||
|
||||
Reference in New Issue
Block a user