mirror of
https://github.com/status-im/consul.git
synced 2025-02-20 17:38:24 +00:00
mesh: add options for HTTP incoming request normalization Expose global mesh configuration to enforce inbound HTTP request normalization on mesh traffic via Envoy xDS config. mesh: enable inbound URL path normalization by default mesh: add support for L7 header match contains and ignore_case Enable partial string and case-insensitive matching in L7 intentions header match rules. ui: support L7 header match contains and ignore_case Co-authored-by: Phil Renaud <phil@riotindustries.com> test: add request normalization integration bats tests Add both "positive" and "negative" test suites, showing normalization in action as well as expected results when it is not enabled, for the same set of test cases. Also add some alternative service container test helpers for verifying raw HTTP request paths, which is difficult to do with Fortio. docs: update security and reference docs for L7 intentions bypass prevention - Update security docs with best practices for service intentions configuration - Update configuration entry references for mesh and intentions to reflect new values and add guidance on usage
154 lines
2.8 KiB
Bash
154 lines
2.8 KiB
Bash
#!/bin/bash
|
|
# Copyright (c) HashiCorp, Inc.
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
upsert_config_entry primary '
|
|
kind = "service-defaults"
|
|
name = "s2"
|
|
protocol = "http"
|
|
'
|
|
|
|
upsert_config_entry primary '
|
|
kind = "service-intentions"
|
|
name = "s2"
|
|
sources {
|
|
name = "s1"
|
|
permissions = [
|
|
// paths
|
|
{
|
|
action = "allow"
|
|
http { path_exact = "/exact" }
|
|
},
|
|
{
|
|
action = "allow"
|
|
http { path_prefix = "/prefix" }
|
|
},
|
|
{
|
|
action = "allow"
|
|
http { path_regex = "/reg[ex]{2}" }
|
|
},
|
|
// headers
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-present"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
present = true
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-exact"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
exact = "exact"
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-exact-ignore-case"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
exact = "foo.bar.com"
|
|
ignore_case = true
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-prefix"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
prefix = "prefi"
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-prefix-ignore-case"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
prefix = "foo.bar"
|
|
ignore_case = true
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-suffix"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
suffix = "uffix"
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-suffix-ignore-case"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
suffix = "bar.com"
|
|
ignore_case = true
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-contains"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
contains = "contains"
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-contains-ignore-case"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
contains = "contains"
|
|
ignore_case = true
|
|
}]
|
|
}
|
|
},
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/hdr-regex"
|
|
header = [{
|
|
name = "x-test-debug"
|
|
regex = "reg[ex]{2}"
|
|
}]
|
|
}
|
|
},
|
|
// methods
|
|
{
|
|
action = "allow"
|
|
http {
|
|
path_exact = "/method-match"
|
|
methods = ["GET", "PUT"]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
'
|
|
|
|
register_services primary
|
|
|
|
gen_envoy_bootstrap s1 19000
|
|
gen_envoy_bootstrap s2 19001
|