Compare commits
No commits in common. "main" and "pa-0.28.0" have entirely different histories.
@ -2,11 +2,9 @@ package com.hithomelabs.cftunnels.Config.Security;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Security configuration for Spring Boot Actuator endpoints.
|
* Security configuration for Spring Boot Actuator endpoints.
|
||||||
@ -14,20 +12,15 @@ import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointR
|
|||||||
* This configuration permits unauthenticated access to /actuator/health and /actuator/info
|
* This configuration permits unauthenticated access to /actuator/health and /actuator/info
|
||||||
* endpoints, enabling health monitoring by Uptime Kuma without requiring OIDC authentication.
|
* endpoints, enabling health monitoring by Uptime Kuma without requiring OIDC authentication.
|
||||||
* All other actuator endpoints remain protected and require 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
|
@Configuration
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
||||||
public class ActuatorSecurityConfig {
|
public class ActuatorSecurityConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@Order(1)
|
||||||
public SecurityFilterChain actuatorSecurityChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain actuatorSecurityChain(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
.securityMatcher(EndpointRequest.toAnyEndpoint())
|
.securityMatcher("/actuator/**")
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers("/actuator/health", "/actuator/info").permitAll()
|
.requestMatchers("/actuator/health", "/actuator/info").permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
|
|||||||
@ -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<>(),
|
||||||
|
|||||||
@ -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}
|
||||||
|
|||||||
@ -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