Compare commits
No commits in common. "main" and "cf-0.28.4" have entirely different histories.
@ -1,5 +1,4 @@
|
|||||||
CLOUDFLARE_ACCOUNT_ID="<cloudflare account id>"
|
CLOUDFLARE_ACCOUNT_ID="<cloudflare account id>"
|
||||||
CLOUDFLARE_API_KEY="<cloudflare account key>"
|
CLOUDFLARE_API_KEY="<cloudflare account key>"
|
||||||
CLOUDFLARE_EMAIL="<cloudflare email>"
|
CLOUDFLARE_EMAIL="<cloudflare email>"
|
||||||
ENV="<deployment env>"
|
ENV="<deployment env>"
|
||||||
MGMT_PORT="5003"
|
|
||||||
@ -9,5 +9,4 @@ RUN ./gradlew :cftunnels-service:bootJar
|
|||||||
|
|
||||||
FROM openjdk:17-jdk-slim
|
FROM openjdk:17-jdk-slim
|
||||||
COPY --from=build /app/cftunnels-service/build/libs/*.jar app.jar
|
COPY --from=build /app/cftunnels-service/build/libs/*.jar app.jar
|
||||||
EXPOSE 8080 8081
|
|
||||||
ENTRYPOINT ["java", "-jar", "/app.jar"]
|
ENTRYPOINT ["java", "-jar", "/app.jar"]
|
||||||
|
|||||||
@ -7,7 +7,6 @@ dependencies {
|
|||||||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
|
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
|
||||||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.5'
|
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.5'
|
||||||
implementation 'org.hibernate.validator:hibernate-validator'
|
implementation 'org.hibernate.validator:hibernate-validator'
|
||||||
|
|
||||||
|
|||||||
@ -1,39 +0,0 @@
|
|||||||
package com.hithomelabs.cftunnels.Config.Security;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.core.annotation.Order;
|
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Security configuration for Spring Boot Actuator endpoints.
|
|
||||||
*
|
|
||||||
* This configuration permits unauthenticated access to /actuator/health and /actuator/info
|
|
||||||
* endpoints, enabling health monitoring by Uptime Kuma without requiring OIDC authentication.
|
|
||||||
* All other actuator endpoints remain protected and require authentication.
|
|
||||||
*
|
|
||||||
* Uses @Order(Ordered.HIGHEST_PRECEDENCE) to ensure this filter chain is evaluated BEFORE
|
|
||||||
* any auto-configured management security filter chains (e.g., ManagementWebSecurityAutoConfiguration).
|
|
||||||
* Without this, the catch-all SecurityFilterChain in SecuirtyConfig can intercept actuator
|
|
||||||
* requests on the separate management port (management.server.port=8081) and redirect to OIDC login.
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
||||||
public class ActuatorSecurityConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public SecurityFilterChain actuatorSecurityChain(HttpSecurity http) throws Exception {
|
|
||||||
http
|
|
||||||
.securityMatcher(EndpointRequest.toAnyEndpoint())
|
|
||||||
.authorizeHttpRequests(auth -> auth
|
|
||||||
.requestMatchers("/actuator/health", "/actuator/info").permitAll()
|
|
||||||
.anyRequest().authenticated()
|
|
||||||
)
|
|
||||||
.csrf(csrf -> csrf.disable());
|
|
||||||
|
|
||||||
return http.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -29,7 +29,6 @@ public class SecuirtyConfig {
|
|||||||
http
|
http
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
//.requestMatchers( "/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html" ).permitAll()
|
//.requestMatchers( "/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html" ).permitAll()
|
||||||
.requestMatchers("/actuator/health", "/actuator/info").permitAll()
|
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
).csrf(csrf -> csrf.disable())
|
).csrf(csrf -> csrf.disable())
|
||||||
.with(new OAuth2LoginConfigurer<>(),
|
.with(new OAuth2LoginConfigurer<>(),
|
||||||
|
|||||||
@ -4,8 +4,4 @@ spring.datasource.url=jdbc:h2:mem:testdb
|
|||||||
spring.datasource.driver-class-name=org.h2.Driver
|
spring.datasource.driver-class-name=org.h2.Driver
|
||||||
spring.datasource.username=sa
|
spring.datasource.username=sa
|
||||||
spring.datasource.password=
|
spring.datasource.password=
|
||||||
spring.jpa.hibernate.ddl-auto=none
|
spring.jpa.hibernate.ddl-auto=none
|
||||||
|
|
||||||
# Actuator configuration for CI
|
|
||||||
management.endpoints.web.exposure.include=health,info
|
|
||||||
management.endpoint.health.show-details=never
|
|
||||||
@ -1,10 +1,8 @@
|
|||||||
api.baseUrl=http://localhost:8080
|
api.baseUrl=http://localhost:8080
|
||||||
|
|
||||||
# Actuator configuration for local development
|
|
||||||
management.server.port=8081
|
|
||||||
management.endpoints.web.exposure.include=health,info
|
|
||||||
management.endpoint.health.show-details=always
|
|
||||||
management.health.db.enabled=true
|
management.health.db.enabled=true
|
||||||
|
management.endpoints.web.exposure.include=health
|
||||||
|
management.endpoint.health.show-details=always
|
||||||
|
|
||||||
logging.level.org.hibernate.SQL=DEBUG
|
logging.level.org.hibernate.SQL=DEBUG
|
||||||
debug=true
|
debug=true
|
||||||
|
|||||||
@ -9,8 +9,4 @@ spring.datasource.driver-class-name=org.postgresql.Driver
|
|||||||
# JPA Configuration
|
# JPA Configuration
|
||||||
spring.jpa.hibernate.ddl-auto=create-drop
|
spring.jpa.hibernate.ddl-auto=create-drop
|
||||||
spring.jpa.show-sql=false
|
spring.jpa.show-sql=false
|
||||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
|
||||||
# Actuator configuration
|
|
||||||
management.endpoints.web.exposure.include=health,info
|
|
||||||
management.endpoint.health.show-details=when-authorized
|
|
||||||
@ -10,7 +10,3 @@ spring.datasource.driver-class-name=org.postgresql.Driver
|
|||||||
spring.jpa.hibernate.ddl-auto=update
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
spring.jpa.show-sql=true
|
spring.jpa.show-sql=true
|
||||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
|
||||||
# Actuator configuration
|
|
||||||
management.endpoints.web.exposure.include=health,info
|
|
||||||
management.endpoint.health.show-details=when-authorized
|
|
||||||
|
|||||||
@ -35,9 +35,4 @@ spring.jpa.hibernate.ddl-auto=update
|
|||||||
spring.jpa.show-sql=true
|
spring.jpa.show-sql=true
|
||||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
|
||||||
spring.jpa.open-in-view=false
|
spring.jpa.open-in-view=false
|
||||||
|
|
||||||
# Actuator configuration - management port and exposed endpoints
|
|
||||||
management.server.port=8081
|
|
||||||
management.endpoints.web.exposure.include=health,info
|
|
||||||
management.endpoint.health.show-details=when-authorized
|
|
||||||
@ -4,7 +4,6 @@ services:
|
|||||||
container_name: cftunnels_${ENV}
|
container_name: cftunnels_${ENV}
|
||||||
ports:
|
ports:
|
||||||
- ${HOST_PORT}:8080
|
- ${HOST_PORT}:8080
|
||||||
- ${MGMT_PORT:-5003}:8081
|
|
||||||
environment:
|
environment:
|
||||||
- CLOUDFLARE_ACCOUNT_ID=${CLOUDFLARE_ACCOUNT_ID}
|
- CLOUDFLARE_ACCOUNT_ID=${CLOUDFLARE_ACCOUNT_ID}
|
||||||
- CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
|
- CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
|
||||||
|
|||||||
@ -36,6 +36,3 @@ ENV=dev
|
|||||||
|
|
||||||
# Host port to map to container port 8081
|
# Host port to map to container port 8081
|
||||||
HOST_PORT=8081
|
HOST_PORT=8081
|
||||||
|
|
||||||
# Host port to map to actuator management port 8082 (health checks, LAN only)
|
|
||||||
MGMT_PORT=5005
|
|
||||||
|
|||||||
@ -9,5 +9,4 @@ RUN ./gradlew :portainer-automation:bootJar
|
|||||||
|
|
||||||
FROM openjdk:17-jdk-slim
|
FROM openjdk:17-jdk-slim
|
||||||
COPY --from=build /app/portainer-automation/build/libs/*.jar app.jar
|
COPY --from=build /app/portainer-automation/build/libs/*.jar app.jar
|
||||||
EXPOSE 8081 8082
|
|
||||||
ENTRYPOINT ["java", "-jar", "/app.jar"]
|
ENTRYPOINT ["java", "-jar", "/app.jar"]
|
||||||
|
|||||||
@ -5,7 +5,6 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
|
||||||
implementation 'org.apache.httpcomponents.client5:httpclient5'
|
implementation 'org.apache.httpcomponents.client5:httpclient5'
|
||||||
|
|
||||||
compileOnly 'org.projectlombok:lombok'
|
compileOnly 'org.projectlombok:lombok'
|
||||||
|
|||||||
@ -3,8 +3,7 @@ services:
|
|||||||
image: gitea.hithomelabs.com/hithomelabs/portainer-automation:${ENV:-test}
|
image: gitea.hithomelabs.com/hithomelabs/portainer-automation:${ENV:-test}
|
||||||
container_name: portainer-automation_${ENV:-test}
|
container_name: portainer-automation_${ENV:-test}
|
||||||
ports:
|
ports:
|
||||||
- "${HOST_PORT:-8081}:8081" # Application port (internal service)
|
- "${HOST_PORT:-8081}:8081"
|
||||||
- "${MGMT_PORT:-5005}:8082" # Health management port (LAN only)
|
|
||||||
environment:
|
environment:
|
||||||
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-local}
|
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE:-local}
|
||||||
- PORTAINER_API_KEY=${PORTAINER_API_KEY}
|
- PORTAINER_API_KEY=${PORTAINER_API_KEY}
|
||||||
|
|||||||
@ -22,11 +22,12 @@ import java.security.cert.X509Certificate;
|
|||||||
public class PortainerClientConfig {
|
public class PortainerClientConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a RestTemplate that trusts all SSL certificates.
|
* Trust-all SSL RestTemplate for the "local" profile.
|
||||||
* Used when connecting via Cloudflare Tunnel (self-signed certs)
|
* Used when connecting via Cloudflare Tunnel (self-signed certs).
|
||||||
* or to the prod Portainer instance (also self-signed).
|
|
||||||
*/
|
*/
|
||||||
private static RestTemplate buildTrustAllRestTemplate() throws Exception {
|
@Profile("local")
|
||||||
|
@Bean(name = "portainerRestTemplate")
|
||||||
|
public RestTemplate portainerRestTemplateLocal() throws Exception {
|
||||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||||
new X509TrustManager() {
|
new X509TrustManager() {
|
||||||
public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; }
|
public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; }
|
||||||
@ -46,32 +47,12 @@ public class PortainerClientConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trust-all SSL RestTemplate for the "local" profile.
|
* Standard validating SSL RestTemplate for non-local profiles
|
||||||
* Used when connecting via Cloudflare Tunnel (self-signed certs).
|
* (CI, test, prod — internal Docker network).
|
||||||
*/
|
*/
|
||||||
@Profile("local")
|
@Profile("!local")
|
||||||
@Bean(name = "portainerRestTemplate")
|
@Bean(name = "portainerRestTemplate")
|
||||||
public RestTemplate portainerRestTemplateLocal() throws Exception {
|
public RestTemplate portainerRestTemplate() {
|
||||||
return buildTrustAllRestTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trust-all SSL RestTemplate for the "prod" profile.
|
|
||||||
* Prod Portainer at https://192.168.0.100:9443 uses a self-signed certificate.
|
|
||||||
*/
|
|
||||||
@Profile("prod")
|
|
||||||
@Bean(name = "portainerRestTemplate")
|
|
||||||
public RestTemplate portainerRestTemplateProd() throws Exception {
|
|
||||||
return buildTrustAllRestTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Standard validating SSL RestTemplate for profiles other than local and prod
|
|
||||||
* (CI, test — internal Docker network with valid certs).
|
|
||||||
*/
|
|
||||||
@Profile("!local & !prod")
|
|
||||||
@Bean(name = "portainerRestTemplate")
|
|
||||||
public RestTemplate portainerRestTemplateDefault() {
|
|
||||||
return new RestTemplate();
|
return new RestTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,3 @@ portainer.base-url=https://192.168.0.100:9442
|
|||||||
portainer.api-key=${PORTAINER_API_KEY:}
|
portainer.api-key=${PORTAINER_API_KEY:}
|
||||||
portainer.endpoint-id=1
|
portainer.endpoint-id=1
|
||||||
portainer.service.api-key=${PORTAINER_SERVICE_API_KEY:change-me}
|
portainer.service.api-key=${PORTAINER_SERVICE_API_KEY:change-me}
|
||||||
|
|
||||||
# Actuator configuration - management port and exposed endpoints
|
|
||||||
# App runs on server.port=8081, so management port must differ (8082)
|
|
||||||
management.server.port=8082
|
|
||||||
management.endpoints.web.exposure.include=health,info
|
|
||||||
management.endpoint.health.show-details=when-authorized
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user