Skip to content

Commit

Permalink
Fix #906: Allow customization of APNs environment on push device level (
Browse files Browse the repository at this point in the history
  • Loading branch information
romanstrobl authored Nov 13, 2024
1 parent 393eae3 commit 3c42380
Show file tree
Hide file tree
Showing 33 changed files with 940 additions and 185 deletions.
6 changes: 3 additions & 3 deletions docs-private/Developer-How-To-Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ To generate SQL script run following command:
#### PostgreSQL

```shell
liquibase --changeLogFile=./docs/db/changelog/changesets/powerauth-push-server/db.changelog-module.xml --output-file=./docs/sql/postgresql/migration_1.7.0_1.8.0.sql updateSQL --url=offline:postgresql
liquibase --changeLogFile=./docs/db/changelog/changesets/powerauth-push-server/db.changelog-module.xml --output-file=./docs/sql/postgresql/update.sql updateSQL --url=offline:postgresql
```

#### Oracle

```shell
liquibase --changeLogFile=./docs/db/changelog/changesets/powerauth-push-server/db.changelog-module.xml --output-file=./docs/sql/oracle/migration_1.7.0_1.8.0.sql updateSQL --url=offline:oracle
liquibase --changeLogFile=./docs/db/changelog/changesets/powerauth-push-server/db.changelog-module.xml --output-file=./docs/sql/oracle/update.sql updateSQL --url=offline:oracle
```


#### MSSQL

```shell
liquibase --changeLogFile=./docs/db/changelog/changesets/powerauth-push-server/db.changelog-module.xml --output-file=./docs/sql/mssql/migration_1.7.0_1.8.0.sql updateSQL --url=offline:mssql
liquibase --changeLogFile=./docs/db/changelog/changesets/powerauth-push-server/db.changelog-module.xml --output-file=./docs/sql/mssql/update.sql updateSQL --url=offline:mssql
```
16 changes: 16 additions & 0 deletions docs/PowerAuth-Push-Server-1.10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,19 @@ The unconfigured application list endpoint `POST /admin/app/unconfigured/list` u
The application detail endpoint `POST /admin/app/detail` uses new platform enumerations in both request and response.

The push message send endpoint `POST /push/message/send` contains new platform enumerations in the response for the count of sent messages.

### Customization of APNs Environment per Registered Device

It is now possible to specify an APNs environment per device registration. The change is reflected in the REST API endpoints `/push/device/create` and `/push/device/create/multi` by addition of the `environment` parameter.

The allowed values of the `environment` parameter are:
- `development` - development APNs host is used for sending push messages
- `production` - production APNs host is used for sending push messages

For platforms other than APNs the parameter is not used, `null` value is allowed.

For existing device registrations if the `environment` value is not specified during registration, the `environment` is decided based on application credential settings in table `push_app_credentials`, column `apns_environment`. If the environment is not configured on application level either, a global server setting is used as a fallback value.

The global setting is controlled by property `powerauth.push.service.apns.useDevelopment`. In case the property is set to `false`, delivery to `development` APNs host is not allowed for devices registered with the `development` environment.

This change is reflected in database by addition of parameter `environment` in table `push_device_registration`.
4 changes: 4 additions & 0 deletions docs/Push-Server-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ _Note: Since this endpoint is usually called by the back-end service, it is not
"appId": "mobile-app",
"token": "1234567890987654321234567890",
"platform": "apns",
"environment": "development",
"activationId": "49414e31-f3df-4cea-87e6-f214ca3b8412"
}
}
Expand All @@ -191,6 +192,7 @@ _Note: Since this endpoint is usually called by the back-end service, it is not
- `appId` - Application that device is using.
- `token` - Identifier for device.
- `platform` - `apns`, `fcm`, `hms`
- `environment` - `development` or `production` for APNs, `null` otherwise
- `activationId` - Activation identifier

