1
0
mirror of synced 2026-08-31 22:46:02 +00:00

Add WebFlux Redirect to HTTPS Reference

Fixes: gh-5869
This commit is contained in:
Rob Winch
2018-09-18 21:12:37 -05:00
parent db9248e05a
commit 501c008526
4 changed files with 52 additions and 1 deletions
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest;
@@ -1473,6 +1474,22 @@ public class ServerHttpSecurity {
return this;
}
/**
* Configures when this filter should redirect to https
*
* By default, the filter will redirect whenever an exchange's scheme is not https
*
* @param when determines when to redirect to https
* @return the {@link HttpsRedirectSpec} for additional configuration
*/
public HttpsRedirectSpec httpsRedirectWhen(
Function<ServerWebExchange, Boolean> when) {
ServerWebExchangeMatcher matcher = e -> when.apply(e) ?
ServerWebExchangeMatcher.MatchResult.match() :
ServerWebExchangeMatcher.MatchResult.notMatch();
return httpsRedirectWhen(matcher);
}
/**
* Configures a custom HTTPS port to redirect to
*