-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
521 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Switch on | ||
|
||
Set the following environment variables: | ||
``` | ||
CACHE_BACKEND=django_redis.cache.RedisCache | ||
CACHE_LOCATION=redis://redis:6379 | ||
CACHE_TIMEOUT=300 | ||
``` | ||
|
||
These environment variables will be used to set [cache arguments][1] in the app's Django settings. | ||
|
||
# Administration | ||
|
||
The page cache is provided by [Wagtail Cache][2]. The page cache can be cleared from the Wagtail Admin by navigating to _Settings > Cache_, or _/admin/cache/_. | ||
|
||
# Switch off | ||
|
||
To switch off all caching features, it should be sufficient to simply unset the `CACHE_BACKEND` environment variable. | ||
|
||
# In development | ||
|
||
Most of the time it is probably desirable to switch off any sort of caching when developing the app. To avoid inadvertently committing settings that enable the page cache, it is advisable to place page cache settings in a `docker-compose.override.yml` file, if using Docker Compose. | ||
|
||
Example Docker Compose configuration: | ||
```docker-compose-override.yml | ||
services: | ||
django: | ||
environment: | ||
CACHE_BACKEND: django_redis.cache.RedisCache | ||
CACHE_LOCATION: 'redis://cache:6379' | ||
CACHE_TIMEOUT: '300' | ||
depends_on: | ||
- cache | ||
cache: | ||
image: redis:6.2-buster | ||
``` | ||
|
||
|
||
[1]: https://docs.djangoproject.com/en/3.1/topics/cache/#using-a-custom-cache-backend | ||
[2]: https://docs.coderedcorp.com/wagtail-cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Notifications | ||
|
||
The IoGT notification system relies on the [Web Push Protocol][1] to ensure the delivery of messages to users. In order to authenticate itself to a Push Service, every deployment of IoGT must generate its own public-private key pair for use with [VAPID][3]. | ||
|
||
To enable notifications in IoGT the following steps must be performed: | ||
|
||
- Generate VAPID keys | ||
- Set required settings (as environment variables) | ||
|
||
# Generate VAPID keys | ||
|
||
## Using openssl | ||
|
||
This method guarantees that the private key remains secret (unless you expose it) and should be suitable for production deployments. | ||
|
||
``` | ||
openssl ecparam -genkey -name prime256v1 -out private_key.pem | ||
openssl ec -in private_key.pem -pubout -outform DER | tail -c 65 | base64 | tr -d '=' | tr '/+' '_-' >> public_key.txt | ||
openssl ec -in private_key.pem -outform DER | tail -c +8 | head -c 32 | base64 | tr -d '=' | tr '/+' '_-' >> private_key.txt | ||
``` | ||
|
||
The public and private keys will be written as plaintext to `public_key.txt` and `private_key.txt`, respectively. | ||
|
||
## Using online generators | ||
|
||
This method is more convenient, especially if openssl is not available, however, it is *not* recommended for production deployments. | ||
|
||
- Go to [Web Push Codelab][2]. | ||
- Copy the public and private keys directly from the page. | ||
|
||
# Set required settings | ||
|
||
The notification feature requires several settings, and the easiest way to set them is to provide them to the app as environment variables. | ||
|
||
- `VAPID_PUBLIC_KEY`: the VAPID public key in plaintext | ||
- `VAPID_PRIVATE_KEY`: the VAPID private key in plaintext | ||
- `VAPID_ADMIN_EMAIL`: the email address of a person/team responsible for hosting the IoGT application e.g. system administrator | ||
|
||
It’s best if `VAPID_ADMIN_EMAIL` is not a personal email address, but rather a group email so that if a person leaves an organization, is unavailable for an extended period, or otherwise can’t respond, someone else on the list can. A Push Service provider may use this to contact you if there is a problem between the app and the push service. | ||
|
||
|
||
[1]: https://web.dev/push-notifications-web-push-protocol/ | ||
[2]: https://web-push-codelab.glitch.me | ||
[3]: https://datatracker.ietf.org/doc/html/draft-thomson-webpush-vapid |
Oops, something went wrong.