Skip to content

Commit

Permalink
Merge pull request #720 from wultra/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
banterCZ authored Jan 5, 2024
2 parents 6ab6b78 + c8ecf6d commit 6083c06
Show file tree
Hide file tree
Showing 24 changed files with 382 additions and 98 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/scp-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run SCP deploy

on:
workflow_dispatch:

jobs:
scp-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
server-id: jfrog-central
server-username: INTERNAL_USERNAME
server-password: INTERNAL_PASSWORD
cache: maven
- name: Run Maven Package Step
run: |
mvn -B -U package -Dmaven.test.skip=true
env:
INTERNAL_USERNAME: ${{ secrets.JFROG_USERNAME }}
INTERNAL_PASSWORD: ${{ secrets.JFROG_PASSWORD }}
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SCP_CERTIFICATE }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -t rsa ${{ secrets.SCP_HOST }} >> ~/.ssh/known_hosts
- name: Deploy powerauth-push-server.war
shell: bash
run: |
scp -i ~/.ssh/id_rsa **/target/powerauth-push-server-*.war ${{ secrets.SCP_USERNAME }}@${{ secrets.SCP_HOST }}:/opt/apache-tomcat/webapps/powerauth-push-server.war
1 change: 0 additions & 1 deletion docs-private/Developer-How-To-Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

### Standalone Run

