Прямой ответ
Database security — защита баз данных от несанкционированного доступа и угроз (security — «безопасность БД» — security — incident — «защита данных» — security), зачем: защита от утечек данных (security — «данные могут быть украдены» — security — incident — «утечки» — security — postgres — «защита» — security); ключевые аспекты безопасности (security — «аспекты» — security): (1) Аутентификация (security — «проверка подлинности» — security — incident — «кто вы» — security — postgres — пароли (security — «пароли/сертификаты» — security — postgres — pg_hba.conf (security — «аутентификация» — security); (2) Авторизация (security — «права доступа» — security — incident — «что можно» — security — postgres — роли (security — «роли/привилегии» — security — postgres — GRANT/REVOKE (security — «авторизация» — security); (3) Шифрование (security — «шифрование данных» — security — incident — «данные зашифрованы» — security — postgres — TLS (security — «TLS/SSL» — security — postgres — ssl=on (security — «шифрование» — security); (4) Аудит (security — «журналирование доступа» — security — incident — «кто что сделал» — security — postgres — логи (security — «логи доступа» — security — postgres — log_connections (security — «аудит» — security); (5) Резервное копирование (security — «бэкапы» — security — incident — «восстановление» — security — postgres — бэкапы (security — «резервные копии» — security — postgres — backup — «бэкапы» — security); инструменты (security): (1) pg_hba.conf (security — «конфигурация аутентификации» — security — incident — «аутентификация» — security — postgres — pg_hba.conf (security — «аутентификация» — security — postgres — «конфигурация» — security); (2) GRANT/REVOKE (security — «управление правами» — security — incident — «права» — security — postgres — GRANT SELECT ON table TO user (security — «авторизация» — security); (3) TLS/SSL (security — «шифрование соединений» — security — incident — «TLS» — security — postgres — ssl=on (security — «шифрование» — security); когда обеспечивать безопасность (security): всегда (security — «постоянно» — security — incident — «24/7» — security — postgres), продакшн (security — «продакшн БД» — security — incident — «продакшн» — security — postgres), чувствительные данные (security — «персональные данные» — security — incident — «чувствительные» — security — postgres); антипаттерны: без аутентификации (security — «без паролей» — security — incident — «все могут подключиться» — security — postgres — «аутентификация обязательна» — security), без шифрования (security — «без TLS» — security — incident — «данные открыты» — security — postgres — «шифрование обязательно» — security).
Практика: настройка безопасности PostgreSQL
Аутентификация (security — pg_hba.conf: host all all 127.0.0.1/32 md5 host all all 0.0.0.0/0 reject (security — «аутентификация по паролю» — security — postgres — «аутентификация» — security — postgres); Авторизация (security — CREATE ROLE app_user WITH LOGIN PASSWORD 'secret'; GRANT SELECT, INSERT, UPDATE ON TABLE users TO app_user; (security — «права доступа» — security — postgres — «авторизация» — security — postgres); Шифрование (security — postgresql.conf: ssl = on ssl_cert_file = 'server.crt' ssl_key_file = 'server.key' (security — «TLS включён» — security — postgres — «шифрование» — security — postgres); Аудит (security — postgresql.conf: log_connections = on log_disconnections = on log_statement = 'all' (security — «логи подключений» — security — postgres — «аудит» — security — postgres); Бэкапы (security — backup — pgbackrest --stanza=mydb backup (security — «бэкапы» — security — postgres — «бэкапы» — security — backup).
Практический сценарий: обеспечение безопасности продакшн БД
Контекст: PostgreSQL (postgres — продакшн (incident — security), боль: без безопасности (security — «без защиты» — security — incident — «утечки данных» — security — postgres); решение — database security: (1) аутентификация (security — pg_hba.conf: host all all 127.0.0.1/32 md5 (security — postgres — «аутентификация» — security — postgres); (2) авторизация (security — CREATE ROLE app_user WITH LOGIN PASSWORD 'secret'; GRANT SELECT, INSERT, UPDATE ON TABLE users TO app_user; (security — postgres — «авторизация» — security — postgres); (3) шифрование (security — ssl = on (security — postgres — «шифрование» — security — postgres); (4) аудит (security — log_connections = on (security — postgres — «аудит» — security — postgres); (5) бэкапы (security — backup — pgbackrest --stanza=mydb backup (security — postgres — «бэкапы» — security — backup); результат: безопасность обеспечена (security — «аутентификация/авторизация/шифрование/аудит» — security — incident — «данные защищены» — security — postgres — «утечки предотвращены» — security); вывод: database security решили задачу (защита данных — security — ADR — «без безопасности» — антипаттерн — postgres — безопасность обязательна — security — техдолг).
FAQ
Что такое database security и зачем она нужна? Database security (security — защита баз данных (security — «безопасность БД» — security — incident — «защита данных» — security — postgres); зачем: защита от утечек (security — «данные могут быть украдены» — security — incident — «утечки» — security — postgres), соответствие требованиям (security — «GDPR/PCI DSS» — security — incident — «требования» — security — postgres), доверие пользователей (security — «пользователи доверяют» — security — incident — «доверие» — security — postgres); «без безопасности» — антипаттерн (утечки данных — postgres — безопасность обязательна — security — ADR — техдолг).
Какие ключевые аспекты безопасности баз данных?
Аспекты (security — ключевые (security — «аспекты» — security — incident — «важные» — security — postgres): Аутентификация (security — «проверка подлинности» — security — incident — «кто вы» — security — postgres — pg_hba.conf (security — «аутентификация» — security), Авторизация (security — «права доступа» — security — incident — «что можно» — security — postgres — GRANT/REVOKE (security — «авторизация» — security), Шифрование (security — «шифрование данных» — security — incident — «данные зашифрованы» — security — postgres — ssl=on (security — «шифрование» — security), Аудит (security — «журналирование» — security — incident — «кто что сделал» — security — postgres — log_connections (security — «аудит» — security); «игнорировать аспекты» — антипаттерн (утечки данных — postgres — все аспекты важны — security — ADR — техдолг).
Как настроить аутентификацию и авторизацию в PostgreSQL?
Аутентификация (security — pg_hba.conf (security — host all all 127.0.0.1/32 md5 host all all 0.0.0.0/0 reject (security — postgres — «аутентификация» — security — postgres); Авторизация (security — CREATE ROLE app_user WITH LOGIN PASSWORD 'secret'; GRANT SELECT, INSERT, UPDATE ON TABLE users TO app_user; (security — postgres — «авторизация» — security — postgres); роли (security — CREATE ROLE (security — «роли» — security — postgres — «роли» — security — postgres), привилегии (security — GRANT/REVOKE (security — «привилегии» — security — postgres — «привилегии» — security — postgres); «без аутентификации» — антипаттерн (все могут подключиться — postgres — аутентификация обязательна — security — ADR — техдолг).
Как включить шифрование соединений в PostgreSQL и почему это важно?
Шифрование (security — TLS/SSL (security — «шифрование соединений» — security — incident — «TLS» — security — postgres); как: включить (security — postgresql.conf: ssl = on ssl_cert_file = 'server.crt' ssl_key_file = 'server.key' (security — postgres — «шифрование» — security — postgres), сертификаты (security — server.crt/server.key (security — «сертификаты» — security — postgres — «сертификаты» — security — postgres), подключение (security — psql "host=localhost sslmode=require" (security — postgres — «подключение» — security — postgres); почему важно: без шифрования — данные открыты (security — «данные открыты» — security — incident — «перехват» — security — postgres — «шифрование обязательно» — security); «без шифрования» — антипаттерн (данные открыты — postgres — шифрование обязательно — security — ADR — техдолг).
Источники: PostgreSQL docs (auth methods, encryption, client authentication) — ссылки в шапке.