Implement Lab 7 service security
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
install -d -o postgres -g postgres -m 0700 /tmp/db-tls
|
||||
install -o postgres -g postgres -m 0600 /run/tls/db.key /tmp/db-tls/server.key
|
||||
exec docker-entrypoint.sh "$@"
|
||||
@@ -0,0 +1,2 @@
|
||||
local all postgres peer
|
||||
hostssl messenger messenger_owner,messenger_api,messenger_worker,messenger_dispatch all scram-sha-256
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
psql --set ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" \
|
||||
--set owner_pw="$(cat /run/secrets/db_owner)" \
|
||||
--set api_pw="$(cat /run/secrets/db_api)" \
|
||||
--set worker_pw="$(cat /run/secrets/db_worker)" \
|
||||
--set dispatch_pw="$(cat /run/secrets/db_dispatch)" <<'SQL'
|
||||
SELECT 'CREATE ROLE ' || quote_ident(role.name) FROM
|
||||
(VALUES ('messenger_owner'), ('messenger_api'), ('messenger_worker'), ('messenger_dispatch')) AS role(name)
|
||||
WHERE NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname=role.name) \gexec
|
||||
ALTER ROLE messenger_owner LOGIN PASSWORD :'owner_pw';
|
||||
ALTER ROLE messenger_api LOGIN PASSWORD :'api_pw';
|
||||
ALTER ROLE messenger_worker LOGIN PASSWORD :'worker_pw';
|
||||
ALTER ROLE messenger_dispatch LOGIN PASSWORD :'dispatch_pw';
|
||||
ALTER DATABASE messenger OWNER TO messenger_owner;
|
||||
REVOKE ALL ON DATABASE messenger FROM PUBLIC;
|
||||
GRANT CONNECT ON DATABASE messenger TO messenger_api, messenger_worker, messenger_dispatch;
|
||||
ALTER SCHEMA public OWNER TO messenger_owner;
|
||||
REVOKE ALL ON SCHEMA public FROM PUBLIC;
|
||||
GRANT USAGE ON SCHEMA public TO messenger_api, messenger_worker, messenger_dispatch;
|
||||
SQL
|
||||
@@ -0,0 +1,51 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 256
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2
|
||||
ssl-default-server-options ssl-min-ver TLSv1.2
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
timeout connect 1s
|
||||
timeout client 60s
|
||||
timeout server 60s
|
||||
timeout check 3s
|
||||
retries 0
|
||||
http-error status 503 content-type application/json lf-string '{"error":{"code":"unavailable","message":"API temporarily unavailable","request_id":"%[unique-id]"}}' hdr X-Request-Id %[unique-id]
|
||||
|
||||
resolvers docker
|
||||
nameserver local 127.0.0.11:53
|
||||
resolve_retries 2
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 1s
|
||||
hold nx 1s
|
||||
hold obsolete 1s
|
||||
|
||||
frontend public
|
||||
bind :8443 ssl crt /run/tls/localhost.pem
|
||||
unique-id-format %[uuid()]
|
||||
stick-table type ip size 10k expire 1m store http_req_rate(10s)
|
||||
acl login method POST
|
||||
acl login_route path /api/v1/auth/sessions
|
||||
http-request track-sc0 src if login login_route
|
||||
http-request return status 429 content-type application/json lf-string '{"error":{"code":"rate_limited","message":"Too many login requests","request_id":"%[unique-id]"}}' hdr X-Request-Id %[unique-id] hdr X-Instance-Id ingress hdr Retry-After 10 if login login_route { sc_http_req_rate(0) gt 12 }
|
||||
use_backend api_live if { path /health/live }
|
||||
default_backend api_ready
|
||||
|
||||
backend api_ready
|
||||
balance roundrobin
|
||||
option httpchk GET /health/ready
|
||||
http-check expect status 200
|
||||
default-server inter 1s fall 2 rise 1 resolvers docker init-addr libc,none ssl verify required ca-file /run/tls/ca.crt crt /run/tls/lb-ingress.pem
|
||||
server first api1:8080 check verifyhost api1 sni str(api1) check-sni api1
|
||||
server second api2:8080 check verifyhost api2 sni str(api2) check-sni api2
|
||||
|
||||
backend api_live
|
||||
balance roundrobin
|
||||
option httpchk GET /health/live
|
||||
http-check expect status 200
|
||||
default-server inter 1s fall 2 rise 1 resolvers docker init-addr libc,none ssl verify required ca-file /run/tls/ca.crt crt /run/tls/lb-ingress.pem
|
||||
server first api1:8080 check verifyhost api1 sni str(api1) check-sni api1
|
||||
server second api2:8080 check verifyhost api2 sni str(api2) check-sni api2
|
||||
@@ -1,7 +1,5 @@
|
||||
# OpenBao — реализовать конфигурацию и политики
|
||||
# OpenBao
|
||||
|
||||
Добавьте non-dev конфигурацию listener/storage/TLS, API/worker policies, bootstrap и rotation scripts. Credentials и unseal material создаются локально; здесь нет готового root token или private key.
|
||||
`server.hcl` задаёт HTTPS и постоянное файловое хранилище. Шаблон `service-policy.hcl` разрешает каждой роли чтение её пути KV v2 и отзыв собственного токена. Cert-auth связывает роль с отдельным сертификатом сервиса.
|
||||
|
||||
Решение должно показать реальную сервисную аутентификацию и получение нужного secret по ограниченной policy; просто работающий контейнер OpenBao не засчитывается. На 3 статический KV secret допустим. На 4 покажите expiry/renewal/rotation и allow/deny. Путь KV v2 data/metadata и ACL должен соответствовать фактическому mount; не копируйте широкое `path "*"` для приложения.
|
||||
|
||||
Документируйте шаги оператора init/unseal и восстановление после restart. Скрипт не должен печатать tokens/shares или хранить их в Git. См. contracts/trust-matrix.md и REPORT.md.
|
||||
После запуска `docker compose up -d openbao` оператор выполняет `python -X utf8 scripts/bao.py configure`. После рестарта используется `python -X utf8 scripts/bao.py unseal`. Команды и хранение файла оператора описаны в [отчёте](../../REPORT.md).
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
disable_mlock = true
|
||||
ui = false
|
||||
api_addr = "https://openbao:8200"
|
||||
|
||||
storage "file" {
|
||||
path = "/openbao/file"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0:8200"
|
||||
tls_cert_file = "/run/tls/openbao.crt"
|
||||
tls_key_file = "/run/tls/openbao.key"
|
||||
tls_min_version = "tls12"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
path "messenger/data/ROLE" {
|
||||
capabilities = ["read"]
|
||||
}
|
||||
|
||||
path "auth/token/revoke-self" {
|
||||
capabilities = ["update"]
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
# Конфигурация наблюдаемости — реализовать
|
||||
# Конфигурация наблюдаемости
|
||||
|
||||
Добавьте `collector.yaml` с OTLP receivers, processors и exporters выбранной версии Collector. Укажите явные bind endpoints, внутренние сети, memory limits/batch и поведение при backpressure по уровню. Сопоставьте все три pipeline с реально развёрнутыми backend.
|
||||
`collector.yaml` принимает OTLP/HTTP от API и worker, экспортирует логи в Loki, трассы в Tempo и отдаёт метрики Prometheus. В `prometheus.yaml`, `loki.yaml` и `tempo.yaml` заданы параметры хранения.
|
||||
|
||||
Добавьте конфигурации storage, Grafana provisioning/datasources, provisioning/dashboards и импортируемые dashboard JSON. На 4 — alert rules и runbooks. Пустой dashboard или debug exporter, который только печатает данные в stdout, не заменяют хранилища/доказательства из `contracts/observability.md`.
|
||||
|
||||
Не публикуйте OTLP/metrics/административные ports в общую сеть без необходимости. В lab7 реализуйте TLS/mTLS по trust matrix; экспорт Authorization и message bodies запрещён.
|
||||
В `grafana/` находятся настройки источников и дашборд. Grafana доступна по loopback, остальные сервисы телеметрии доступны внутри Compose. Команды запуска и запросы для проверки есть в [REPORT.md](../../REPORT.md).
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
extensions:
|
||||
bearertokenauth/ingest:
|
||||
filename: /run/secrets/otel_ingest
|
||||
bearertokenauth/storage:
|
||||
filename: /run/secrets/otel_write
|
||||
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
tls:
|
||||
cert_file: /run/tls/collector.crt
|
||||
key_file: /run/tls/collector.key
|
||||
auth:
|
||||
authenticator: bearertokenauth/ingest
|
||||
|
||||
processors:
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 192
|
||||
spike_limit_mib: 48
|
||||
batch:
|
||||
timeout: 1s
|
||||
send_batch_size: 256
|
||||
send_batch_max_size: 512
|
||||
|
||||
exporters:
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:9464
|
||||
tls:
|
||||
cert_file: /run/tls/collector.crt
|
||||
key_file: /run/tls/collector.key
|
||||
metric_expiration: 5m
|
||||
resource_to_telemetry_conversion:
|
||||
enabled: true
|
||||
otlphttp/loki:
|
||||
endpoint: https://telemetry-edge:9443/otlp
|
||||
tls:
|
||||
ca_file: /run/tls/ca.crt
|
||||
auth:
|
||||
authenticator: bearertokenauth/storage
|
||||
timeout: 3s
|
||||
sending_queue:
|
||||
queue_size: 128
|
||||
retry_on_failure:
|
||||
max_elapsed_time: 30s
|
||||
otlphttp/tempo:
|
||||
endpoint: https://telemetry-edge:9444
|
||||
tls:
|
||||
ca_file: /run/tls/ca.crt
|
||||
auth:
|
||||
authenticator: bearertokenauth/storage
|
||||
timeout: 3s
|
||||
sending_queue:
|
||||
queue_size: 128
|
||||
retry_on_failure:
|
||||
max_elapsed_time: 30s
|
||||
|
||||
service:
|
||||
extensions: [bearertokenauth/ingest, bearertokenauth/storage]
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/loki]
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/tempo]
|
||||
@@ -0,0 +1,46 @@
|
||||
global
|
||||
maxconn 256
|
||||
ssl-default-bind-options ssl-min-ver TLSv1.2
|
||||
|
||||
defaults
|
||||
mode http
|
||||
timeout connect 3s
|
||||
timeout client 30s
|
||||
timeout server 30s
|
||||
default-server inter 2s
|
||||
|
||||
listen grafana
|
||||
bind :9445 ssl crt /run/tls/telemetry-edge.pem
|
||||
http-request set-header X-Forwarded-Proto https
|
||||
server grafana 127.0.0.1:3000
|
||||
|
||||
listen prometheus-query
|
||||
bind :9440 ssl crt /run/tls/telemetry-edge.pem
|
||||
http-request deny unless { req.hdr(Authorization) -m str -f /run/secrets/grafana_read_header }
|
||||
http-request deny unless { method GET } or { path /api/v1/query /api/v1/query_range }
|
||||
http-request del-header Authorization
|
||||
server prometheus 127.0.0.1:9090
|
||||
|
||||
listen loki-query
|
||||
bind :9441 ssl crt /run/tls/telemetry-edge.pem
|
||||
http-request deny unless { req.hdr(Authorization) -m str -f /run/secrets/grafana_read_header } { method GET }
|
||||
http-request del-header Authorization
|
||||
server loki 127.0.0.1:3100
|
||||
|
||||
listen tempo-query
|
||||
bind :9442 ssl crt /run/tls/telemetry-edge.pem
|
||||
http-request deny unless { req.hdr(Authorization) -m str -f /run/secrets/grafana_read_header } { method GET }
|
||||
http-request del-header Authorization
|
||||
server tempo 127.0.0.1:3200
|
||||
|
||||
listen loki-write
|
||||
bind :9443 ssl crt /run/tls/telemetry-edge.pem
|
||||
http-request deny unless { req.hdr(Authorization) -m str -f /run/secrets/otel_write_header } { method POST } { path /otlp/v1/logs }
|
||||
http-request del-header Authorization
|
||||
server loki 127.0.0.1:3100
|
||||
|
||||
listen tempo-write
|
||||
bind :9444 ssl crt /run/tls/telemetry-edge.pem
|
||||
http-request deny unless { req.hdr(Authorization) -m str -f /run/secrets/otel_write_header } { method POST } { path /v1/traces }
|
||||
http-request del-header Authorization
|
||||
server tempo 127.0.0.1:4318
|
||||
@@ -0,0 +1,182 @@
|
||||
{
|
||||
"uid": "lab-messenger",
|
||||
"title": "Мессенджер — лабораторная 7",
|
||||
"schemaVersion": 39,
|
||||
"version": 1,
|
||||
"refresh": "10s",
|
||||
"time": {
|
||||
"from": "now-15m",
|
||||
"to": "now"
|
||||
},
|
||||
"tags": [
|
||||
"mtusi"
|
||||
],
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "timeseries",
|
||||
"title": "API — запросы в секунду",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "lab-prometheus"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (http_route) (rate(messenger_http_requests_total[1m]))",
|
||||
"legendFormat": "{{http_route}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "timeseries",
|
||||
"title": "API — ответы 5xx в секунду",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "lab-prometheus"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (http_route) (rate(messenger_http_requests_total{http_status_class=\"5xx\"}[1m]))",
|
||||
"legendFormat": "{{http_route}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "timeseries",
|
||||
"title": "API — средняя длительность",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "lab-prometheus"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (http_route) (rate(messenger_http_duration_seconds_sum[1m])) / sum by (http_route) (rate(messenger_http_duration_seconds_count[1m]))",
|
||||
"legendFormat": "{{http_route}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "timeseries",
|
||||
"title": "Worker — задания по исходу",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "lab-prometheus"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (job_outcome) (messenger_job_deliveries_total)",
|
||||
"legendFormat": "{{job_outcome}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "timeseries",
|
||||
"title": "Worker — средняя длительность",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "lab-prometheus"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (job_outcome) (rate(messenger_job_duration_seconds_sum[1m])) / sum by (job_outcome) (rate(messenger_job_duration_seconds_count[1m]))",
|
||||
"legendFormat": "{{job_outcome}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"type": "logs",
|
||||
"title": "Логи API и worker",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "lab-loki"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "{service_name=~\"messenger-api|messenger-worker\"}"
|
||||
}
|
||||
],
|
||||
"options": {
|
||||
"showTime": true,
|
||||
"showLogDetails": true,
|
||||
"sortOrder": "Descending"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: Messenger
|
||||
folder: MTUSI
|
||||
type: file
|
||||
options:
|
||||
path: /etc/grafana/dashboards
|
||||
@@ -0,0 +1,37 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: lab-prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: https://telemetry-edge:9440
|
||||
isDefault: true
|
||||
jsonData:
|
||||
timeInterval: 5s
|
||||
httpHeaderName1: Authorization
|
||||
secureJsonData:
|
||||
httpHeaderValue1: $GF_LAB_QUERY
|
||||
- name: Loki
|
||||
uid: lab-loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: https://telemetry-edge:9441
|
||||
jsonData:
|
||||
httpHeaderName1: Authorization
|
||||
derivedFields:
|
||||
- name: Trace
|
||||
matcherRegex: '"trace_id":"([0-9a-f]{32})"'
|
||||
datasourceUid: lab-tempo
|
||||
url: '$${__value.raw}'
|
||||
secureJsonData:
|
||||
httpHeaderValue1: $GF_LAB_QUERY
|
||||
- name: Tempo
|
||||
uid: lab-tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: https://telemetry-edge:9442
|
||||
jsonData:
|
||||
httpHeaderName1: Authorization
|
||||
secureJsonData:
|
||||
httpHeaderValue1: $GF_LAB_QUERY
|
||||
@@ -0,0 +1,51 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_address: 127.0.0.1
|
||||
http_listen_port: 3100
|
||||
grpc_listen_address: 127.0.0.1
|
||||
grpc_listen_port: 9096
|
||||
|
||||
common:
|
||||
instance_addr: 127.0.0.1
|
||||
path_prefix: /loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /loki/chunks
|
||||
rules_directory: /loki/rules
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
replication_factor: 1
|
||||
|
||||
ingester:
|
||||
wal:
|
||||
dir: /loki/wal
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2024-01-01
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: lab_index_
|
||||
period: 24h
|
||||
|
||||
compactor:
|
||||
working_directory: /loki/compactor
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
|
||||
limits_config:
|
||||
allow_structured_metadata: true
|
||||
retention_period: 72h
|
||||
otlp_config:
|
||||
resource_attributes:
|
||||
ignore_defaults: true
|
||||
attributes_config:
|
||||
- action: index_label
|
||||
attributes: [service.name, deployment.environment.name]
|
||||
|
||||
analytics:
|
||||
reporting_enabled: false
|
||||
@@ -0,0 +1,13 @@
|
||||
global:
|
||||
scrape_interval: 5s
|
||||
evaluation_interval: 5s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: otel-collector
|
||||
honor_labels: true
|
||||
scheme: https
|
||||
tls_config:
|
||||
ca_file: /run/tls/ca.crt
|
||||
server_name: otel-collector
|
||||
static_configs:
|
||||
- targets: ["otel-collector:9464"]
|
||||
@@ -0,0 +1,26 @@
|
||||
server:
|
||||
http_listen_address: 127.0.0.1
|
||||
http_listen_port: 3200
|
||||
grpc_listen_address: 127.0.0.1
|
||||
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 127.0.0.1:4318
|
||||
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
local:
|
||||
path: /var/tempo/blocks
|
||||
wal:
|
||||
path: /var/tempo/wal
|
||||
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 72h
|
||||
|
||||
usage_report:
|
||||
reporting_enabled: false
|
||||
@@ -0,0 +1,8 @@
|
||||
listeners.tcp = none
|
||||
listeners.ssl.default = 5671
|
||||
ssl_options.certfile = /run/tls/broker.crt
|
||||
ssl_options.keyfile = /run/tls/broker.key
|
||||
ssl_options.cacertfile = /run/tls/ca.crt
|
||||
ssl_options.verify = verify_none
|
||||
definitions.import_backend = local_filesystem
|
||||
definitions.local.path = /run/secrets/rabbit_definitions.json
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
mkdir -p /tmp/mc/certs/CAs
|
||||
cp /run/tls/ca.crt /tmp/mc/certs/CAs/lab.crt
|
||||
export MC_CONFIG_DIR=/tmp/mc
|
||||
attempt=0
|
||||
until mc alias set store https://s3:9000 "$(cat /run/secrets/minio_root_user)" "$(cat /run/secrets/minio_root_password)" >/dev/null 2>&1; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -ge 60 ]; then
|
||||
echo "MinIO unavailable over trusted HTTPS" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
mc mb --ignore-existing store/messenger-attachments >/dev/null
|
||||
printf messenger-ready | mc pipe store/messenger-attachments/system/readiness >/dev/null
|
||||
for role in api worker; do
|
||||
mc admin user add store "lab7-$role" "$(cat "/run/secrets/s3_$role")" >/dev/null
|
||||
mc admin policy create store "lab7-$role" "/policies/$role.json" >/dev/null
|
||||
if ! mc admin user info --json store "lab7-$role" | grep -q "\"policyName\":\"lab7-$role\""; then
|
||||
mc admin policy attach store "lab7-$role" --user "lab7-$role" >/dev/null
|
||||
fi
|
||||
done
|
||||
echo "MinIO bucket and two scoped policies are ready."
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{"Effect": "Allow", "Action": "s3:GetObject",
|
||||
"Resource": ["arn:aws:s3:::messenger-attachments/system/readiness", "arn:aws:s3:::messenger-attachments/originals/*"]},
|
||||
{"Effect": "Allow", "Action": "s3:PutObject", "Resource": "arn:aws:s3:::messenger-attachments/staging/*"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{"Effect": "Allow", "Action": ["s3:GetObject", "s3:DeleteObject"], "Resource": "arn:aws:s3:::messenger-attachments/staging/*"},
|
||||
{"Effect": "Allow", "Action": ["s3:GetObject", "s3:PutObject"], "Resource": "arn:aws:s3:::messenger-attachments/originals/*"}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user