|
| 1 | +# Oracle Publisher Secret Deployment |
| 2 | + |
| 3 | +This is the acceptable production pattern for API keys used by live publishers on the Oracle host. |
| 4 | + |
| 5 | +## Principle |
| 6 | + |
| 7 | +Publisher code must stay configurable and secret-free. The repository may contain variable names, `.env.example` placeholders, Docker Compose interpolation, and systemd instructions, but not raw provider keys. |
| 8 | + |
| 9 | +The live Oracle host should inject keys through one of these host-local mechanisms: |
| 10 | + |
| 11 | +- systemd `EnvironmentFile=` with mode `0600`, owned by `root`; |
| 12 | +- service-specific root-owned key files referenced by `*_API_KEY_FILE` environment variables; |
| 13 | +- Docker Compose `.env` on the host, also mode `0600`, if the publisher is run via Compose. |
| 14 | + |
| 15 | +## Current Key-Backed Publishers |
| 16 | + |
| 17 | +| Publisher | Required? | Variable | |
| 18 | +| --- | --- | --- | |
| 19 | +| USGS Water | Optional, improves rate limits | `USGS_API_KEY` | |
| 20 | +| USGS NIMS | Optional, improves rate limits | `USGS_API_KEY` | |
| 21 | +| Met Office Land Observations | Required | `MET_OFFICE_LAND_OBSERVATIONS_API_KEY` | |
| 22 | + |
| 23 | +The Oracle deploy/bootstrap script also expects `OSH_PASS` from the caller's environment or a host-local environment file. Server credentials should follow the same rule as provider API keys: never commit the raw value. |
| 24 | + |
| 25 | +Met Office also supports `MET_OFFICE_LAND_OBSERVATIONS_API_KEY_FILE`, which should point at a host-local file containing the raw key or an assignment line. |
| 26 | + |
| 27 | +## systemd Pattern |
| 28 | + |
| 29 | +Create a shared environment file on Oracle: |
| 30 | + |
| 31 | +```bash |
| 32 | +sudo install -d -m 700 -o root -g root /etc/os4csapi |
| 33 | +sudo install -m 600 -o root -g root /dev/null /etc/os4csapi/publisher-secrets.env |
| 34 | +sudoedit /etc/os4csapi/publisher-secrets.env |
| 35 | +``` |
| 36 | + |
| 37 | +Example contents, with placeholders only: |
| 38 | + |
| 39 | +```text |
| 40 | +USGS_API_KEY=<usgs-key-if-used> |
| 41 | +MET_OFFICE_LAND_OBSERVATIONS_API_KEY=<met-office-land-observations-key> |
| 42 | +OSH_PASS=<osh-admin-password> |
| 43 | +``` |
| 44 | + |
| 45 | +Then add a drop-in to each service that needs the keys: |
| 46 | + |
| 47 | +```bash |
| 48 | +sudo systemctl edit met-office-datahub-publisher-go |
| 49 | +``` |
| 50 | + |
| 51 | +Drop-in contents: |
| 52 | + |
| 53 | +```ini |
| 54 | +[Service] |
| 55 | +EnvironmentFile=/etc/os4csapi/publisher-secrets.env |
| 56 | +``` |
| 57 | + |
| 58 | +Reload and restart: |
| 59 | + |
| 60 | +```bash |
| 61 | +sudo systemctl daemon-reload |
| 62 | +sudo systemctl restart met-office-datahub-publisher-go |
| 63 | +sudo journalctl -u met-office-datahub-publisher-go -n 80 --no-pager |
| 64 | +``` |
| 65 | + |
| 66 | +For USGS Water and USGS NIMS, use the same `EnvironmentFile=` drop-in on `usgs-water-publisher-go` and `usgs-nims-publisher-go` when the API key is available. |
| 67 | + |
| 68 | +## Secret File Pattern |
| 69 | + |
| 70 | +For a single-service Met Office secret file: |
| 71 | + |
| 72 | +```bash |
| 73 | +sudo install -d -m 700 -o root -g root /etc/os4csapi/secrets |
| 74 | +sudo install -m 600 -o root -g root /dev/null /etc/os4csapi/secrets/met-office-land-observations.key |
| 75 | +sudoedit /etc/os4csapi/secrets/met-office-land-observations.key |
| 76 | +``` |
| 77 | + |
| 78 | +The file should contain only the key or this assignment: |
| 79 | + |
| 80 | +```text |
| 81 | +MET_OFFICE_LAND_OBSERVATIONS_API_KEY=<met-office-land-observations-key> |
| 82 | +``` |
| 83 | + |
| 84 | +The service environment then uses: |
| 85 | + |
| 86 | +```ini |
| 87 | +[Service] |
| 88 | +Environment=MET_OFFICE_LAND_OBSERVATIONS_API_KEY_FILE=/etc/os4csapi/secrets/met-office-land-observations.key |
| 89 | +``` |
| 90 | + |
| 91 | +Standalone publisher runs may also point at a shared host-local env file: |
| 92 | + |
| 93 | +```ini |
| 94 | +[Service] |
| 95 | +Environment=PUBLISHERS_ENV_FILE=/etc/os4csapi/publisher-secrets.env |
| 96 | +``` |
| 97 | + |
| 98 | +## Docker Compose Pattern |
| 99 | + |
| 100 | +When running `publishers/docker-compose.yml` on Oracle, store keys in the host-local `publishers/.env` file. That file is ignored by git and must not be copied into commits or support bundles. |
| 101 | + |
| 102 | +```text |
| 103 | +USGS_API_KEY=<usgs-key-if-used> |
| 104 | +MET_OFFICE_LAND_OBSERVATIONS_API_KEY=<met-office-land-observations-key> |
| 105 | +``` |
| 106 | + |
| 107 | +Met Office is an opt-in access-gated Compose service: |
| 108 | + |
| 109 | +```bash |
| 110 | +docker compose --profile access-gated up -d met-office-datahub |
| 111 | +``` |
0 commit comments