|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2015 the original author or authors. |
|
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -16,20 +16,14 @@ |
|
|
|
|
|
|
|
|
|
package org.springframework.web.cors.reactive; |
|
|
|
|
|
|
|
|
|
import reactor.core.publisher.Mono; |
|
|
|
|
|
|
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
|
import org.springframework.web.cors.CorsConfiguration; |
|
|
|
|
import org.springframework.web.server.ServerWebExchange; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* A strategy that takes a reactive HTTP exchange and a {@link CorsConfiguration} and |
|
|
|
|
* updates the response. |
|
|
|
|
* |
|
|
|
|
* <p>This component is not concerned with how a {@code CorsConfiguration} is |
|
|
|
|
* selected but rather takes follow-up actions such as applying CORS validation |
|
|
|
|
* checks and either rejecting the response or adding CORS headers to the |
|
|
|
|
* response. |
|
|
|
|
* A strategy to apply CORS validation checks and updates to a |
|
|
|
|
* {@link ServerWebExchange}, either rejecting through the response or adding |
|
|
|
|
* CORS related headers, based on a pre-selected {@link CorsConfiguration}. |
|
|
|
|
* |
|
|
|
|
* @author Sebastien Deleuze |
|
|
|
|
* @author Rossen Stoyanchev |
|
|
|
@ -39,10 +33,11 @@ import org.springframework.web.server.ServerWebExchange; |
|
|
|
|
public interface CorsProcessor { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Process an HTTP exchange given a {@code CorsConfiguration}. |
|
|
|
|
* @param configuration the applicable CORS configuration (possibly {@code null}) |
|
|
|
|
* @param exchange the current HTTP request / response |
|
|
|
|
* @return a {@link Mono} emitting {@code false} if the request is rejected, {@code true} otherwise |
|
|
|
|
* Process a request using the given {@code CorsConfiguration}. |
|
|
|
|
* @param configuration the CORS configuration to use; possibly {@code null} |
|
|
|
|
* in which case pre-flight requests are rejected, but all others allowed. |
|
|
|
|
* @param exchange the current exchange |
|
|
|
|
* @return {@code false} if the request was rejected, {@code true} otherwise |
|
|
|
|
*/ |
|
|
|
|
boolean process(@Nullable CorsConfiguration configuration, ServerWebExchange exchange); |
|
|
|
|
|
|
|
|
|