Skip to content

Commit

Permalink
Merge pull request #303 from wultra/develop
Browse files Browse the repository at this point in the history
Prepare release 0.24.0
  • Loading branch information
romanstrobl authored May 20, 2020
2 parents 01b370b + 7b95b34 commit 4906344
Show file tree
Hide file tree
Showing 86 changed files with 25,152 additions and 12,035 deletions.
42 changes: 42 additions & 0 deletions docs/PowerAuth-Push-Server-0.24.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Migration from 0.23.0 to 0.24.0

## Unirest Initialization

In previous versions, we included configuration of [Unirest](https://kong.github.io/unirest-java/) client right in the Push Server client code. This was incorrect, since Unirest initializes in a static manner. Our configuration could be clashing with other components using Unirest. As a result, you need to add Unirest configuration yourself soon after the application launch in case you would like to use our client library. In the case you call our API's yourself, no changes are needed.

Below is a minimal Unirest configuration plugged into the Spring framework in a way to reuse `ObjectMapper` configuration. Of course, you can use any other [Unirest configuration parameters](https://kong.github.io/unirest-java/#configuration).

```java
@Configuration
public class UnirestConfiguration {

@Autowired
private com.fasterxml.jackson.databind.ObjectMapper mapper;

@PostConstruct
public void postConstruct() {
Unirest.config().setObjectMapper(new ObjectMapper() {

public String writeValue(Object value) {
try {
return mapper.writeValueAsString(value);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}

public <T> T readValue(String value, Class<T> valueType) {
try {
return mapper.readValue(value, valueType);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
}
}
```

## Push Server Administration

In the latest version of Push Server, we decided to remove the web administration console, due to its simplicity. You can configure apps either via database by inserting values to the `push_app_credentials` table, or by calling [Administration API](./Push-Server-API.md#administration). A new section regarding Push Server administration is [available in the documentation](./Push-Server-Administration.md).
63 changes: 31 additions & 32 deletions docs/Push-Server-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Following endpoints are published in PowerAuth Push Server RESTful API:

- `POST` [/push/device/create](#create-device) - Create new device registration
- `POST` [/push/device/create/multi](#create-device-for-multiple-associated-activations) - Create new device registration for multiple activations
- `POST` [/push/device/delete](#delete-device) - Remove registered device
- `POST` [/push/device/status/update](#update-device-status) - Update the status of the activation so that when activation associated with given device is not active, no notifications are sent to the device.
- `POST` / `DELETE` [/push/device/delete](#delete-device) - Remove registered device
- `POST` / `PUT` [/push/device/status/update](#update-device-status) - Update the status of the activation so that when activation associated with given device is not active, no notifications are sent to the device.

#### Sending Push Messages

Expand All @@ -43,11 +43,11 @@ Following endpoints are published in PowerAuth Push Server RESTful API:
#### Campaign Management

- `POST` [/push/campaign/create](#create-campaign) - Create new campaign
- `POST` [/push/campaign/${ID}/delete](#delete-campaign) - Delete specific campaign
- `POST` [/push/campaign/${ID}/user/delete](#delete-users-from-campaign) - Delete users from specific campaign
- `PUT` [/push/campaign/${ID}/user/add](#add-users-to-campaign) - Add users to specific campaign
- `POST` / `DELETE` [/push/campaign/${ID}/delete](#delete-campaign) - Delete specific campaign
- `POST` / `DELETE` [/push/campaign/${ID}/user/delete](#delete-users-from-campaign) - Delete users from specific campaign
- `POST` / `PUT` [/push/campaign/${ID}/user/add](#add-users-to-campaign) - Add users to specific campaign
- `GET` [/push/campaign/${ID}/detail](#get-campaign) - Return specific campaign
- `GET` [/push/campaign/list/?all={true|false}](#get-list-of-campaigns) - Return actual list of campaigns
- `GET` [/push/campaign/list?all={true,false}](#get-list-of-campaigns) - Return actual list of campaigns
- `GET` [/push/campaign/${ID}/user/list?page=${PAGE}&size=${SIZE}](#get-users-from-campaign) - Return paged list of users from specific campaign

#### Administration of Push Server
Expand All @@ -56,10 +56,10 @@ Following endpoints are published in PowerAuth Push Server RESTful API:
- `GET` [/admin/app/unconfigured/list](#list-unconfigured-applications) - List unconfigured applications
- `POST` [/admin/app/detail](#application-detail) - Get application detail
- `POST` [/admin/app/create](#create-application) - Create application
- `PUT` [/admin/ios/update](#update-ios-configuration) - Update iOS configuration
- `POST` [/admin/ios/remove](#remove-ios-configuration) - Remove iOS configuration
- `PUT` [/admin/android/update](#update-android-configuration) - Update Android configuration
- `POST` [/admin/android/remove](#remove-android-configuration) - Remove Android configuration
- `POST` / `PUT` [/admin/ios/update](#update-ios-configuration) - Update iOS configuration
- `POST` / `DELETE` [/admin/ios/remove](#remove-ios-configuration) - Remove iOS configuration
- `POST` / `PUT` [/admin/android/update](#update-android-configuration) - Update Android configuration
- `POST` / `DELETE` [/admin/android/remove](#remove-android-configuration) - Remove Android configuration

#### Service Status

Expand All @@ -69,11 +69,11 @@ Following endpoints are published in PowerAuth Push Server RESTful API:

PowerAuth Push Server uses following format for error response body, accompanied with an appropriate HTTP status code. Besides the HTTP error codes that application server may return regardless of server application (such as 404 when resource is not found or 503 when server is down), following status codes may be returned:

|`status`|`HTTP code` |Description|
|--- |--- |---|
|OK |200 |No issue|
|ERROR |400 |Issue with a request format, or issue of the business logic|
|ERROR |401 | Unauthorized, invalid security token configuration|
| Status | HTTP Code | Description |
|--------|-----------|-------------|
| OK | 200 | No issue |
| ERROR | 400 | Issue with a request format, or issue of the business logic |
| ERROR | 401 | Unauthorized, invalid security token configuration |

All error responses that are produced by the PowerAuth Push Server have following body:

Expand All @@ -88,8 +88,8 @@ All error responses that are produced by the PowerAuth Push Server have followin
}
```

- `status` - _OK_ | _ERROR_
- `code` - _ERROR_GENERIC_ | _ERROR_DATABASE_
- `status` - `OK`, `ERROR`
- `code` - `ERROR_GENERIC`, `ERROR_DATABASE`
- `message` - Message that describes certain error.

## Service
Expand Down Expand Up @@ -172,7 +172,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` - "_ios_ | _android_"
- `platform` - `ios`, `android`
- `activationId` - Activation identifier

#### **Response**
Expand Down Expand Up @@ -218,7 +218,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` - "_ios_ | _android_"
- `platform` - `ios`, `android`
- `activationIds` - Associated activation identifiers

#### **Response**
Expand All @@ -236,7 +236,7 @@ Removes registered device based on the push token value.
<table>
<tr>
<td>Method</td>
<td><code>POST</code></td>
<td><code>POST / DELETE</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand Down Expand Up @@ -273,7 +273,7 @@ Update the status of given device registration based on the associated activatio
<table>
<tr>
<td>Method</td>
<td><code>POST</code></td>
<td><code>POST / PUT</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand Down Expand Up @@ -438,7 +438,7 @@ Sends a message message batch - each item in the batch represents a message to g

```

- `appId` - Application that user/s is/are using.
- `appId` - Application that user is using.
- `batch` - List of messages, see [documentation for sending a single message](#send-message) for details

#### **Response**
Expand Down Expand Up @@ -546,7 +546,7 @@ Delete a specific campaign. Also users associated with this campaign are going t
<table>
<tr>
<td>Method</td>
<td><code>POST</code></td>
<td><code>POST / DELETE</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand All @@ -560,7 +560,6 @@ Delete a specific campaign. Also users associated with this campaign are going t

```json
{

}
```

Expand Down Expand Up @@ -704,7 +703,7 @@ Associate users to a specific campaign. Users are identified in request body as
<table>
<tr>
<td>Method</td>
<td><code>PUT</code></td>
<td><code>POST / PUT</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand All @@ -725,6 +724,7 @@ Associate users to a specific campaign. Users are identified in request body as
]
}
```

- list of users

#### **Response**
Expand Down Expand Up @@ -794,7 +794,7 @@ Delete users associated with a specific campaign. Users are identified request b
<table>
<tr>
<td>Method</td>
<td><code>POST</code></td>
<td><code>POST / DELETE</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand Down Expand Up @@ -843,7 +843,6 @@ Send message from a specific campaign on test user to check rightness of that ca
<td>Var ${ID} </td>
<td>Campaign identifier</td>
</tr>
</tr>
</table>

```json
Expand Down Expand Up @@ -1063,7 +1062,7 @@ Update an iOS configuration.
<table>
<tr>
<td>Method</td>
<td><code>PUT</code></td>
<td><code>POST / PUT</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand Down Expand Up @@ -1100,7 +1099,7 @@ Remove an iOS configuration.
<table>
<tr>
<td>Method</td>
<td><code>PUT</code></td>
<td><code>POST / DELETE</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand Down Expand Up @@ -1133,7 +1132,7 @@ Update an Android configuration.
<table>
<tr>
<td>Method</td>
<td><code>PUT</code></td>
<td><code>POST / PUT</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand Down Expand Up @@ -1166,7 +1165,7 @@ Update an Android configuration.
<table>
<tr>
<td>Method</td>
<td><code>POST</code></td>
<td><code>POST / DELETE</code></td>
</tr>
<tr>
<td>Resource URI</td>
Expand All @@ -1188,4 +1187,4 @@ Update an Android configuration.
{
"status": "OK"
}
```
```
144 changes: 144 additions & 0 deletions docs/Push-Server-Administration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Push Server Administration

PowerAuth Push Server can be administered using a RESTful API.

The RESTful API is documented in [a dedicated chapter](./Push-Server-API.md).

## Administration using Insomnia

Insomnia is an easy to use RESTful API client. You can get Insomnia from [https://insomnia.rest](https://insomnia.rest)

To import the Push Server workspace into Insomnia, create a workspace using menu in the top left corner. Use the `Create Workspace` option and
then click `Import/Export`. You can import the workspace with all requests from [provided workspace export file](./data/Push_Server_Insomnia.zip).

All requests which are described below are already prepared in the provided Insomnia worskpace, so you can easily
update the JSON requests and execute them.

## Administration using cURL

Curl is a command line HTTP client. You can get cURL from [https://curl.haxx.se](https://curl.haxx.se)

### Retrieve Application List:
```
curl --request GET \
--url http://localhost:8080/powerauth-push-server/admin/app/list
```

### Retrieve Unconfigured Application List:
```
curl --request GET \
--url http://localhost:8080/powerauth-push-server/admin/app/unconfigured/list
```

### Create an Application:
```
curl --request POST \
--url http://localhost:8080/powerauth-push-server/admin/app/create \
--header 'content-type: application/json' \
--data '{
"requestObject": {
"appId": 1
}
}'
```

Update the `appId` value with requested PowerAuth application ID.
The value `id` from response object will be used for identification of the Push Server application.

### Get Application Detail:
```
curl --request POST \
--url http://localhost:8080/powerauth-push-server/admin/app/detail \
--header 'content-type: application/json' \
--data '{
"requestObject": {
"id": 1,
"includeIos": true,
"includeAndroid": true
}
}'
```

Update the `id` value with requested Push Server application ID.

### Update APNs Configuration
```
curl --request POST \
--url http://localhost:8080/powerauth-push-server/admin/app/ios/update \
--header 'content-type: application/json' \
--data '{
"requestObject": {
"id": 1,
"bundle": "com.wultra.myApp",
"keyId": "keyId",
"teamId": "teamId",
"privateKeyBase64": "a2V5"
}
}'
```

Set the `id` value for Push Server application ID to want to update.

Enter the base64-encoded value of APNs private key into `privateKeyBase64`.

You can encode the file using `base64` command on Mac. You can also use `Certutil.exe` on Windows or OpenSSL on all platforms.
```
base64 -i <in-file> -o <outfile>
```

### Remove APNs Configuration
```
curl --request DELETE \
--url http://localhost:8080/powerauth-push-server/admin/app/ios/remove \
--cookie JSESSIONID=76D3CE8C7F92E1FC090A79886E43B235 \
--data '{
"requestObject": {
"id": 1
}
}'
```

Set the `id` value for the Push Server application ID you want to update.

### Update FCM Configuration
```
curl --request POST \
--url http://localhost:8080/powerauth-push-server/admin/app/android/update \
--header 'content-type: application/json' \
--data '{
"requestObject": {
"id": 1,
"projectId": "projectId",
"privateKeyBase64": "a2V5"
}
}'
```

Set the `id` value for Push Server application ID to want to update.

Enter the base64-encoded value of APNs private key into `privateKeyBase64`.

You can encode the file using `base64` command on Mac. You can also use `Certutil.exe` on Windows or OpenSSL on all platforms.
```
base64 -i <in-file> -o <outfile>
```

### Remove FCM Configuration
```
curl --request DELETE \
--url http://localhost:8080/powerauth-push-server/admin/app/android/remove \
--header 'content-type: application/json' \
--data '{
"requestObject": {
"id": 1
}
}'
```

Set the `id` value for the Push Server application ID you want to update.

## Administration using SQL Database

Push server can be also administered by updating the `push_app_credentials` table.

See the [PowerAuth Push Server Database Structure](./Push-Server-Database.md) for more details.
Loading

0 comments on commit 4906344

Please sign in to comment.