forked from baron/baron-sso
adminfront 개요 통계 추가
This commit is contained in:
@@ -58,3 +58,66 @@ if (( after_rows <= before_rows )); then
|
||||
docker logs --tail 100 ory_vector >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
before_auth_ts="$(docker exec ory_clickhouse clickhouse-client --user "${ORY_CLICKHOUSE_USER:-ory}" --password "${ORY_CLICKHOUSE_PASSWORD:-orypass}" --query "SELECT now64(3)")"
|
||||
auth_status="$(docker run --rm --network public_net curlimages/curl:8.10.1 \
|
||||
-sS -o /dev/null -w '%{http_code}' \
|
||||
'http://ory_oathkeeper:4455/oauth2/auth?client_id=orgfront&redirect_uri=http%3A%2F%2Flocalhost%3A5175%2Fauth%2Fcallback&response_type=code&scope=openid&state=access-log-e2e&code_challenge=accessloge2e&code_challenge_method=S256')"
|
||||
|
||||
if [[ "$auth_status" != "302" ]]; then
|
||||
echo "ERROR: expected Oathkeeper OIDC auth request to return 302, got: $auth_status" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
deadline=$((SECONDS + 30))
|
||||
completed_rows=0
|
||||
granted_rows=0
|
||||
while (( SECONDS < deadline )); do
|
||||
completed_rows="$(docker exec ory_clickhouse clickhouse-client --user "${ORY_CLICKHOUSE_USER:-ory}" --password "${ORY_CLICKHOUSE_PASSWORD:-orypass}" --query "
|
||||
SELECT count()
|
||||
FROM ory.oathkeeper_access_logs
|
||||
WHERE timestamp >= toDateTime64('$before_auth_ts', 3)
|
||||
AND method = 'GET'
|
||||
AND path = '/oauth2/auth'
|
||||
AND status = 302
|
||||
")"
|
||||
granted_rows="$(docker exec ory_clickhouse clickhouse-client --user "${ORY_CLICKHOUSE_USER:-ory}" --password "${ORY_CLICKHOUSE_PASSWORD:-orypass}" --query "
|
||||
SELECT count()
|
||||
FROM ory.oathkeeper_access_logs
|
||||
WHERE timestamp >= toDateTime64('$before_auth_ts', 3)
|
||||
AND method = 'GET'
|
||||
AND path = '/oauth2/auth'
|
||||
AND client_id = 'orgfront'
|
||||
AND decision = 'granted'
|
||||
")"
|
||||
if (( completed_rows > 0 && granted_rows > 0 )); then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if (( completed_rows <= 0 )); then
|
||||
echo "ERROR: Oathkeeper completed request log did not preserve method/path/status." >&2
|
||||
docker exec ory_clickhouse clickhouse-client --user "${ORY_CLICKHOUSE_USER:-ory}" --password "${ORY_CLICKHOUSE_PASSWORD:-orypass}" --query "
|
||||
SELECT timestamp, method, path, status, client_id, decision
|
||||
FROM ory.oathkeeper_access_logs
|
||||
WHERE timestamp >= toDateTime64('$before_auth_ts', 3)
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT 20
|
||||
FORMAT Vertical
|
||||
" >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if (( granted_rows <= 0 )); then
|
||||
echo "ERROR: Oathkeeper granted request log did not preserve client_id." >&2
|
||||
docker exec ory_clickhouse clickhouse-client --user "${ORY_CLICKHOUSE_USER:-ory}" --password "${ORY_CLICKHOUSE_PASSWORD:-orypass}" --query "
|
||||
SELECT timestamp, method, path, status, client_id, decision
|
||||
FROM ory.oathkeeper_access_logs
|
||||
WHERE timestamp >= toDateTime64('$before_auth_ts', 3)
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT 20
|
||||
FORMAT Vertical
|
||||
" >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user