feat(lab7): implement secure messenger infrastructure with TLS, OpenBao and observability

This commit is contained in:
2026-11-29 18:06:02 +03:00
parent 20afc2c790
commit c188a3beca
121 changed files with 10090 additions and 68 deletions
+3
View File
@@ -0,0 +1,3 @@
baseline: memory=19456 KiB, t=2, p=1, median=13.21 ms, min=12.66 ms, max=14.40 ms
stronger: memory=32768 KiB, t=3, p=1, median=46.17 ms, min=45.01 ms, max=63.33 ms
high-memory: memory=65536 KiB, t=3, p=1, median=101.44 ms, min=97.04 ms, max=107.90 ms
+2
View File
@@ -0,0 +1,2 @@
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+4
View File
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "https://localhost:8443" --ca-file "/home/user/.local/share/mtusi2026lab7/pki/ca.crt"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 72, "failed_attempts": 3, "first_recovery_seconds": 1.119}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+3
View File
@@ -0,0 +1,3 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "https://localhost:8443" --ca-file "/home/user/.local/share/mtusi2026lab7/pki/ca.crt"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
+2
View File
@@ -0,0 +1,2 @@
python3 tests/security.py --base-url "https://localhost:8443" --ca-file "/home/user/.local/share/mtusi2026lab7/pki/ca.crt"
PASS: trusted HTTPS works; untrusted CA rejected. This does NOT verify internal mTLS, OpenBao or hardening.
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "https://localhost:8443" --ca-file "/home/user/.local/share/mtusi2026lab7/pki/ca.crt"
PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.
+1
View File
@@ -0,0 +1 @@
PASS: trusted HTTPS works; untrusted CA rejected. This does NOT verify internal mTLS, OpenBao or hardening.
+1
View File
@@ -0,0 +1 @@
PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.
+8
View File
@@ -0,0 +1,8 @@
PASS: Trusted CA and correct hostname
curl exit code: 0
HTTP status: 200
PASS: Untrusted CA
curl exit code: 60
PASS: Wrong hostname
curl exit code: 60
PASS: HTTPS certificate verification
+8
View File
@@ -0,0 +1,8 @@
Testing rate limit with username: rl_2d31d8ed431a4b75
Attempt 1: HTTP 401, Retry-After=None
Attempt 2: HTTP 401, Retry-After=None
Attempt 3: HTTP 401, Retry-After=None
Attempt 4: HTTP 401, Retry-After=None
Attempt 5: HTTP 401, Retry-After=None
Attempt 6: HTTP 429, Retry-After=60
PASS: shared login rate limit and Retry-After
+24
View File
@@ -0,0 +1,24 @@
=== Testing api1 mTLS ===
[1] Authorized LB certificate
{"status":"ok"}
[2] No client certificate
PASS: no certificate rejected
[3] Untrusted CA certificate
PASS: rogue CA rejected
[4] Trusted CA, forbidden SAN
HTTP 403
PASS: api1 mTLS identity enforcement
=== Testing api2 mTLS ===
[1] Authorized LB certificate
{"status":"ok"}
[2] No client certificate
PASS: no certificate rejected
[3] Untrusted CA certificate
PASS: rogue CA rejected
[4] Trusted CA, forbidden SAN
HTTP 403
PASS: api2 mTLS identity enforcement
PASS: all mTLS tests passed
+12
View File
@@ -0,0 +1,12 @@
INFO: active token accessors: 1
INFO: root tokens: 1
INFO: certificate-auth tokens: 0
INFO: other tokens: 0
INFO: certificate tokens with API policy: 0
INFO: certificate tokens with worker policy: 0
INFO: certificate tokens older than 3600 seconds: 0
INFO: certificate tokens with nonpositive TTL: 0
INFO: tokens expired during audit: 0
INFO: lookup errors: 0
PASS: token accessor inventory completed
PASS: no certificate-auth tokens older than 3600 seconds found
+2
View File
@@ -0,0 +1,2 @@
PASS: runtime credentials loaded from OpenBao
PASS: rotated API1 certificate authenticated
@@ -0,0 +1,5 @@
PASS: Replacement identity configured
PASS: Replacement certificate configured
PASS: Replacement key configured
PASS: Certificate mounted read-only
PASS: Key mounted read-only
+2
View File
@@ -0,0 +1,2 @@
PASS: runtime credentials loaded from OpenBao
PASS: rotated API2 certificate authenticated
@@ -0,0 +1,7 @@
PASS: Replacement API2 identity configured
PASS: Replacement certificate configured
PASS: Replacement private key configured
PASS: Certificate mounted read-only
PASS: Private key mounted read-only
PASS: API1 rotated identity preserved
PASS: Worker identity unchanged
+17
View File
@@ -0,0 +1,17 @@
OpenBao HTTPS: https://localhost:8200/v1
TLS verification: enabled
PASS: temporary KV v2 secrets prepared
PASS: api: scoped token issued with limited TTL
PASS: api: SecretID reuse denied
PASS: worker: scoped token issued with limited TTL
PASS: worker: SecretID reuse denied
PASS: api: own secret read allowed
PASS: worker: own secret read allowed
PASS: API cannot read worker secrets
PASS: worker cannot read API secrets
PASS: api: secret modification denied
PASS: worker: secret modification denied
PASS: api: policy administration denied
PASS: worker: policy administration denied
PASS: all OpenBao AppRole ACL tests passed
OpenBao test cleanup attempted
+24
View File
@@ -0,0 +1,24 @@
=== api1 ===
PASS: certificate authentication successful
PASS: only scoped service policy assigned
PASS: own KV v2 secret readable
PASS: cross-service KV read denied
PASS: KV modification denied
PASS: temporary token revoked
=== api2 ===
PASS: certificate authentication successful
PASS: only scoped service policy assigned
PASS: own KV v2 secret readable
PASS: cross-service KV read denied
PASS: KV modification denied
PASS: temporary token revoked
=== worker ===
PASS: certificate authentication successful
PASS: only scoped service policy assigned
PASS: own KV v2 secret readable
PASS: cross-service KV read denied
PASS: KV modification denied
PASS: temporary token revoked
PASS: three certificate identities verified
PASS: scoped OpenBao certificate ACL tests completed
PASS: no secret values or tokens printed
+17
View File
@@ -0,0 +1,17 @@
=== api1 ===
PASS: certificate authentication and KV retrieval
PASS: expected number of secret fields received
PASS: no secret values printed
PASS: api1 certificate bootstrap verified
=== api2 ===
PASS: certificate authentication and KV retrieval
PASS: expected number of secret fields received
PASS: no secret values printed
PASS: api2 certificate bootstrap verified
=== worker ===
PASS: certificate authentication and KV retrieval
PASS: expected number of secret fields received
PASS: no secret values printed
PASS: worker certificate bootstrap verified
PASS: three certificate bootstrap tests completed
PASS: running application containers unchanged
@@ -0,0 +1,15 @@
=== api1 ===
PASS: runtime credentials loaded from OpenBao
PASS: child process received runtime credentials
PASS: api1 certificate entrypoint verified
=== api2 ===
PASS: runtime credentials loaded from OpenBao
PASS: child process received runtime credentials
PASS: api2 certificate entrypoint verified
=== worker ===
PASS: runtime credentials loaded from OpenBao
PASS: child process received runtime credentials
PASS: worker certificate entrypoint verified
PASS: three certificate entrypoint tests completed
PASS: running containers unchanged
PASS: no secret values or tokens printed
+5
View File
@@ -0,0 +1,5 @@
PASS: api1 cannot authenticate as lab7-worker
PASS: api2 cannot authenticate as lab7-api1
PASS: worker cannot authenticate as lab7-api2
PASS: all certificate identity substitutions rejected
PASS: no credentials or tokens printed
@@ -0,0 +1,6 @@
PASS: All replacement identities registered
PASS: Old identities absent
PASS: No unexpected certificate identities
INFO: registered identity: lab7-api1-next
INFO: registered identity: lab7-api2-next
INFO: registered identity: lab7-worker-next
@@ -0,0 +1,23 @@
=== api1 ===
PASS: AppRole authentication completed
PASS: runtime secrets match service credentials
PASS: scoped KV v2 secret loaded
PASS: no secret values printed
PASS: api1 bootstrap verified
PASS: consumed SecretID already absent
=== api2 ===
PASS: AppRole authentication completed
PASS: runtime secrets match service credentials
PASS: scoped KV v2 secret loaded
PASS: no secret values printed
PASS: api2 bootstrap verified
PASS: consumed SecretID already absent
=== worker ===
PASS: AppRole authentication completed
PASS: runtime secrets match service credentials
PASS: scoped KV v2 secret loaded
PASS: no secret values printed
PASS: worker bootstrap verified
PASS: consumed SecretID already absent
PASS: three independent bootstrap tests completed
PASS: temporary credential files removed
@@ -0,0 +1,6 @@
PASS: temporary api2 SecretID issued
PASS: runtime credentials loaded from OpenBao
PASS: child process received OpenBao secrets
PASS: api2 OpenBao entrypoint verified
PASS: consumed SecretID already absent
PASS: temporary bootstrap files removed
+6
View File
@@ -0,0 +1,6 @@
PASS: temporary API1 SecretID issued
PASS: runtime credentials loaded from OpenBao
PASS: child process received OpenBao secrets
PASS: API1 OpenBao entrypoint verified
PASS: consumed SecretID already absent
PASS: temporary bootstrap files removed
@@ -0,0 +1,6 @@
PASS: temporary worker SecretID issued
PASS: runtime credentials loaded from OpenBao
PASS: child process received OpenBao secrets
PASS: worker OpenBao entrypoint verified
PASS: consumed SecretID already absent
PASS: temporary bootstrap files removed
+16
View File
@@ -0,0 +1,16 @@
PASS: openbao-api1-rotation-config.txt
PASS: openbao-api1-rotation-auth.txt
PASS: openbao-api2-rotation-config.txt
PASS: openbao-api2-rotation-auth.txt
PASS: openbao-worker-rotation-config.txt
PASS: openbao-worker-rotation-auth.txt
PASS: openbao-certificate-identity-audit.txt
PASS: openbao-old-certificates-rejection.txt
PASS: openbao-retired-certificates-inventory.txt
PASS: openbao-final-rotation-audit.txt
PASS: openbao-token-lifecycle-audit.txt
PASS: openbao-token-revocation-test.txt
PASS: openbao-active-token-audit.txt
PASS: openbao-operator-security-audit.txt
PASS: https-smoke-tests.txt
PASS: OpenBao evidence inventory complete
+24
View File
@@ -0,0 +1,24 @@
PASS: api1: old files removed
PASS: api1: replacement files preserved
PASS: api1: replacement key permissions 600
PASS: api1: replacement identity configured
PASS: api1: replacement files mounted read-only
PASS: api1: running identity correct
PASS: api1: running certificate mounts correct
PASS: api2: old files removed
PASS: api2: replacement files preserved
PASS: api2: replacement key permissions 600
PASS: api2: replacement identity configured
PASS: api2: replacement files mounted read-only
PASS: api2: running identity correct
PASS: api2: running certificate mounts correct
PASS: worker: old files removed
PASS: worker: replacement files preserved
PASS: worker: replacement key permissions 600
PASS: worker: replacement identity configured
PASS: worker: replacement files mounted read-only
PASS: worker: running identity correct
PASS: worker: running certificate mounts correct
PASS: OpenBao contains exactly three replacement identities
PASS: No old certificate identities registered
PASS: final certificate rotation audit
@@ -0,0 +1,4 @@
PASS: old api1 certificate rejected without role name (HTTP 400)
PASS: old api2 certificate rejected without role name (HTTP 400)
PASS: old worker certificate rejected without role name (HTTP 400)
PASS: all old certificates rejected
@@ -0,0 +1,5 @@
PASS: Operator directory exists
PASS: Initialization file exists
PASS: Initialization file is not a symlink
PASS: Operator directory permissions 700
PASS: Initialization file permissions 600
@@ -0,0 +1,15 @@
PASS: api1: Old certificate exists
PASS: api1: Old private key exists
PASS: api1: Replacement certificate exists
PASS: api1: Old key permissions 600
PASS: api1: Old and new certificates differ
PASS: api2: Old certificate exists
PASS: api2: Old private key exists
PASS: api2: Replacement certificate exists
PASS: api2: Old key permissions 600
PASS: api2: Old and new certificates differ
PASS: worker: Old certificate exists
PASS: worker: Old private key exists
PASS: worker: Replacement certificate exists
PASS: worker: Old key permissions 600
PASS: worker: Old and new certificates differ
+17
View File
@@ -0,0 +1,17 @@
OpenBao endpoint: https://localhost:8200/v1
TLS verification: enabled
PASS: API replicas use matching credentials
PASS: api: correct scoped policy
PASS: api: limited token TTL
PASS: worker: correct scoped policy
PASS: worker: limited token TTL
PASS: api: runtime secrets match Compose
PASS: worker: runtime secrets match Compose
PASS: API cannot read worker runtime secrets (HTTP 403)
PASS: Worker cannot read API runtime secrets (HTTP 403)
PASS: API cannot read policy configuration (HTTP 403)
PASS: Worker cannot read policy configuration (HTTP 403)
PASS: all OpenBao runtime access tests passed
PASS: no credential values printed
PASS: temporary service token revoked
PASS: temporary service token revoked
@@ -0,0 +1,13 @@
PASS: lab7-api1-next: Expected policy only
PASS: lab7-api1-next: Token TTL is 1200 seconds
PASS: lab7-api1-next: Token max TTL is 3600 seconds
PASS: lab7-api1-next: Default policy disabled
PASS: lab7-api2-next: Expected policy only
PASS: lab7-api2-next: Token TTL is 1200 seconds
PASS: lab7-api2-next: Token max TTL is 3600 seconds
PASS: lab7-api2-next: Default policy disabled
PASS: lab7-worker-next: Expected policy only
PASS: lab7-worker-next: Token TTL is 1200 seconds
PASS: lab7-worker-next: Token max TTL is 3600 seconds
PASS: lab7-worker-next: Default policy disabled
PASS: token lifecycle configuration audit
@@ -0,0 +1,12 @@
PASS: New worker certificate authenticated
PASS: Correct worker policy
PASS: Issued TTL within 1200 seconds
PASS: Administrative token lookup succeeded
PASS: Actual TTL within 1200 seconds
PASS: Token has no root policy
PASS: Worker secret readable
PASS: API secret forbidden
PASS: Worker token cannot perform lookup-self
PASS: Token revoke-self succeeded
PASS: Revoked token no longer exists
PASS: token lifecycle and revocation test
@@ -0,0 +1,2 @@
PASS: runtime credentials loaded from OpenBao
PASS: rotated worker certificate authenticated
@@ -0,0 +1,7 @@
PASS: Replacement worker identity configured
PASS: Replacement worker certificate configured
PASS: Replacement worker private key configured
PASS: Certificate mounted read-only
PASS: Private key mounted read-only
PASS: API1 rotated identity preserved
PASS: API2 rotated identity preserved
+53
View File
@@ -0,0 +1,53 @@
================================
Testing service: api1
================================
PostgreSQL role: messenger_api
TLS encrypted: True
TLS version: TLSv1.3
PASS: allowed - read users
PASS: allowed - read sessions
PASS: allowed - read jobs
PASS: denied - read migration history
PASS: denied - create tables
PASS: all ACL tests for messenger_api
================================
Testing service: api2
================================
PostgreSQL role: messenger_api
TLS encrypted: True
TLS version: TLSv1.3
PASS: allowed - read users
PASS: allowed - read sessions
PASS: allowed - read jobs
PASS: denied - read migration history
PASS: denied - create tables
PASS: all ACL tests for messenger_api
================================
Testing service: worker
================================
PostgreSQL role: messenger_worker
TLS encrypted: True
TLS version: TLSv1.3
PASS: allowed - read jobs
PASS: allowed - read attachments
PASS: allowed - read variants
PASS: denied - read users
PASS: denied - read sessions
PASS: denied - read messages
PASS: all ACL tests for messenger_worker
================================
Testing service: dispatcher
================================
PostgreSQL role: messenger_dispatcher
TLS encrypted: True
TLS version: TLSv1.3
PASS: allowed - read jobs
PASS: denied - read users
PASS: denied - read sessions
PASS: denied - read messages
PASS: denied - read attachments
PASS: all ACL tests for messenger_dispatcher
+3
View File
@@ -0,0 +1,3 @@
on
TLSv1.2
/etc/postgresql/pg_hba.conf
+11
View File
@@ -0,0 +1,11 @@
=== Publisher ACL ===
RabbitMQ role: messenger_publisher
TLS connection: authenticated
PASS: publisher cannot consume image_jobs
PASS: RabbitMQ ACL tests for messenger_publisher
=== Consumer ACL ===
RabbitMQ role: messenger_consumer
TLS connection: authenticated
PASS: consumer cannot publish
PASS: RabbitMQ ACL tests for messenger_consumer
+21
View File
@@ -0,0 +1,21 @@
RustFS endpoint: https://minio:9000
Bucket: messenger-attachments
TLS verification: enabled
PASS: temporary test objects prepared
PASS: API can upload staging
PASS: API can read original
PASS: API can read thumbnail
PASS: API can delete staging
PASS: worker can read staging
PASS: worker can write original
PASS: worker can write thumbnail
PASS: API staging read denied
PASS: API original write denied
PASS: API thumbnail write denied
PASS: API original delete denied
PASS: worker original read denied
PASS: worker thumbnail read denied
PASS: worker staging write denied
PASS: worker staging delete denied
PASS: all RustFS IAM ACL tests passed
RustFS ACL test cleanup attempted