You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When server.forward-headers-strategy=framework is used in a WebFlux project that makes use of an IpAddressServerWebExchangeMatcher a NullPointerException is thrown when a Forwarded or X-Forwarded-For header is present because the remoteAddress created by ForwardedHeaderTransformer is unresolved.
To Reproduce
Create a sample WebFlux project and set server.forward-headers-strategy=framework
Define a SecurityWebFilterChain bean that calls an IpAddressServerWebExchangeMatcher
Submit a request with a Forwarded or X-Forwarded-For header
Expected behavior
The IpAddressServerWebExchangeMatcher should execute as normal with no exception thrown.
Sample server.forward-headers-strategy=framework
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity httpSecurity) {
return httpSecurity
.authorizeExchange(auth -> auth
.pathMatchers("/**")
.access((authentication, authorizationContext) ->
new IpAddressServerWebExchangeMatcher("255.255.255.255")
.matches(authorizationContext.getExchange())
.map(matchResult -> new AuthorizationDecision(matchResult.isMatch()))))
.build();
}
The text was updated successfully, but these errors were encountered:
Sometimes InetSocketAddress#getAddress#getHostAddress retuns null.
In that case, call InetSocketAddress#getHostString instead.
There is no performance loss since IpAddressMatcher#matches attemptsi
to re-parse and resolve the address anyway.
Closesgh-11888
Describe the bug
When
server.forward-headers-strategy=framework
is used in a WebFlux project that makes use of anIpAddressServerWebExchangeMatcher
aNullPointerException
is thrown when aForwarded
orX-Forwarded-For
header is present because the remoteAddress created byForwardedHeaderTransformer
is unresolved.To Reproduce
server.forward-headers-strategy=framework
SecurityWebFilterChain
bean that calls anIpAddressServerWebExchangeMatcher
Forwarded
orX-Forwarded-For
headerExpected behavior
The
IpAddressServerWebExchangeMatcher
should execute as normal with no exception thrown.Sample
server.forward-headers-strategy=framework
The text was updated successfully, but these errors were encountered: