Files
Ubuntu_docs/PostgreSQL_credcheck.md
2025-02-24 22:57:30 +05:00

62 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

****************************************************************************************************
Установка и настройка проверяльщик паролей credcheck
PostgreSQL https://www.postgresql.org/about/news/credcheck-v200-released-2654/
Тестовая база
```sh
ssh administrator@10.201.3.36 -p 22
```
Похоже в официальном репозитории нет credcheck, так что если будем искать то не найдём:
```sh
apt search credcheck
```
Поэтому устанавливаем из репозиториев (компилируем на тестовой машине потом устанавливаем на продакшен):
```sh
sudo apt-get install postgresql-server-dev-16 &&
sudo apt-get install build-essential &&
git clone https://github.com/HexaCluster/credcheck.git &&
cd credcheck &&
make &&
sudo make install
```
Подключаемся к базе данных для выполнения запросов
```sh
psql -h 127.0.0.1 -U postgres -d transit
```
Проверяем что настройки имеются:
```sh
SELECT name, setting, unit, source, sourcefile, sourceline
FROM pg_settings
WHERE name LIKE 'credcheck%';
```
Читаем текущие настройки
```sh
SHOW ALL;
```
Создаём расширение в базе postgres:
```sh
CREATE EXTENSION credcheck;
```
Теперь можно настроить расширение по https://tembo.io/docs/getting-started/postgres_guides/extensions/credcheck:
-- Configure credential policies to enforce username and password standards and reload configuration files
ALTER SYSTEM SET credcheck.username_min_length = 4;
ALTER SYSTEM SET credcheck.password_min_length = 8;
ALTER SYSTEM SET credcheck.password_min_special = 1;
SELECT pg_reload_conf();
-- Attempt to create a user for a new park ranger, which does not meet the credential policies
CREATE USER ranger_ WITH PASSWORD 'forest';
ERROR: password length should match the configured credcheck.password_min_length
Для пароля установить:
ALTER SYSTEM SET credcheck.password_expiration_days = 90;
SELECT pg_reload_conf();
Для приложений нужно изменить политику паролей (менять не автоматически а по расписанию у администратора):