Skip to content

Commit 24a8ba3

Browse files
committed
Fixes tests, allowing /internal/** in both SecurityConfig and DollyAuthorizationHeaderFilter.
1 parent 478e533 commit 24a8ba3

6 files changed

Lines changed: 23 additions & 3 deletions

File tree

proxies/texas-proxy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ En proxy for tilgang til Texas.
33
## Lokal kjøring
44
* [Generelt.](../../docs/local_general.md)
55

6-
> **NB:** Applikasjonen kjører på port 8081, slik at den kan kjøres opp ved siden av applikasjoner som kjører på default 8080. Evt. i en `docker-compose.yml`.
6+
> **NB:** Applikasjonen kjører på port 8081, slik at den kan kjøres opp ved siden av applikasjoner som kjører på default 8080. Evt. i en `docker-compose.yml`. Delt secret i local profile er LOCAL.

proxies/texas-proxy/src/main/java/no/nav/dolly/proxy/texas/DollyAuthorizationHeaderFilter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class DollyAuthorizationHeaderFilter implements WebFilter {
2020
@NonNull
2121
public Mono<Void> filter(ServerWebExchange exchange, @NonNull WebFilterChain chain) {
2222

23+
if (exchange.getRequest().getPath().value().startsWith("/internal")) {
24+
return chain.filter(exchange);
25+
}
26+
2327
var header = exchange
2428
.getRequest()
2529
.getHeaders()

proxies/texas-proxy/src/main/java/no/nav/dolly/proxy/texas/SecurityConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
2121
.csrf(ServerHttpSecurity.CsrfSpec::disable)
2222
.addFilterAt(filter, SecurityWebFiltersOrder.AUTHENTICATION)
2323
.authorizeExchange(exchange -> exchange
24-
.anyExchange()
25-
.permitAll())
24+
.pathMatchers("/internal/**").permitAll()
25+
.anyExchange().permitAll())
2626
.build();
2727

2828
}

proxies/texas-proxy/src/main/resources/application-local.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ dolly:
99
token: https://dolly-texas-proxy.intern.dev.nav.no/api/v1/token
1010
exchange: https://dolly-texas-proxy.intern.dev.nav.no/api/v1/token/exchange
1111
introspect: https://dolly-texas-proxy.intern.dev.nav.no/api/v1/introspect
12+
shared:
13+
secret: LOCAL
1214

1315
server:
1416
port: 8081

proxies/texas-proxy/src/test/java/no/nav/dolly/proxy/texas/RouteLocatorTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,27 @@ void testRoutes() {
8585
.post()
8686
.uri("/api/v1/token")
8787
.contentType(MediaType.APPLICATION_JSON)
88+
.header(HttpHeaders.AUTHORIZATION, "Dolly TEST")
8889
.bodyValue(GET_TOKEN_BODY)
8990
.exchange()
9091
.expectStatus()
9192
.isOk();
9293

94+
// No custom auth header.
95+
client
96+
.post()
97+
.uri("/api/v1/token")
98+
.contentType(MediaType.APPLICATION_JSON)
99+
.bodyValue(GET_TOKEN_BODY)
100+
.exchange()
101+
.expectStatus()
102+
.is4xxClientError();
103+
93104
client
94105
.post()
95106
.uri("/api/v1/token/exchange")
96107
.contentType(MediaType.APPLICATION_JSON)
108+
.header(HttpHeaders.AUTHORIZATION, "Dolly TEST")
97109
.bodyValue(EXCHANGE_TOKEN_BODY)
98110
.exchange()
99111
.expectStatus()
@@ -103,6 +115,7 @@ void testRoutes() {
103115
.post()
104116
.uri("/api/v1/introspect")
105117
.contentType(MediaType.APPLICATION_JSON)
118+
.header(HttpHeaders.AUTHORIZATION, "Dolly TEST")
106119
.bodyValue(INTROSPECT_TOKEN_BODY)
107120
.exchange()
108121
.expectStatus()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
DOLLY_TEXAS_PROXY_SHARED_SECRET: TEST
12
NAIS_TOKEN_ENDPOINT: http://localhost:${wiremock.server.port}/api/v1/token
23
NAIS_TOKEN_EXCHANGE_ENDPOINT: http://localhost:${wiremock.server.port}/api/v1/token/exchange
34
NAIS_TOKEN_INTROSPECTION_ENDPOINT: http://localhost:${wiremock.server.port}/api/v1/introspect

0 commit comments

Comments
 (0)