cambios en postgress, no me esta gustando el problema de autenticacion
Some checks failed
build-and-deploy / build-and-deploy (push) Failing after 1m6s
Some checks failed
build-and-deploy / build-and-deploy (push) Failing after 1m6s
This commit is contained in:
@@ -3,6 +3,10 @@ set -e
|
||||
|
||||
echo "Configurando autenticación de PostgreSQL..."
|
||||
|
||||
POSTGRES_USER="${POSTGRES_USER:-seguidor}"
|
||||
POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-seguidor_password}"
|
||||
POSTGRES_DB="${POSTGRES_DB:-$POSTGRES_USER}"
|
||||
|
||||
# Eliminar configuración scram-sha-256 y agregar md5
|
||||
# Esto asegura que las conexiones remotas funcionen correctamente
|
||||
sed -i '/scram-sha-256/d' "$PGDATA/pg_hba.conf"
|
||||
@@ -12,7 +16,16 @@ if ! grep -q "host all all all md5" "$PGDATA/pg_hba.conf"; then
|
||||
echo "host all all all md5" >> "$PGDATA/pg_hba.conf"
|
||||
fi
|
||||
|
||||
echo "✓ Configuración de autenticación aplicada (md5)"
|
||||
# Forzar que las contraseñas se guarden en md5 (no scram) y
|
||||
# reescribir la contraseña para asegurar que coincide con las env vars.
|
||||
ESCAPED_PASSWORD=${POSTGRES_PASSWORD//\'/\'\'}
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
ALTER SYSTEM SET password_encryption = 'md5';
|
||||
ALTER ROLE "$POSTGRES_USER" WITH PASSWORD '${ESCAPED_PASSWORD}';
|
||||
SELECT pg_reload_conf();
|
||||
EOSQL
|
||||
|
||||
echo "✓ Configuración de autenticación aplicada (md5 + password sincronizada)"
|
||||
|
||||
# Nota: No es necesario recargar aquí porque este script corre ANTES
|
||||
# de que PostgreSQL termine su inicialización. Los cambios se aplican
|
||||
|
||||
@@ -81,6 +81,13 @@ if ! grep -q "host all all all md5" "$PGDATA/pg_hba.conf"; then
|
||||
echo "host all all all md5" >> "$PGDATA/pg_hba.conf"
|
||||
fi
|
||||
|
||||
# Forzar md5 para almacenamiento de passwords y reescribir contraseña
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
ALTER SYSTEM SET password_encryption = 'md5';
|
||||
ALTER ROLE "$POSTGRES_USER" WITH PASSWORD '${POSTGRES_PASSWORD}';
|
||||
SELECT pg_reload_conf();
|
||||
EOSQL
|
||||
|
||||
echo "✓ Configuración de autenticación aplicada (md5)"
|
||||
```
|
||||
|
||||
@@ -89,6 +96,7 @@ echo "✓ Configuración de autenticación aplicada (md5)"
|
||||
- Los cambios en `pg_hba.conf` se aplican automáticamente al finalizar el inicio
|
||||
- No es necesario ejecutar `pg_ctl reload` manualmente
|
||||
- El método `md5` es compatible con el driver `pg` de Node.js
|
||||
- Cada deploy vuelve a aplicar `password_encryption=md5` y resetea la contraseña vía Gitea Action para curar volúmenes antiguos
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user