Skip to content

Commit 20b3ab0

Browse files
committed
#547 - Actuator Endpoint Throws CORS Error
- add cors to management endpoints - also move them from /actuator to /api/v5/actuator
1 parent cae5352 commit 20b3ab0

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ jobs:
186186
run: docker compose -f .github/integration-test/docker-compose.yml up -d
187187

188188
- name: Wait for Dataportal Backend
189-
run: .github/scripts/wait-for-url.sh http://localhost:8091/actuator/health
189+
run: .github/scripts/wait-for-url.sh http://localhost:8091/api/v5/actuator/health
190190

191191
- name: Check if Dataportal Backend is correctly running with the user with id 10001
192192
run: .github/scripts/check-if-running-as-user-10001.sh
193193

194194
- name: Check info endpoint
195-
run: .github/scripts/check-info-endpoint.sh http://localhost:8091/actuator/info
195+
run: .github/scripts/check-info-endpoint.sh http://localhost:8091/api/v5/actuator/info
196196

197197
- name: Wait for Blaze
198198
run: .github/scripts/wait-for-url.sh http://localhost:8082/health

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RUN mkdir logging && \
1919
apk --no-cache add curl bash
2020
USER 10001
2121

22-
HEALTHCHECK --interval=5s --start-period=10s CMD curl -s -f http://localhost:8090/actuator/health || exit 1
22+
HEALTHCHECK --interval=5s --start-period=10s CMD curl -s -f http://localhost:8090/api/v5/actuator/health || exit 1
2323

2424
COPY ./target/*.jar ./dataportal-backend.jar
2525
COPY ontology ontology

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ DATAPORTAL_DATABASE_PORT=<your-desired-port> docker-compose up -d
312312

313313
### Testing if the Container is Running Properly
314314
```
315-
GET http://localhost:8090/actuator/health
315+
GET http://localhost:8090/api/v5/actuator/health
316316
```
317317

318318
Should reply with status 200 and a JSON object

src/main/java/de/numcodex/feasibility_gui_backend/config/WebSecurityConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public SecurityFilterChain apiFilterChain(
9898

9999
http.authorizeHttpRequests(authorize -> authorize
100100
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_SWAGGER_CONFIG)).permitAll()
101+
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_API + PATH_ACTUATOR_HEALTH)).permitAll()
102+
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_API + PATH_ACTUATOR_INFO)).permitAll()
101103
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_API + PATH_SWAGGER_UI)).permitAll()
102104
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_API + PATH_TERMINOLOGY + "/**")).hasAuthority(keycloakAllowedRole)
103105
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_API + PATH_QUERY + PATH_DATA)).hasAuthority(keycloakAllowedRole)
@@ -108,8 +110,6 @@ public SecurityFilterChain apiFilterChain(
108110
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_API + "/**")).hasAnyAuthority(keycloakAdminRole, keycloakAllowedRole)
109111
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_API + PATH_DSE + "/**")).hasAnyAuthority(keycloakAdminRole, keycloakAllowedRole)
110112
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_API + PATH_CODEABLE_CONCEPT + "/**")).hasAnyAuthority(keycloakAdminRole, keycloakAllowedRole)
111-
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_ACTUATOR_HEALTH)).permitAll()
112-
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher(PATH_ACTUATOR_INFO)).permitAll()
113113
.anyRequest().authenticated()
114114
)
115115
.oauth2ResourceServer(oauth2 -> oauth2

src/main/resources/application.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ springdoc:
3535
management:
3636
endpoints:
3737
web:
38+
cors:
39+
allowed-origins: "${ALLOWED_ORIGINS:http://localhost}"
40+
allowed-methods: OPTIONS, GET
41+
allowed-headers: "*"
3842
exposure:
3943
include: "health, info"
44+
base-path: /api/v5/actuator
4045
access:
4146
default: none
4247
endpoint:

0 commit comments

Comments
 (0)