From 01f0498498b6cbd90b5d9afc73a34a6931e3c724 Mon Sep 17 00:00:00 2001 From: dongjunduo Date: Wed, 29 Mar 2023 09:55:53 +0800 Subject: [PATCH 1/4] fix(cli): prevent non-`127.0.0.0/24` to access admin api with empty admin_key (#9146) --- apisix/cli/ops.lua | 9 +++------ t/cli/test_admin.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/apisix/cli/ops.lua b/apisix/cli/ops.lua index ef069f815010..5ce51dab3b32 100644 --- a/apisix/cli/ops.lua +++ b/apisix/cli/ops.lua @@ -185,12 +185,9 @@ local function init(env) local checked_admin_key = false local allow_admin = yaml_conf.deployment.admin and yaml_conf.deployment.admin.allow_admin - if yaml_conf.apisix.enable_admin and allow_admin then - for _, allow_ip in ipairs(allow_admin) do - if allow_ip == "127.0.0.0/24" then - checked_admin_key = true - end - end + if yaml_conf.apisix.enable_admin and allow_admin + and #allow_admin == 1 and allow_admin[1] == "127.0.0.0/24" then + checked_admin_key = true end if yaml_conf.apisix.enable_admin and not checked_admin_key then diff --git a/t/cli/test_admin.sh b/t/cli/test_admin.sh index 5336244e3372..6f39ffae170a 100755 --- a/t/cli/test_admin.sh +++ b/t/cli/test_admin.sh @@ -154,6 +154,41 @@ fi echo "pass: missing admin key and show ERROR message" +# missing admin key, only allow 127.0.0.0/24 to access admin api + +echo ' +deployment: + admin: + admin_key: ~ + allow_admin: + - 127.0.0.0/24 +' > conf/config.yaml + +make init > output.log 2>&1 | true + +if grep -E "ERROR: missing valid Admin API token." output.log > /dev/null; then + echo "failed: should not show 'ERROR: missing valid Admin API token.'" + exit 1 +fi + +echo ' +deployment: + admin: + admin_key: ~ + allow_admin: + - 0.0.0.0/0 + - 127.0.0.0/24 +' > conf/config.yaml + +make init > output.log 2>&1 | true + +if ! grep -E "ERROR: missing valid Admin API token." output.log > /dev/null; then + echo "failed: should show 'ERROR: missing valid Admin API token.'" + exit 1 +fi + +echo "pass: missing admin key and only allow 127.0.0.0/24 to access admin api" + # admin api, allow any IP but use default key echo ' From 9b2b82f05c07a06d018f3bf5739b5c94222c769b Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Wed, 29 Mar 2023 13:09:17 +0530 Subject: [PATCH 2/4] docs: remove APISIX base instruction (#9117) --- docs/en/latest/mtls.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/en/latest/mtls.md b/docs/en/latest/mtls.md index 1a1180a0978f..fe0f43ef7ef9 100644 --- a/docs/en/latest/mtls.md +++ b/docs/en/latest/mtls.md @@ -1,5 +1,10 @@ --- title: Mutual TLS Authentication +keywords: + - Apache APISIX + - Mutual TLS + - mTLS +description: This document describes how you can secure communication to and within APISIX with mTLS. ---