Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions configuration/secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ const config = {
...
cors: "allowWhitelist",
corsDomainWhitelist: ["api.mapbox.com"],
corsSecretWhitelist: {
"api.mapbox.com": ["SECRET_MAPBOX_ID", "SECRET_MAPBOX_TOKEN"]
},
...
modules: [
{
Expand Down Expand Up @@ -142,6 +145,23 @@ above, we need to set
```js
cors: "allowWhitelist",
corsDomainWhitelist: ["api.mapbox.com"],
corsSecretWhitelist: {
"api.mapbox.com": ["SECRET_MAPBOX_ID", "SECRET_MAPBOX_TOKEN"]
},
```

Only secrets listed for the target hostname are substituted, all other
placeholders stay unchanged. With `cors: "allowAll"` no secrets are substituted.

Requests with secrets must use HTTPS on port 443, must not contain URL
credentials, and secrets must not change the host. They are never redirected.

If you already use secrets in proxy URLs, add a `corsSecretWhitelist` entry like
the one above. The modules themselves need no changes.

Only list secrets the target service really needs, with minimal permissions. The
whitelist does not restrict paths or query parameters, and the service's
response is returned to the browser. A service that echoes the secret back can
still expose it.

:::
9 changes: 6 additions & 3 deletions module-development/weather-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class YourProvider {
}

initialize() {
this.fetcher = new HTTPFetcher("https://your.api/endpoint", {
this.fetcher = new HTTPFetcher({
url: "https://your.api/endpoint",
reloadInterval: this.config.updateInterval,
logContext: "weatherprovider.yourprovider",
});
Expand Down Expand Up @@ -170,8 +171,9 @@ or unexpected API response shapes can be reported through `onErrorCallback`
instead of failing silently.

`HTTPFetcher` (`require("#http_fetcher")`) handles periodic fetching with retry
and backoff. See
[`js/http_fetcher.js`](https://github.com/MagicMirrorOrg/MagicMirror/blob/master/js/http_fetcher.js)
and backoff. Pass `url` for a static address or `urlFactory` for an address that
changes between requests. See
[`js/http_fetcher.mjs`](https://github.com/MagicMirrorOrg/MagicMirror/blob/master/js/http_fetcher.mjs)
for all options. Common `translationKey` values: `MODULE_ERROR_UNAUTHORIZED`,
`MODULE_ERROR_RATE_LIMITED`, `MODULE_ERROR_SERVER_ERROR`,
`MODULE_ERROR_NO_CONNECTION`, `MODULE_ERROR_UNSPECIFIED`.
Expand Down Expand Up @@ -205,6 +207,7 @@ server-side provider returns plain objects; the weather module converts them to
| temperature | `number` | Current temperature in metric `celsius degree`. |
| minTemperature | `number` | Lowest temperature of the day in metric `celsius degree`. |
| maxTemperature | `number` | Highest temperature of the day in metric `celsius degree`. |
| feelsLikeTemp | `number` | Optional apparent temperature in metric `celsius degree`. Calculated if omitted. |
| weatherType | `string` | Icon name of the weather type. <br> Possible values: [WeatherIcons](https://www.npmjs.com/package/weathericons) |
| humidity | `number` | Percentage of humidity |
| precipitationAmount | `number` | Metric: `millimeters` |
Expand Down
Loading