feat: use different creds for api and consumer with restrictive rights
This commit is contained in:
parent
611600c2d8
commit
11b7c14dc7
7 changed files with 16 additions and 1 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -218,3 +218,8 @@ __marimo__/
|
||||||
|
|
||||||
# Streamlit
|
# Streamlit
|
||||||
.streamlit/secrets.toml
|
.streamlit/secrets.toml
|
||||||
|
|
||||||
|
|
||||||
|
## Specific env files that may contain secrets
|
||||||
|
api.env
|
||||||
|
consumer.env
|
||||||
1
server/api.env.example
Normal file
1
server/api.env.example
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
DATABASE_URI='postgresql://simugaz_api:changeme@db/simugaz'
|
||||||
|
|
@ -15,7 +15,7 @@ log = logging.getLogger(__name__)
|
||||||
_MIN_CONN = 1
|
_MIN_CONN = 1
|
||||||
_MAX_CONN = 10
|
_MAX_CONN = 10
|
||||||
|
|
||||||
DB_URI = os.getenv("DATABASE_URI", "postgresql://simugaz:simugaz@db/simugaz")
|
DB_URI = os.getenv("DATABASE_URI", "postgresql://user:password@db/simugaz")
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
@lru_cache(maxsize=1)
|
||||||
|
|
|
||||||
1
server/consumer.env.example
Normal file
1
server/consumer.env.example
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
DATABASE_URI='postgresql://simugaz_consumer:changemetoo@db/simugaz'
|
||||||
|
|
@ -7,6 +7,7 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- lora-gateway_mqtt
|
- lora-gateway_mqtt
|
||||||
- database
|
- database
|
||||||
|
env_file: consumer.env
|
||||||
|
|
||||||
api:
|
api:
|
||||||
build: ./backend
|
build: ./backend
|
||||||
|
|
@ -18,6 +19,7 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- public
|
- public
|
||||||
- database
|
- database
|
||||||
|
env_file: api.env
|
||||||
|
|
||||||
webui:
|
webui:
|
||||||
build: ./frontend
|
build: ./frontend
|
||||||
|
|
|
||||||
6
server/initdb/02_roles.sql
Normal file
6
server/initdb/02_roles.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
CREATE USER simugaz_api WITH PASSWORD 'changeme';
|
||||||
|
GRANT SELECT ON TABLE device, reading TO simugaz_api;
|
||||||
|
|
||||||
|
CREATE USER simugaz_consumer WITH PASSWORD 'changemetoo';
|
||||||
|
GRANT SELECT, INSERT ON TABLE device TO simugaz_consumer;
|
||||||
|
GRANT INSERT ON TABLE reading TO simugaz_consumer;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue