Use infinit regex for accept requests from any domain (#3296)

Signed-off-by: Diego López León <dieguitoll@gmail.com>
pull/3302/head
Diego López León 3 years ago committed by GitHub
parent 25a2af0897
commit 9407866d44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java
  3. 15
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceCorsTest.java

@ -10,6 +10,7 @@
- Update to block header validation for IBFT and QBFT to support London fork EIP-1559 [#3251](https://github.com/hyperledger/besu/pull/3251)
### Bug Fixes
- Fix regression on cors-origin star value
## 22.1.0-RC2

@ -819,7 +819,7 @@ public class JsonRpcHttpService {
return "";
}
if (config.getCorsAllowedDomains().contains("*")) {
return "*";
return ".*";
} else {
final StringJoiner stringJoiner = new StringJoiner("|");
config.getCorsAllowedDomains().stream().filter(s -> !s.isEmpty()).forEach(stringJoiner::add);

@ -166,6 +166,21 @@ public class JsonRpcHttpServiceCorsTest {
}
}
@Test
public void requestFromBrowserExtensionShouldSucceedWhenCorsIsStar() throws Exception {
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("*");
final Request request =
new Request.Builder()
.url(jsonRpcHttpService.url())
.header("Origin", "moz-extension://802123e4-a916-2d4e-bebf-384b0e2e86dd")
.build();
try (final Response response = client.newCall(request).execute()) {
assertThat(response.isSuccessful()).isTrue();
}
}
@Test
public void requestWithAccessControlRequestMethodShouldReturnAllowedHeaders() throws Exception {
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("http://foo.io");

Loading…
Cancel
Save