- Enable maven profile `standalone`
- Use IntelliJ Idea run configuration at `../.run/PowerAuthPushServerJavaApplication.run.xml`
- Open [http://localhost:8089/powerauth-push-server/actuator/health](http://localhost:8089/powerauth-push-server/actuator/health) and you should get `{"status":"UP"}`

Expand Down
8 changes: 7 additions & 1 deletion docs/Configuration-Properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ The Push Server uses the following public configuration properties:
| `powerauth.service.correlation-header.enabled` | `false` | Whether correlation header is enabled |
| `powerauth.service.correlation-header.name` | `X-Correlation-ID` | Correlation header name |
| `powerauth.service.correlation-header.value.validation-regexp` | `[a-zA-Z0-9\\-]{8,1024}` | Regular expression for correlation header value validation |
| `logging.pattern.console` | [See application.properties](https://github.com/wultra/powerauth-push-server/blob/develop/powerauth-push-server/src/main/resources/application.properties#docucheck-keep-link) | Logging pattern for console which includes the correlation header value |
| `logging.pattern.console` | [See application.properties](https://github.com/wultra/powerauth-push-server/blob/develop/powerauth-push-server/src/main/resources/application.properties#docucheck-keep-link) | Logging pattern for console which includes the correlation header value |


## Monitoring and Observability

The WAR file includes the `micrometer-registry-prometheus` dependency.
Discuss its configuration with the [Spring Boot documentation](https://docs.spring.io/spring-boot/docs/3.1.x/reference/html/actuator.html#actuator.metrics).
1 change: 1 addition & 0 deletions docs/Migration-Instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

This page contains PowerAuth Push Server migration instructions.

- [PowerAuth Push Server 1.6.0](./PowerAuth-Push-Server-1.6.0.md)
- [PowerAuth Push Server 1.5.0](./PowerAuth-Push-Server-1.5.0.md)
- [PowerAuth Push Server 1.4.0](./PowerAuth-Push-Server-1.4.0.md)
- [PowerAuth Push Server 1.3.0](./PowerAuth-Push-Server-1.3.0.md)
Expand Down
5 changes: 5 additions & 0 deletions docs/PowerAuth-Push-Server-1.6.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Migration from 1.5.x to 1.6.x

This guide contains instructions for migration from PowerAuth Push Server version `1.5.x` to version `1.6.x`.

No migration steps nor database changes are required.
22 changes: 12 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

<groupId>io.getlime.security</groupId>
<artifactId>powerauth-push-server-parent</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
<packaging>pom</packaging>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.3</version>
<version>3.1.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -69,21 +69,23 @@

<properties>
<!-- Wultra Dependencies -->
<wultra-core.version>1.7.0</wultra-core.version>
<powerauth.version>1.5.0</powerauth.version>
<powerauth-crypto.version>1.5.1</powerauth-crypto.version>
<powerauth-restful-integration.version>1.5.0</powerauth-restful-integration.version>
<wultra-core.version>1.8.0</wultra-core.version>
<powerauth.version>1.6.0</powerauth.version>
<powerauth-crypto.version>1.6.0</powerauth-crypto.version>
<powerauth-restful-integration.version>1.6.0</powerauth-restful-integration.version>

<!-- Library Versions -->
<pushy.version>0.15.2</pushy.version>
<pushy.version>0.15.3</pushy.version>
<google-api-client.version>1.35.2</google-api-client.version>
<firebase-admin.version>9.2.0</firebase-admin.version>
<bc.version>1.76</bc.version>
<bc.version>1.77</bc.version>
<logstash.version>7.4</logstash.version>
<!-- TODO (racansky, 2023-12-08) temporarily override the version 1.4.11 from spring boot version because of CVE -->
<logback.version>1.4.14</logback.version>

<!-- Documentation Dependencies -->
<springdoc-openapi-starter-webmvc-ui.version>2.2.0</springdoc-openapi-starter-webmvc-ui.version>
<swagger-annotations-jakarta.version>2.2.15</swagger-annotations-jakarta.version>
<springdoc-openapi-starter-webmvc-ui.version>2.3.0</springdoc-openapi-starter-webmvc-ui.version>
<swagger-annotations-jakarta.version>2.2.20</swagger-annotations-jakarta.version>

<maven-javadoc-plugin.version>3.5.0</maven-javadoc-plugin.version>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion powerauth-push-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<artifactId>powerauth-push-server-parent</artifactId>
<groupId>io.getlime.security</groupId>
<version>1.5.0</version>
<version>1.6.0</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion powerauth-push-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<artifactId>powerauth-push-server-parent</artifactId>
<groupId>io.getlime.security</groupId>
<version>1.5.0</version>
<version>1.6.0</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.getlime.push.model.base;

import io.getlime.core.rest.model.base.response.ObjectResponse;
import lombok.EqualsAndHashCode;

/**
* Generic response class for paged results
Expand All @@ -25,6 +26,7 @@
*
* @param <T> Type of the paged records.
*/
@EqualsAndHashCode(callSuper = true)
public class PagedResponse<T> extends ObjectResponse<T> {

private int page;
Expand Down
52 changes: 22 additions & 30 deletions powerauth-push-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,24 @@
<parent>
<groupId>io.getlime.security</groupId>
<artifactId>powerauth-push-server-parent</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
</parent>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<!-- Spring Dependencies -->
Expand All @@ -30,12 +45,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -48,12 +57,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -115,6 +118,12 @@
<artifactId>postgresql</artifactId>
</dependency>

<!-- Monitoring -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

<!-- Logging -->
<dependency>
<groupId>net.logstash.logback</groupId>
Expand Down Expand Up @@ -175,11 +184,6 @@
<version>${bc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>test</scope>
</dependency>

<!-- Documentation -->
<dependency>
Expand Down Expand Up @@ -241,18 +245,6 @@
</plugins>
</build>
</profile>

<profile>
<id>standalone</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>

<profile>
<id>liquibase</id>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.servers.Server;
import jakarta.servlet.ServletContext;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
* Swagger configuration class for api documentation
*
Expand Down Expand Up @@ -63,4 +68,13 @@ public GroupedOpenApi pushApiGroup() {
.build();
}

@Bean
public OpenAPI openAPI(final ServletContext servletContext) {
final Server server = new Server()
.url(servletContext.getContextPath())
.description("Default Server URL");
return new OpenAPI()
.servers(List.of(server));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class PushCampaignEntity implements Serializable {
/**
* Message.
*/
@Column(name = "message", nullable = false, updatable = false)
@Column(name = "message", nullable = false, updatable = false, length = 4000)
private String message;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2023 Wultra s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.getlime.push.service;

import com.eatthepath.pushy.apns.util.ApnsPayloadBuilder;
import com.eatthepath.pushy.apns.util.SimpleApnsPayloadBuilder;
import io.getlime.push.model.entity.PushMessageBody;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
* Convert {@link PushMessageBody} to platform dependant payload.
*
* @author Lubos Racansky, [email protected]
*/
@Slf4j
final class PayloadBuilder {

private PayloadBuilder() {
throw new IllegalStateException("Should not be instantiated.");
}

/**
* Method to build APNs message payload.
*
* @param push Push message object with APNs data.
* @param isSilent Indicates if the message is silent or not.
* @return String with APNs JSON payload.
*/
static String buildApnsPayload(final PushMessageBody push, final boolean isSilent) {
final ApnsPayloadBuilder payloadBuilder = new SimpleApnsPayloadBuilder();
if (!isSilent) { // include alert, body, sound and category only in case push message is not silent.
payloadBuilder
.setAlertTitle(push.getTitle())
.setLocalizedAlertTitle(push.getTitleLocKey(), push.getTitleLocArgs())
.setAlertBody(push.getBody())
.setLocalizedAlertMessage(push.getBodyLocKey(), push.getBodyLocArgs())
.setSound(push.getSound())
.setCategoryName(push.getCategory());
}

payloadBuilder
.setBadgeNumber(push.getBadge())
.setContentAvailable(isSilent)
.setThreadId(push.getCollapseKey());

final Map<String, Object> extras = push.getExtras();
if (extras != null) {
for (Map.Entry<String, Object> entry : extras.entrySet()) {
if (entry.getValue() != null) {
payloadBuilder.addCustomProperty(entry.getKey(), entry.getValue());
} else {
// Workaround for a known Apple issue, the JSON is valid but APNS would not send the push message.
logger.debug("Skipping extras key: {} because of null value.", entry.getKey());
}
}
}

return payloadBuilder.build();
}
}
Loading

0 comments on commit 6083c06

Please sign in to comment.