Skip to content

Commit

Permalink
Spring Boot Admin Integration (#3018)
Browse files Browse the repository at this point in the history
* initial commit

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* add httpclient versions

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* use jakarta packages

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* adapt spring security

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix mail client

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* disable odata module for now

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* more adaptations

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* disable odata

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* more adaptations

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* use newer interface

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* minor fixes

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* remove plugin versions

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix EncryptionBeanPostProcessor

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* remove dep versions

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* disable odata

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* camel 3.21.2

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix activemq dependencies version

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* adapt Camel

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* adapt tests

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* add synchronized

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* dummy KeycloakSecurityConfiguration

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix integration tests

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix javadoc plugin issue

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* use migrated olingo dependency
Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* Update README.md

* fix startup errors

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* centralized plugins management

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* maven compiler plugin centralized config

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* maven-compiler-plugin in parent

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* centralized formatter-maven-plugin

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* set fixed plugins version

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* improve logging

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* use olingo from the codbex fork repo

https://github.com/codbex/olingo-odata2

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix javadoc error

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* integration tests on ubuntu as well

* Update pull-request.yml

* remove provided scopes

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* add keycloak conifugations

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* rebase

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* remove dependencyManagement

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix javadoc generation

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* native images support

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix OData

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* javax replacements

javax.annotation.Nullable
javax.xml.soap
javax.servlet

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* pom cleanup

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix cxf conflict

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* Spring Boot Admin Integration

* adapt to the changes from master

integration-tests -> tests

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* install Spring Boot Admin using profile

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* exclude SpringBootAdminIT from the tests by default

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* add spring boot job to workflows

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* adapt SpringBootAdminIT

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix spring boot admin profile

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix spring boot itests

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix spring admin versions

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix merge issues

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix more merge issues

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* remove versions

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* rename role

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* protect actuator endpoints

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix integration tests execution

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* clean context after SecurityIT

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* @DirtiesContext on parent level

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

* fix merge issues

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>

---------

Signed-off-by: Iliyan Velichkov <velichkov.iliyan@gmail.com>
  • Loading branch information
iliyan-velichkov authored Dec 22, 2023
1 parent 02631c8 commit 9ec4efa
Show file tree
Hide file tree
Showing 21 changed files with 418 additions and 19 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ jobs:
run: npm i -g typescript
- name: Maven Build
run: mvn -T 1C clean install -D maven.test.skip=true -D skipTests -D maven.javadoc.skip=true -D license.skip=true -U
- if: runner.os == 'Windows'
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
- name: Integration tests
run: mvn -f tests/pom.xml verify -P integration-tests
- name: Upload selenide screenshots
Expand All @@ -94,3 +96,58 @@ jobs:
retention-days: 1
name: selenide-screenshots
path: tests/build/reports/tests

integration-tests-spring-boot:
runs-on: ${{ matrix.os }}-latest
continue-on-error: true
strategy:
matrix:
os: [windows]
steps:
- name: Setup Chrome
uses: browser-actions/setup-chrome@v1.3.0
with:
chrome-version: stable
- if: runner.os == 'Linux'
run: chrome --version
- if: runner.os == 'macOS'
run: chromium --version
- if: runner.os == 'Windows'
run: (Get-Item (Get-Command chrome).Source).VersionInfo.ProductVersion
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up JDK Corretto 21
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '21'
architecture: x64
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install esbuild
run: npm i -g esbuild
- name: Install TypeScript compiler
run: npm i -g typescript
- name: Maven Build
run: mvn -T 1C clean install -P spring-boot-admin -D maven.test.skip=true -D skipTests -D maven.javadoc.skip=true -D license.skip=true -U
- if: runner.os == 'Windows'
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
- name: Integration tests
run: mvn -f tests/pom.xml verify -P integration-tests-spring-boot-admin -D spring.profiles.active=spring-boot-admin
- name: Upload selenide screenshots
uses: actions/upload-artifact@v3.1.3
if: always()
with:
retention-days: 1
name: selenide-screenshots-spring-boot
path: tests/build/reports/tests

55 changes: 55 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ jobs:
run: npm i -g typescript
- name: Maven Build
run: mvn -T 1C clean install -D maven.test.skip=true -D skipTests -D maven.javadoc.skip=true -D license.skip=true -U
- if: runner.os == 'Windows'
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
- name: Integration tests
run: mvn -f tests/pom.xml verify -P integration-tests
- name: Upload selenide screenshots
Expand All @@ -92,3 +94,56 @@ jobs:
retention-days: 1
name: selenide-screenshots
path: tests/build/reports/tests

integration-tests-spring-boot:
runs-on: ${{ matrix.os }}-latest
continue-on-error: true
strategy:
matrix:
os: [windows]
steps:
- name: Setup Chrome
uses: browser-actions/setup-chrome@v1.3.0
with:
chrome-version: stable
- if: runner.os == 'Linux'
run: chrome --version
- if: runner.os == 'macOS'
run: chromium --version
- if: runner.os == 'Windows'
run: (Get-Item (Get-Command chrome).Source).VersionInfo.ProductVersion
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Set up JDK Corretto 21
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 21
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install esbuild
run: npm i -g esbuild
- name: Install TypeScript compiler
run: npm i -g typescript
- name: Maven Build
run: mvn -T 1C clean install -P spring-boot-admin -D maven.test.skip=true -D skipTests -D maven.javadoc.skip=true -D license.skip=true -U
- if: runner.os == 'Windows'
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
- name: Integration tests
run: mvn -f tests/pom.xml verify -P integration-tests-spring-boot-admin -D spring.profiles.active=spring-boot-admin
- name: Upload selenide screenshots
uses: actions/upload-artifact@v3.1.3
if: always()
with:
retention-days: 1
name: selenide-screenshots-spring-boot
path: tests/build/reports/tests
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ The project started as an internal SAP initiative to address the extension and a
- [Run](#run)
- [Standalone](#standalone)
- [Docker](#docker)
- [Native image](#native-image)
- [Code formatting](#code-formatting)
- [Native image](#native-image)
- [Code formatting](#code-formatting)
- [Spring Boot Admin](#spring-boot-admin)
- [Additional Information](#additional-information)
- [License](#license)
- [Contributors](#contributors)
Expand Down Expand Up @@ -258,6 +259,15 @@ To format the code using Maven execute the following in the root dir of the proj

mvn formatter:format

### Spring Boot Admin
If you want to enable [Spring Boot Admin](https://docs.spring-boot-admin.com/current/) for the Dirigible project, you need to build the project with maven profile `spring-boot-admin` and then activate spring profile `spring-boot-admin`.
To do this, you have to execute the following commands:
```
mvn -T 1C clean install -P spring-boot-admin -D maven.test.skip=true -D skipTests -D maven.javadoc.skip=true -D license.skip=true
java -jar -Dspring.profiles.active=spring-boot-admin build/application/target/dirigible-application-*-executable.jar
```

## Additional Information

### License
Expand Down
32 changes: 31 additions & 1 deletion build/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring.admin.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down Expand Up @@ -290,4 +296,28 @@
<parent.pom.folder>../../</parent.pom.folder>
</properties>

</project>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>spring-boot-admin</id>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring.admin.version}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring.admin.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
import de.codecentric.boot.admin.server.config.EnableAdminServer;

@EnableAdminServer
@EnableJpaAuditing
@EnableJpaRepositories
@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
spring.boot.admin.context-path=spring-admin
spring.boot.admin.ui.title=${spring.application.name} Admin
spring.boot.admin.ui.brand=<img src="/services/web/resources/images/dirigible.svg"><span>Eclipse Dirigible Admin</span>

spring.boot.admin.client.url=http://localhost:${server.port}/spring-admin
spring.boot.admin.client.username=${DIRIGIBLE_SPRING_ADMIN_USERNAME:admin}
spring.boot.admin.client.password=${DIRIGIBLE_SPRING_ADMIN_PASSWORD:admin}
spring.boot.admin.client.instance.metadata.user.name=${spring.boot.admin.client.username}
spring.boot.admin.client.instance.metadata.user.password=${spring.boot.admin.client.password}
8 changes: 8 additions & 0 deletions build/application/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
spring.application.name=Eclipse Dirigible

spring.main.allow-bean-definition-overriding=true

server.error.include-message=always
server.port=8080

spring.servlet.multipart.enabled=true
spring.servlet.multipart.file-size-threshold=2KB
Expand All @@ -20,4 +24,8 @@ management.metrics.mongo.connectionpool.enabled=false
spring.devtools.restart.poll-interval=6s
spring.devtools.restart.quiet-period=5s

management.endpoints.web.exposure.include=camelroutes,mappings,caches,configprops,camelroutes,metrics,threaddump,heapdump,loggers,health,quartz,scheduledtasks,env,beans,conditions,info
management.endpoints.health.show-details=always

cxf.path=/odata/v2

4 changes: 3 additions & 1 deletion build/application/src/main/resources/dirigible.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ DIRIGIBLE_DATABASE_PROVIDER=local
DIRIGIBLE_JAVASCRIPT_HANDLER_CLASS_NAME=org.eclipse.dirigible.graalium.handler.GraaliumJavascriptHandler
DIRIGIBLE_GRAALIUM_ENABLE_DEBUG=true
DIRIGIBLE_HOME_URL=services/web/ide/
DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE=true
DIRIGIBLE_DATABASE_NAMES_CASE_SENSITIVE=true
DIRIGIBLE_SPRING_ADMIN_USERNAME=admin
DIRIGIBLE_SPRING_ADMIN_PASSWORD=admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 SAP SE or an SAP affiliate company and Eclipse Dirigible contributors
*
* All rights reserved. This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Eclipse Dirigible
* contributors SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.dirigible.components.base.http.access;

public enum DirigibleRole {

DEVELOPER(RoleNames.DEVELOPER), OPERATOR(RoleNames.OPERATOR);

private final String roleName;

DirigibleRole(String roleName) {
this.roleName = roleName;
}

public String getName() {
return roleName;
}

@SuppressWarnings("hiding")
public static class RoleNames {
public static final String OPERATOR = "Operator";
public static final String DEVELOPER = "Developer";

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class HttpSecurityURIConfigurator {
"/services/js/resources-core/**", //
"/services/js/resources-core/**", //
"/services/integrations/**", //
"/actuator/**"};
"/actuator/health"};

private static final String[] AUTHENTICATED_PATTERNS = {//
"/services/**", //
Expand All @@ -51,6 +51,10 @@ public class HttpSecurityURIConfigurator {
"/services/ide/**", //
"/websockets/ide/**"};

private static final String[] OPERATOR_PATTERNS = {//
"/spring-admin/**", //
"/actuator/**"};

/**
* Configure.
*
Expand All @@ -68,7 +72,11 @@ public static void configure(HttpSecurity http) throws Exception {

// "Developer" role required
.requestMatchers(DEVELOPER_PATTERNS)
.hasRole("Developer")
.hasRole(DirigibleRole.DEVELOPER.getName())

// Spring Boot Admin
.requestMatchers(OPERATOR_PATTERNS)
.hasRole(DirigibleRole.OPERATOR.getName())

// Deny all other requests
.anyRequest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import org.apache.commons.codec.binary.Base64;
import org.eclipse.dirigible.components.base.http.access.DirigibleRole;
import org.eclipse.dirigible.components.base.http.access.HttpSecurityURIConfigurator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -51,7 +52,7 @@ InMemoryUserDetailsManager userDetailsService() {
String password = org.eclipse.dirigible.commons.config.Configuration.get("DIRIGIBLE_BASIC_PASSWORD", "YWRtaW4="); // admin
UserDetails user = User.withUsername(new String(new Base64().decode(username.getBytes()), StandardCharsets.UTF_8).trim())
.password("{noop}" + new String(new Base64().decode(password.getBytes()), StandardCharsets.UTF_8).trim())
.roles("DEVELOPER", "OPERATOR")
.roles(DirigibleRole.DEVELOPER.getName(), DirigibleRole.OPERATOR.getName())
.build();
return new InMemoryUserDetailsManager(user);
}
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
<license-maven-plugin.version>4.3</license-maven-plugin.version>

<spring.boot.version>3.2.0</spring.boot.version>
<spring.admin.version>3.1.8</spring.admin.version>

<org.springdoc.openapi.ui.version>1.7.0</org.springdoc.openapi.ui.version>
<c3p0.version>0.9.5.5</c3p0.version>
<graalvm.version>23.1.1</graalvm.version>
Expand Down Expand Up @@ -699,5 +701,4 @@
</dependency>
</dependencies>
</dependencyManagement>

</project>
</project>
Loading

0 comments on commit 9ec4efa

Please sign in to comment.