From fd18df772e76f2a01aa280d09c1de78327b9a7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20S=C5=82ota?= Date: Wed, 6 Nov 2019 16:01:24 +0100 Subject: [PATCH 1/3] Update config/dev.exs Make `config/dev.exs` connect by default to local mocks that can be setup the same way as for tests. --- config/dev.exs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/config/dev.exs b/config/dev.exs index f60f6727..80f6827c 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -25,9 +25,11 @@ config :mongoose_push, fcm: [ default: [ endpoint: "localhost", + port: 4000, appfile: "priv/fcm/token.json", pool_size: 5, - mode: :prod + mode: :prod, + tls_opts: [] ] ] @@ -42,7 +44,8 @@ config :mongoose_push, endpoint: "localhost", mode: :dev, use_2197: true, - pool_size: 5 + pool_size: 5, + tls_opts: [] ], prod: [ auth: %{ @@ -53,6 +56,7 @@ config :mongoose_push, endpoint: "localhost", mode: :prod, use_2197: true, - pool_size: 5 + pool_size: 5, + tls_opts: [] ] ] From 7983a853e7993ceca8205687c3397bb596aff1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20S=C5=82ota?= Date: Wed, 6 Nov 2019 16:11:01 +0100 Subject: [PATCH 2/3] Update README.md README.md now includes information aboout building `dev` release that connects to local APNS / FCM mocks. --- README.md | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3e7d1dca..0a4632bb 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ For the full configuration you need to set the following directory structure up: * token.json - `FCM` service account JSON file If you want to use `APNS` token authentication you need to provide token and set `key_id` and `team_id` environmental variables. To see how to obtain token and `key_id` read: -https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token_based_connection_to_apns +https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token_based_connection_to_apns To see how to obtain `team_id` read: https://www.mobiloud.com/help/knowledge-base/ios-app-transfer/ -`FCM` JSON file can be generated by Firebase console (https://console.firebase.google.com). Go to your project -> `Project Settings` -> `Service accounts` -> `Generate new private key` +`FCM` JSON file can be generated by Firebase console (https://console.firebase.google.com). Go to your project -> `Project Settings` -> `Service accounts` -> `Generate new private key` Assuming that you have the `priv` directory with all ceriticates and fcm token in current directory, then you may start MongoosePush with the following command: ```bash @@ -111,7 +111,7 @@ Environmental variables to configure production release: > It is however highly recommended to build MongoosePush with Erlang/OTP 21.x. * Rebar3 (just enter ```mix local.rebar```) -#### Build and run +#### Build and run of production release Build step is really easy. Just type in root of the repository: ```bash @@ -120,10 +120,30 @@ MIX_ENV=prod mix do deps.get, compile, certs.dev, distillery.release After this step you may try to run the service via: ```bash -_build/prod/rel/mongoose_push/bin/mongoose_push console +_build/prod/rel/mongoose_push/bin/mongoose_push foreground +``` + +Yeah, I know... It crashed. Running this service is fast and simple but unfortunately you can't have push notifications without properly configured `FCM` and/or `APNS` service. You can find out how to properly configure it in `Configuration` section of this README. + +#### Build and run of development release + +Build step is really easy. Just type in root of the repository: +```bash +MIX_ENV=dev mix do deps.get, compile, certs.dev, distillery.release +``` + +Development release is by default configured to connect to local APNS / FCM mock. This configuration may be changed as needed +in `config/dev.exs` file. +For now, let's just start those mocks so that we can use default dev configuration: +```bash +docker-compose -f test/docker/docker-compose.yml up -d +``` + +After this step you may try to run the service via: +```bash +_build/dev/rel/mongoose_push/bin/mongoose_push console ``` -Yeah, I know... It crashed. Running this service is fast and simple but unfortunately you can't have push notifications without properly configured `FCM` and/or `APNS` service. So, lets configure it! ### Running tests From 1767233bd93d9eb366c45978b956f2bd5e2b11d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20S=C5=82ota?= Date: Wed, 6 Nov 2019 16:41:44 +0100 Subject: [PATCH 3/3] Update config files documentation --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0a4632bb..775fc1a0 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,8 @@ config :mongoose_push, fcm: [ appfile: "path/to/token.json", endpoint: "localhost", pool_size: 5, - mode: :prod + mode: :prod, + tls_opts: [] ] ] ``` @@ -211,7 +212,9 @@ Each `FCM` pool may be configured by setting the following fields: * **pool_size** (*required*) - maximum number of used `HTTP/2` connections to google's service * **mode** (*either `:prod` or `:dev`*) - pool's mode. The `HTTP` client may select pool used to push a notification by specifying matching option in the request * **endpoint** (*optional*) - URL override for `FCM` service. Useful mainly in tests +* **port** (*optional*) - Port number override for `FCM` service. Useful mainly in tests * **tags** (*optional*) - a list of tags. Used when choosing pool to match request tags when sending a notification. More details: https://github.com/esl/sparrow#tags +* **tls_opts** (*optional*) - a list of raw options passed to `ssl:connect` function call while connecting to `FCM`. When this option is omitted, it will default to set of values that will verify server certificate based on internal CA chain. Providing this option overrides all defaults, effectively disabling certificate validation. Therefore passing this option is not recommended outside dev and test environments. You may entirely skip the `FCM` config entry to disable `FCM` support. @@ -225,14 +228,16 @@ config :mongoose_push, apns: [ key: "priv/apns/dev_key.pem", mode: :dev, use_2197: false, - pool_size: 5 + pool_size: 5, + tls_opts: [] ], prod: [ cert: "priv/apns/prod_cert.pem", key: "priv/apns/prod_key.pem", mode: :prod, use_2197: false, - pool_size: 5 + pool_size: 5, + tls_opts: [] ] ] ``` @@ -244,8 +249,10 @@ Each `APNS` pool may be configured by setting the following fields: * **pool_size** (*required*) - maximum number of used `HTTP/2` connections to google's service * **mode** (*either `:prod` or `:dev`*) - pool's mode. The `HTTP` client may select pool used to push a notification by specifying matching option in the request * **endpoint** (*optional*) - URL override for `APNS` service. Useful mainly in tests +* **port** (*optional*) - Port number override for `APNS` service. Useful mainly in tests * **use_2197** (*optional `true` or `false`*) - whether use alternative port for `APNS`: 2197 * **tags** (*optional*) - a list of tags. Used when choosing pool to match request tags when sending a notification. More details: https://github.com/esl/sparrow#tags +* **tls_opts** (*optional*) - a list of raw options passed to `ssl:connect` function call while connecting to `APNS`. When this option is omitted, it will default to set of values that will verify server certificate based on internal CA chain. Providing this option overrides all defaults, effectively disabling certificate validation. Therefore passing this option is not recommended outside dev and test environments. You may entirely skip the `APNS` config entry to disable `APNS` support.