From 038e2ca35f73e068eba5f98d96c7ac38cde91f89 Mon Sep 17 00:00:00 2001 From: Roman Strobl Date: Wed, 6 Nov 2024 15:01:26 +0800 Subject: [PATCH] Fix #1134: Add new push platform enums, deprecate old ones --- docs/Migration-Instructions.md | 1 + docs/Mobile-Token-API.md | 14 ++++++++------ docs/PowerAuth-Enrollment-Server-1.10.0.md | 10 ++++++++++ docs/PowerAuth-Enrollment-Server-1.7.0.md | 2 +- .../enrollment/request/PushRegisterRequest.java | 16 ++++++++++++++-- .../impl/service/PushRegistrationService.java | 3 +++ 6 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 docs/PowerAuth-Enrollment-Server-1.10.0.md diff --git a/docs/Migration-Instructions.md b/docs/Migration-Instructions.md index abd670ab8..db6aa8576 100644 --- a/docs/Migration-Instructions.md +++ b/docs/Migration-Instructions.md @@ -2,6 +2,7 @@ This page contains PowerAuth Enrollment Server migration instructions. +- [PowerAuth Enrollment Server 1.10.0](./PowerAuth-Enrollment-Server-1.10.0.md) - [PowerAuth Enrollment Server 1.9.0](./PowerAuth-Enrollment-Server-1.9.0.md) - [PowerAuth Enrollment Server 1.8.0](./PowerAuth-Enrollment-Server-1.8.0.md) - [PowerAuth Enrollment Server 1.7.0](./PowerAuth-Enrollment-Server-1.7.0.md) diff --git a/docs/Mobile-Token-API.md b/docs/Mobile-Token-API.md index d155655e3..7729001ee 100644 --- a/docs/Mobile-Token-API.md +++ b/docs/Mobile-Token-API.md @@ -790,15 +790,16 @@ Registers a device to push notifications. Authorization is done using PowerAuth ```json { "requestObject": { - "platform": "ios", + "platform": "apns", "token": "10de0b9c-791f-4e9f-93c4-e2203951c307" } } ``` Supported platforms: -- `ios` -- `android` +- `apns` +- `fcm` +- `hms` #### Response 200 @@ -869,15 +870,16 @@ Registers a device to push notifications. Authorization is done using PowerAuth ```json { "requestObject": { - "platform": "ios", + "platform": "apns", "token": "10de0b9c-791f-4e9f-93c4-e2203951c307" } } ``` Supported platforms: -- `ios` -- `android` +- `aps` +- `fcm` +- `hms` #### Response 200 diff --git a/docs/PowerAuth-Enrollment-Server-1.10.0.md b/docs/PowerAuth-Enrollment-Server-1.10.0.md new file mode 100644 index 000000000..28362043a --- /dev/null +++ b/docs/PowerAuth-Enrollment-Server-1.10.0.md @@ -0,0 +1,10 @@ +# Migration from 1.9.x to 1.10.x + +This guide contains instructions for migration from PowerAuth Enrollment Server version `1.9.x` to version `1.10.0`. + +## REST API + +### Platform Validation during Registration for Push Messages + +The endpoints `POST /api/push/device/register` and `POST /api/push/device/register/token` now use updated platform `platform` values `apns`, `fcm`, and `hms`. +The original values `ios`, `android` and `huawei` are still supported, but will be removed in a future release. \ No newline at end of file diff --git a/docs/PowerAuth-Enrollment-Server-1.7.0.md b/docs/PowerAuth-Enrollment-Server-1.7.0.md index f6b607ef8..078a6e5c7 100644 --- a/docs/PowerAuth-Enrollment-Server-1.7.0.md +++ b/docs/PowerAuth-Enrollment-Server-1.7.0.md @@ -8,5 +8,5 @@ This guide contains instructions for migration from PowerAuth Enrollment Server ### Register for Push Messages (Token) -The endpoint `POST /api/push/device/register/token` now strictly validates `platform` against values `ios`, `android` or `huawei`. +The endpoints `POST /api/push/device/register` and `POST /api/push/device/register/token` now strictly validate `platform` against values `ios`, `android` or `huawei`. If you use the PowerAuth SDK, you should not be affected. diff --git a/enrollment-server-api-model/src/main/java/com/wultra/app/enrollmentserver/api/model/enrollment/request/PushRegisterRequest.java b/enrollment-server-api-model/src/main/java/com/wultra/app/enrollmentserver/api/model/enrollment/request/PushRegisterRequest.java index 11121cbe3..46a963cb5 100644 --- a/enrollment-server-api-model/src/main/java/com/wultra/app/enrollmentserver/api/model/enrollment/request/PushRegisterRequest.java +++ b/enrollment-server-api-model/src/main/java/com/wultra/app/enrollmentserver/api/model/enrollment/request/PushRegisterRequest.java @@ -40,21 +40,33 @@ public class PushRegisterRequest { private Platform platform; /** - * The push token is the value received from APNS, FCM, or HMS services without any modification. + * The push token is the value received from APNs, FCM, or HMS services without any modification. */ @NotBlank @ToString.Exclude - @Schema(description = "The push token is the value received from APNS, FCM, or HMS services without any modification.") + @Schema(description = "The push token is the value received from APNs, FCM, or HMS services without any modification.") private String token; public enum Platform { + @JsonProperty("apns") + APNS, + + @JsonProperty("fcm") + FCM, + + @JsonProperty("hms") + HMS, + @JsonProperty("ios") + @Deprecated IOS, @JsonProperty("android") + @Deprecated ANDROID, @JsonProperty("huawei") + @Deprecated HUAWEI } diff --git a/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/PushRegistrationService.java b/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/PushRegistrationService.java index a3ee4a6f5..556cb3fe1 100644 --- a/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/PushRegistrationService.java +++ b/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/PushRegistrationService.java @@ -94,6 +94,9 @@ public Response registerDevice( private static MobilePlatform convert(final PushRegisterRequest.Platform source) { return switch (source) { + case APNS -> MobilePlatform.APNS; + case FCM -> MobilePlatform.FCM; + case HMS -> MobilePlatform.HMS; case IOS -> MobilePlatform.IOS; case ANDROID -> MobilePlatform.ANDROID; case HUAWEI -> MobilePlatform.HUAWEI;