#### Response 200
Expand Down Expand Up @@ -230,6 +232,7 @@ _Note: Since this endpoint is usually called by the back-end service, it is not
"appId": "mobile-app",
"token": "1234567890987654321234567890",
"platform": "apns",
"environment": "development",
"activationIds": [
"49414e31-f3df-4cea-87e6-f214ca3b8412",
"26c94bf8-f594-4bd8-9c51-93449926b644"
Expand All @@ -241,6 +244,7 @@ _Note: Since this endpoint is usually called by the back-end service, it is not
- `appId` - Application that device is using.
- `token` - Identifier for device.
- `platform` - `apns`, `fcm`, `hms`
- `environment` - `development` or `production` for APNs, `null` otherwise
- `activationIds` - Associated activation identifiers

#### Response 200
Expand Down
1 change: 1 addition & 0 deletions docs/Push-Server-Database.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Stores push tokens specific for a given device.
| `user_id` | INTEGER | index | Associated user ID. |
| `app_id` | INTEGER | index | Associated application ID. |
| `platform` | VARCHAR(30) | - | Mobile OS Platform ("apns", "fcm", "hms", "ios" (deprecated), "android" (deprecated), "huawei" (deprecated). |
| `environment` | VARCHAR(255) | - | APNs environment - `development` or `production`, `null` value is used for other platforms. |
| `push_token` | VARCHAR(255) | - | Push token associated with a given device. Type of the token is determined by the `platform` column. |
| `timestamp_last_registered` | TIMESTAMP | - | Timestamp of the last device registration. |
| `is_active` | BOOLEAN | - | PowerAuth activation status (boolean), used as an activation status cache so that communication with PowerAuth Server can be minimal. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd">

<!-- Add new APNS columns -->
<changeSet id="1" logicalFilePath="powerauth-push-server/1.10.x/20241108-device-registration-environment.xml" author="Roman Strobl">
<preConditions onFail="MARK_RAN">
<columnExists tableName="push_device_registration" columnName="environment"/>
</preConditions>
<comment>Add columns environment to push_device_registration table</comment>
<addColumn tableName="push_device_registration">
<column name="environment" type="varchar(255)" />
</addColumn>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd">

<include file="20241029-add-new-platforms.xml" relativeToChangelogFile="true" />
<include file="20241108-device-registration-environment.xml" relativeToChangelogFile="true" />

</databaseChangeLog>
5 changes: 5 additions & 0 deletions docs/sql/mssql/migration_1.9.0_1.10.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ GO
UPDATE push_app_credentials SET fcm_private_key = android_private_key, fcm_project_id = android_project_id;
GO

-- Changeset powerauth-push-server/1.10.x/20241108-device-registration-environment.xml::1::Roman Strobl
-- Add columns environment to push_device_registration table
ALTER TABLE push_device_registration ADD environment varchar(255);
GO


4 changes: 4 additions & 0 deletions docs/sql/oracle/migration_1.9.0_1.10.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ UPDATE push_app_credentials SET apns_bundle = ios_bundle, apns_environment = ios
-- Changeset powerauth-push-server/1.10.x/20241029-migrate-android-to-fcm.xml::4::Roman Strobl
-- Migrate existing android_* columns to fcm_* columns
UPDATE push_app_credentials SET fcm_private_key = android_private_key, fcm_project_id = android_project_id;

-- Changeset powerauth-push-server/1.10.x/20241108-device-registration-environment.xml::1::Roman Strobl
-- Add columns environment to push_device_registration table
ALTER TABLE push_device_registration ADD environment VARCHAR2(255);
4 changes: 4 additions & 0 deletions docs/sql/postgresql/migration_1.9.0_1.10.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ UPDATE push_app_credentials SET apns_bundle = ios_bundle, apns_environment = ios
-- Changeset powerauth-push-server/1.10.x/20241029-migrate-android-to-fcm.xml::4::Roman Strobl
-- Migrate existing android_* columns to fcm_* columns
UPDATE push_app_credentials SET fcm_private_key = android_private_key, fcm_project_id = android_project_id;

-- Changeset powerauth-push-server/1.10.x/20241108-device-registration-environment.xml::1::Roman Strobl
-- Add columns environment to push_device_registration table
ALTER TABLE push_device_registration ADD environment VARCHAR(255);
Loading

0 comments on commit 3c42380

Please sign in to comment.