diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/compose.yaml b/compose.yaml index 803e9d1..fe19a4f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -23,9 +23,9 @@ services: # https://www.pgadmin.org/ pgadmin: - image: dpage/pgadmin4:${PGADMIN_VERSION:-8.11} + image: dpage/pgadmin4:${PGADMIN_VERSION:-9.8} depends_on: - postgresql: + database: condition: service_healthy restart: "no" configs: @@ -108,6 +108,11 @@ services: profiles: - bi +# ---------------------------------------------------------------------- +# Documents +# +# ---------------------------------------------------------------------- + # CouchDB # Single-node document database # https://couchdb.apache.org/ @@ -120,6 +125,8 @@ services: environment: COUCHDB_USER: ${DB_ROOT_USER:-admin} COUCHDB_PASSWORD: ${DB_ROOT_PASSWORD:-!ChangeMe!} + profiles: + - documents # MongoDB # @@ -136,6 +143,8 @@ services: environment: MONGODB_INITDB_ROOT_USERNAME: ${DB_ROOT_USER:-admin} MONGODB_INITDB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-!ChangeMe!} + profiles: + - documents # Redis # In-memory key-value database @@ -171,6 +180,8 @@ services: - neo4j_logs:/logs environment: NEO4J_AUTH: neo4j/${DB_ROOT_PASSWORD:-!ChangeMe!} + profiles: + - graph # PostGraphile # Instant GraphQL API @@ -238,13 +249,10 @@ services: ports: - 3005:3005 environment: - PGRST_DB_URI: postgres://${POSTGREST_USER:-postgrest}:${DB_PASSWORD}@${POSTGREST_HOST:-database}:${POSTGREST_DB_PORT:-5432}/${COMPOSE_PROJECT_NAME} + PGRST_DB_URI: postgres://${POSTGREST_USER:-postgrest}:9012@${POSTGREST_HOST:-database}:${POSTGREST_DB_PORT:-5432}/${COMPOSE_PROJECT_NAME} PGRST_DB_SCHEMAS: ${POSTGREST_DB_SCHEMAS:-public} PGRST_DB_ANON_ROLE: ${POSTGREST_DB_ANON_ROLE:-role_web} - PGRST_JWT_SECRET: ${POSTGREST_JWT_SECRET:-ABCDEFGHIJKLMNOPQRSTUVWXYZ} - PGRST_DB_USE_LEGACY_GUCS: ${POSTGREST_DB_USE_LEGACY_GUCS:-false} - PGRST_APP_SETTINGS_JWT_SECRET: ${POSTGREST_APP_SETTINGS_JWT_SECRET} - PGRST_APP_SETTINGS_JWT_EXP: ${POSTGREST_APP_SETTINGS_JWT_EXP} + PGRST_JWT_SECRET: ${POSTGREST_JWT_SECRET:-ChangeMeChangeMeChangeMeChangeMe} PGRST_ADMIN_SERVER_PORT: 3055 PGRST_SERVER_PORT: 3005 profiles: diff --git a/docker-entrypoint-initdb.d/10_postgrest.sql b/docker-entrypoint-initdb.d/10_postgrest.sql index 70a8cef..70cf6cf 100644 --- a/docker-entrypoint-initdb.d/10_postgrest.sql +++ b/docker-entrypoint-initdb.d/10_postgrest.sql @@ -1,6 +1,23 @@ -create role postgrest noinherit login password 'motdepasse'; -grant role_web to postgrest; +create role postgrest nosuperuser nocreatedb nocreaterole noinherit noreplication nobypassrls + login password '9012'; --- Postgraphile -create role postgraphile inherit login password 'motdepasse'; -grant role_web to postgraphile; +-- postgrest est le rôle utilisé par l'application pour se connecter à la base. +-- Il doit être configuré pour avoir un accès très limité. +-- Il s'agit d'un caméléon dont la tâche est de « devenir » un autre utilisateur pour servir des requêtes HTTP authentifiées. + +-- Roles sans login. Il faut se connecter d'abord avec l'utilisateur postgrest. +-- Puis celui-ci usurpe une des identités suivantes suivant le role présent dans le JWT. +-- Lorsqu'une demande contient un JWT valide avec une revendication de rôle, +-- PostgREST passera au rôle de base de données avec ce nom pendant la durée de la demande HTTP avec la commande : +-- SET LOCAL ROLE adherent; +create role anonyme nologin; +create role adherent nologin; + +-- L'utilisateur postgrest peut se connecter en tant que ... +grant anonyme to postgrest; +grant adherent to postgrest; + +grant usage on schema public to anonyme; + +alter default privileges in schema public + grant select on tables to anonyme; diff --git a/docker-entrypoint-initdb.d/11_postgraphile.sql b/docker-entrypoint-initdb.d/11_postgraphile.sql new file mode 100644 index 0000000..bb6fa7d --- /dev/null +++ b/docker-entrypoint-initdb.d/11_postgraphile.sql @@ -0,0 +1 @@ +create role postgraphile inherit login password 'motdepasse'; diff --git a/pgadmin-servers.json b/pgadmin-servers.json index 70790ef..5491109 100644 --- a/pgadmin-servers.json +++ b/pgadmin-servers.json @@ -6,7 +6,7 @@ "Host": "database", "Port": 5432, "MaintenanceDB": "postgres", - "Username": "postgres", + "Username": "sql", "UseSSHTunnel": 0, "TunnelPort": "22", "TunnelAuthentication": 0,