You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/02/08 02:07:32 UTC

[GitHub] [apisix] spacewander commented on a change in pull request #3554: Auth hook

spacewander commented on a change in pull request #3554:
URL: https://github.com/apache/apisix/pull/3554#discussion_r571735429



##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)

Review comment:
       `return core.schema.check(schema, conf)` is enough

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+
+    if type(hook_res_to_headers) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", nil)
+    for field, val in pairs(hook_res_to_headers) do
+        local f = string.gsub(val, '_', '-')
+        core.request.set_header(prefix .. f, nil)
+        core.response.set_header(prefix .. f, nil)
+
+    end
+    return ;
+end
+
+--获取需要传输的headers
+local function res_to_headers(config, data)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+    if type(hook_res_to_headers) ~= "table" or type(data) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", core.json.encode(data))
+    for field, val in pairs(hook_res_to_headers) do
+        local v = data[val]
+        if v then
+            if type(v) == "table" then
+                v = core.json.encode(v)
+            end
+            local f = string.gsub(val, '_', '-')

Review comment:
       We can use `pattern` in the schema to make sure there is no '_'.
   See https://github.com/apache/apisix/blob/e5cd46e38e09d1025817381a3bf0b85a4f02a528/apisix/plugins/proxy-cache.lua#L84

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,

Review comment:
       The 1000 is taken. Maybe we can use another number?

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+
+    if type(hook_res_to_headers) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", nil)
+    for field, val in pairs(hook_res_to_headers) do

Review comment:
       Please use ipairs as hook_res_to_headers is an array

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+
+    if type(hook_res_to_headers) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", nil)
+    for field, val in pairs(hook_res_to_headers) do
+        local f = string.gsub(val, '_', '-')
+        core.request.set_header(prefix .. f, nil)
+        core.response.set_header(prefix .. f, nil)
+
+    end
+    return ;
+end
+
+--获取需要传输的headers
+local function res_to_headers(config, data)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+    if type(hook_res_to_headers) ~= "table" or type(data) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", core.json.encode(data))
+    for field, val in pairs(hook_res_to_headers) do
+        local v = data[val]
+        if v then
+            if type(v) == "table" then
+                v = core.json.encode(v)
+            end
+            local f = string.gsub(val, '_', '-')
+            core.request.set_header(prefix .. f, v)
+            core.response.set_header(prefix .. f, v)
+
+        end
+    end
+    return ;
+end
+
+
+--获取需要传输的args
+local function get_hook_args(hook_args)
+
+    local req_args = new_table();
+    if not hook_args then
+        return req_args
+    end
+    local args = ngx.req.get_uri_args()
+    for field in pairs(hook_args) do

Review comment:
       Please use ipairs as hook_args is an array

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)

Review comment:
       We can merge res_init_headers into res_to_headers as a special case.

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+
+    if type(hook_res_to_headers) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", nil)
+    for field, val in pairs(hook_res_to_headers) do
+        local f = string.gsub(val, '_', '-')
+        core.request.set_header(prefix .. f, nil)
+        core.response.set_header(prefix .. f, nil)
+
+    end
+    return ;
+end
+
+--获取需要传输的headers
+local function res_to_headers(config, data)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+    if type(hook_res_to_headers) ~= "table" or type(data) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", core.json.encode(data))
+    for field, val in pairs(hook_res_to_headers) do

Review comment:
       Please use ipairs as hook_res_to_headers is an array

##########
File path: doc/plugins/auth-hook.md
##########
@@ -0,0 +1,182 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+-[English](../../plugins/auth-hook.md)
+
+# table of Contents
+
+-[**Name**](#first name) -[**Attribute**](#Attribute) -[**Dependencies**](#Dependencies) -[**How ​​to enable**](#How to enable) -[**Test plugin**](#Test plugin) -[**Disable plugins**](#Disable plugins)

Review comment:
       Need to fix the format

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do

Review comment:
       Please use ipairs as hook_headers is an array

##########
File path: doc/plugins/auth-hook.md
##########
@@ -0,0 +1,182 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+-[English](../../plugins/auth-hook.md)
+
+# table of Contents
+
+-[**Name**](#first name) -[**Attribute**](#Attribute) -[**Dependencies**](#Dependencies) -[**How ​​to enable**](#How to enable) -[**Test plugin**](#Test plugin) -[**Disable plugins**](#Disable plugins)
+
+## first name
+
+`auth-hook` is an authentication and authorization plug-in, add `auth-hook` to a `service` or `route`.
+The auth-hook function is provided by its own auth-server, and it is sufficient to provide an authorization authentication interface according to the corresponding data structure.

Review comment:
       "authorization authentication" => "authorization / authentication"

##########
File path: doc/plugins/auth-hook.md
##########
@@ -0,0 +1,182 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+-[English](../../plugins/auth-hook.md)
+
+# table of Contents
+
+-[**Name**](#first name) -[**Attribute**](#Attribute) -[**Dependencies**](#Dependencies) -[**How ​​to enable**](#How to enable) -[**Test plugin**](#Test plugin) -[**Disable plugins**](#Disable plugins)
+
+## first name

Review comment:
       Should be `## Name`

##########
File path: conf/config-default.yaml
##########
@@ -259,6 +259,7 @@ plugins:                          # plugin list (sorted in alphabetical order)
   - udp-logger
   - uri-blocker
   - wolf-rbac
+  - auth-hook

Review comment:
       plugin list (sorted in alphabetical order)

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+
+    if type(hook_res_to_headers) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", nil)
+    for field, val in pairs(hook_res_to_headers) do
+        local f = string.gsub(val, '_', '-')

Review comment:
       We can use `pattern` in the schema to make sure there is no '_'.
   See https://github.com/apache/apisix/blob/e5cd46e38e09d1025817381a3bf0b85a4f02a528/apisix/plugins/proxy-cache.lua#L84

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+
+    if type(hook_res_to_headers) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", nil)
+    for field, val in pairs(hook_res_to_headers) do
+        local f = string.gsub(val, '_', '-')
+        core.request.set_header(prefix .. f, nil)
+        core.response.set_header(prefix .. f, nil)
+
+    end
+    return ;
+end
+
+--获取需要传输的headers
+local function res_to_headers(config, data)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+    if type(hook_res_to_headers) ~= "table" or type(data) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", core.json.encode(data))
+    for field, val in pairs(hook_res_to_headers) do
+        local v = data[val]
+        if v then
+            if type(v) == "table" then
+                v = core.json.encode(v)
+            end
+            local f = string.gsub(val, '_', '-')
+            core.request.set_header(prefix .. f, v)
+            core.response.set_header(prefix .. f, v)
+
+        end
+    end
+    return ;
+end
+
+
+--获取需要传输的args
+local function get_hook_args(hook_args)
+
+    local req_args = new_table();
+    if not hook_args then
+        return req_args
+    end
+    local args = ngx.req.get_uri_args()
+    for field in pairs(hook_args) do
+        local v = args[field]
+        if v then
+            req_args[field] = v
+        end
+    end
+    return req_args;
+end
+
+-- Configure request parameters.
+local function hook_configure_params(args, config, myheaders)
+    -- TLS verification.
+    myheaders["Content-Type"] = "application/json; charset=utf-8"
+    local auth_hook_params = {
+        ssl_verify = false,
+        method = config.auth_hook_method,
+        headers = myheaders,
+    };
+    local url = config.auth_hook_uri;
+    -- Keepalive options.
+    if config.hook_keepalive then
+        auth_hook_params.keepalive_timeout = config.hook_keepalive_timeout
+        auth_hook_params.keepalive_pool = config.hook_keepalive_pool
+    else
+        auth_hook_params.keepalive = config.hook_keepalive
+    end
+    url = config.auth_hook_uri .. "?" .. ngx.encode_args(args)
+    if config.auth_hook_method == 'POST' then
+        auth_hook_params.body = nil
+    else
+        auth_hook_params.body = nil

Review comment:
       Why repeat the same code in different branch?

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+
+    if type(hook_res_to_headers) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", nil)
+    for field, val in pairs(hook_res_to_headers) do
+        local f = string.gsub(val, '_', '-')
+        core.request.set_header(prefix .. f, nil)
+        core.response.set_header(prefix .. f, nil)

Review comment:
       We can't set the response header as we haven't got it yet.

##########
File path: doc/plugins/auth-hook.md
##########
@@ -0,0 +1,182 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+-[English](../../plugins/auth-hook.md)
+
+# table of Contents
+
+-[**Name**](#first name) -[**Attribute**](#Attribute) -[**Dependencies**](#Dependencies) -[**How ​​to enable**](#How to enable) -[**Test plugin**](#Test plugin) -[**Disable plugins**](#Disable plugins)
+
+## first name
+
+`auth-hook` is an authentication and authorization plug-in, add `auth-hook` to a `service` or `route`.
+The auth-hook function is provided by its own auth-server, and it is sufficient to provide an authorization authentication interface according to the corresponding data structure.
+
+## Attributes
+
+| Name                      | Type          | Required | Default Value | Valid Value | Description                                                                                                                                                                                                                                                                                                                                                                                                             |
+| ------------------------- | ------------- | -------- | ------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| auth_hook_uri             | string        | Required |               |             | Set the access route of `auth-server`                                                                                                                                                                                                                                                                                                                                                                                   |
+| auth_hook_id              | string        | Optional | "unset"       |             | Set `auth_hook_id`, the `auth_hook_id` will be carried in the header `Auth-Hook-Id` to request a custom auth-server service                                                                                                                                                                                                                                                                                             |
+| auth_hook_method          | string        | Optional | "GET"         |             | Set the access method of `auth-server`, the default is `GET`, only `POST`, `GET` are allowed                                                                                                                                                                                                                                                                                                                            |
+| hook_headers              | array[string] | Optional |               |             | Specify the header parameters of the business request. Proxy request hook service, which will carry `Authorization` by default                                                                                                                                                                                                                                                                                          |
+| hook_args                 | array[string] | Optional |               |             | Specify request query parameters, proxy requests hook service with query parameters                                                                                                                                                                                                                                                                                                                                     |
+| hook_res_to_headers       | array[string] | Optional |               |             | Specify the fields in the data body of the data returned by the hook service, add the headers parameter and pass it to the upstream service, such as `user_id=15` in the data data, splicing `hook_res_to_header_prefix` and Replace the next `_` with `-` into the header, request upstream services with `X-user-id`, if the selected field is an object or array, it will be converted to a json string as its value |
+| hook_res_to_header_prefix | string        | Optional |               |             | User `hook_res_to_headers` carries parameters and converts to header field prefix                                                                                                                                                                                                                                                                                                                                       |

Review comment:
       Should document its default value `X-`

##########
File path: apisix/plugins/auth-hook.lua
##########
@@ -0,0 +1,337 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local json = require("apisix.core.json")
+local http = require("resty.http")
+local ck = require("resty.cookie")
+local ngx = ngx
+local rawget = rawget
+local rawset = rawset
+local setmetatable = setmetatable
+local string = string
+
+local plugin_name = "auth-hook"
+local hook_lrucache = core.lrucache.new({
+    ttl = 60, count = 1024
+})
+
+local schema = {
+    type = "object",
+    properties = {
+        auth_hook_id = { type = "string", minLength = 1, maxLength = 100, default = "unset" },
+        auth_hook_uri = { type = "string", minLength = 1, maxLength = 4096 },
+        auth_hook_method = {
+            type = "string",
+            default = "GET",
+            enum = { "GET", "POST" },
+        },
+        hook_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_args = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_res_to_headers = {
+            type = "array",
+            items = {
+                type = "string",
+                minLength = 1, maxLength = 100
+            },
+            uniqueItems = true
+        },
+        hook_keepalive = { type = "boolean", default = true },
+        hook_keepalive_timeout = { type = "integer", minimum = 1000, default = 60000 },
+        hook_keepalive_pool = { type = "integer", minimum = 1, default = 5 },
+        hook_res_to_header_prefix = { type = "string", default = "X-", minLength = 1, maxLength = 100 },
+        hook_cache = { type = "boolean", default = false },
+        check_termination = { type = "boolean", default = true },
+    },
+    required = { "auth_hook_uri"},
+}
+
+local _M = {
+    version = 0.1,
+    priority = 1000,
+    name = plugin_name,
+    schema = schema,
+}
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+local function get_auth_token(ctx)
+    local token = ctx.var.http_x_auth_token
+    if token then
+        return token
+    end
+
+    token = ctx.var.http_authorization
+    if token then
+        return token
+    end
+
+    token = ctx.var.arg_auth_token
+    if token then
+        return token
+    end
+
+    local cookie, err = ck:new()
+    if not cookie then
+        return nil, err
+    end
+
+    local val, error = cookie:get("auth-token")
+    return val, error
+end
+
+local function fail_response(message, init_values)
+    local response = init_values or {}
+    response.message = message
+    return response
+end
+
+--初始化headers
+local function new_table()
+    local t = {}
+    local lt = {}
+    local _mt = {
+        __index = function(t, k)
+            return rawget(lt, string.lower(k))
+        end,
+        __newindex = function(t, k, v)
+            rawset(t, k, v)
+            rawset(lt, string.lower(k), v)
+        end,
+    }
+    return setmetatable(t, _mt)
+end
+
+
+--获取需要传输的headers
+local function request_headers(config, ctx)
+    local req_headers = new_table();
+    local headers = core.request.headers(ctx);
+    local hook_headers = config.hook_headers
+    if not hook_headers then
+        return req_headers
+    end
+    for field in pairs(hook_headers) do
+        local v = headers[field]
+        if v then
+            req_headers[field] = v
+        end
+    end
+    return req_headers;
+end
+
+
+--获取需要传输的headers
+local function res_init_headers(config)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+
+    if type(hook_res_to_headers) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", nil)
+    for field, val in pairs(hook_res_to_headers) do
+        local f = string.gsub(val, '_', '-')
+        core.request.set_header(prefix .. f, nil)
+        core.response.set_header(prefix .. f, nil)
+
+    end
+    return ;
+end
+
+--获取需要传输的headers
+local function res_to_headers(config, data)
+
+    local prefix = config.hook_res_to_header_prefix or ''
+    local hook_res_to_headers = config.hook_res_to_headers;
+    if type(hook_res_to_headers) ~= "table" or type(data) ~= "table" then
+        return
+    end
+    core.request.set_header(prefix .. "auth-data", core.json.encode(data))
+    for field, val in pairs(hook_res_to_headers) do
+        local v = data[val]
+        if v then
+            if type(v) == "table" then
+                v = core.json.encode(v)
+            end
+            local f = string.gsub(val, '_', '-')
+            core.request.set_header(prefix .. f, v)
+            core.response.set_header(prefix .. f, v)
+
+        end
+    end
+    return ;
+end
+
+
+--获取需要传输的args
+local function get_hook_args(hook_args)
+
+    local req_args = new_table();
+    if not hook_args then
+        return req_args
+    end
+    local args = ngx.req.get_uri_args()
+    for field in pairs(hook_args) do
+        local v = args[field]
+        if v then
+            req_args[field] = v
+        end
+    end
+    return req_args;
+end
+
+-- Configure request parameters.
+local function hook_configure_params(args, config, myheaders)
+    -- TLS verification.
+    myheaders["Content-Type"] = "application/json; charset=utf-8"
+    local auth_hook_params = {
+        ssl_verify = false,
+        method = config.auth_hook_method,
+        headers = myheaders,
+    };
+    local url = config.auth_hook_uri;
+    -- Keepalive options.
+    if config.hook_keepalive then
+        auth_hook_params.keepalive_timeout = config.hook_keepalive_timeout
+        auth_hook_params.keepalive_pool = config.hook_keepalive_pool
+    else
+        auth_hook_params.keepalive = config.hook_keepalive
+    end
+    url = config.auth_hook_uri .. "?" .. ngx.encode_args(args)
+    if config.auth_hook_method == 'POST' then
+        auth_hook_params.body = nil
+    else
+        auth_hook_params.body = nil
+    end
+    return auth_hook_params, url
+end
+
+-- timeout in ms
+local function http_req(url, auth_hook_params)
+
+    local httpc = http.new()
+    httpc:set_timeout(1000 * 10)
+    local res, err = httpc:request_uri(url, auth_hook_params)
+    if err then
+        core.log.error("FAIL REQUEST [ ", core.json.encode(auth_hook_params), " ] failed! res is nil, err:", err)
+        return nil, err
+    end
+
+    return res
+end
+
+local function get_auth_info(config, ctx, action, path, client_ip, auth_token)
+    local errmsg
+    local myheaders = request_headers(config, ctx)
+    myheaders["X-Client-Ip"] = client_ip
+    myheaders["Authorization"] = auth_token
+    myheaders["Auth-Hook-Id"] = config.auth_hook_id
+    local args = get_hook_args(config.hook_args)
+    args['hook_path'] = path
+    args['hook_action'] = action
+    args['hook_client_ip'] = client_ip
+    core.response.set_header("hook-cache", 'no-cache')
+    local auth_hook_params, url = hook_configure_params(args, config, myheaders)
+    local res, err = http_req(url, auth_hook_params)
+    if err then
+        core.log.error("fail request: ", url, ", err:", err)
+        return {
+            status = 500,
+            err = "request to hook-server failed, err:" .. err
+        }
+    end
+
+    if res.status ~= 200 and res.status ~= 401 then
+        return {
+            status = 500,
+            err = 'request to hook-server failed, status:' .. res.status
+        }
+    end
+
+    local res_body, res_err = json.decode(res.body)
+    if res_err then
+        errmsg = 'check permission failed! parse response json failed!'
+        core.log.error("json.decode(", res.body, ") failed! err:", res_err)
+        return { status = res.status, err = errmsg }
+    else
+        errmsg = res_body.message
+        return { status = res.status, err = errmsg, body = res_body }
+    end
+end
+
+function _M.rewrite(conf, ctx)
+
+    local url = ctx.var.uri
+    local action = ctx.var.request_method
+    local client_ip = ctx.var.http_x_real_ip or core.request.get_ip(ctx)
+    local config = conf
+    local auth_token, err = get_auth_token(ctx)
+    res_init_headers(config)
+    if auth_token then
+        local res
+        if config.hook_cache then

Review comment:
       We can't cache the res as the client_ip is various.

##########
File path: doc/plugins/auth-hook.md
##########
@@ -0,0 +1,182 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+-[English](../../plugins/auth-hook.md)
+
+# table of Contents
+
+-[**Name**](#first name) -[**Attribute**](#Attribute) -[**Dependencies**](#Dependencies) -[**How ​​to enable**](#How to enable) -[**Test plugin**](#Test plugin) -[**Disable plugins**](#Disable plugins)
+
+## first name
+
+`auth-hook` is an authentication and authorization plug-in, add `auth-hook` to a `service` or `route`.
+The auth-hook function is provided by its own auth-server, and it is sufficient to provide an authorization authentication interface according to the corresponding data structure.
+
+## Attributes
+
+| Name                      | Type          | Required | Default Value | Valid Value | Description                                                                                                                                                                                                                                                                                                                                                                                                             |
+| ------------------------- | ------------- | -------- | ------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| auth_hook_uri             | string        | Required |               |             | Set the access route of `auth-server`                                                                                                                                                                                                                                                                                                                                                                                   |
+| auth_hook_id              | string        | Optional | "unset"       |             | Set `auth_hook_id`, the `auth_hook_id` will be carried in the header `Auth-Hook-Id` to request a custom auth-server service                                                                                                                                                                                                                                                                                             |
+| auth_hook_method          | string        | Optional | "GET"         |             | Set the access method of `auth-server`, the default is `GET`, only `POST`, `GET` are allowed                                                                                                                                                                                                                                                                                                                            |
+| hook_headers              | array[string] | Optional |               |             | Specify the header parameters of the business request. Proxy request hook service, which will carry `Authorization` by default                                                                                                                                                                                                                                                                                          |
+| hook_args                 | array[string] | Optional |               |             | Specify request query parameters, proxy requests hook service with query parameters                                                                                                                                                                                                                                                                                                                                     |
+| hook_res_to_headers       | array[string] | Optional |               |             | Specify the fields in the data body of the data returned by the hook service, add the headers parameter and pass it to the upstream service, such as `user_id=15` in the data data, splicing `hook_res_to_header_prefix` and Replace the next `_` with `-` into the header, request upstream services with `X-user-id`, if the selected field is an object or array, it will be converted to a json string as its value |
+| hook_res_to_header_prefix | string        | Optional |               |             | User `hook_res_to_headers` carries parameters and converts to header field prefix                                                                                                                                                                                                                                                                                                                                       |
+| hook_cache                | boolean       | Optional | false         |             | Whether to cache the same token requesting the data body of the hook service, the default is `false` According to your own business conditions, if it is enabled, it will be cached for 60S                                                                                                                                                                                                                             |
+| check_termination         | boolean       | Optional | true          |             | Whether to request the auth-server to immediately interrupt the request and return an error message after verification, `true` is enabled by default to intercept and return immediately, if set to `false`, auth-server will also return an error Continue to release and delete all mapping header fields set by `hook_res_to_headers`.                                                                               |
+
+## Dependencies
+
+### Deploy your own auth service
+
+The service needs to provide auth interface routing, and at least the following data structure is required to return the data body, we need the `data` data body
+
+```json
+{
+    "message":"success",
+    "data":{
+        "user_id":15,
+        "......": "......"
+    }
+}
+```
+
+## How to enable
+
+1. Create a Route or Service object and enable the `auth-hook` plugin.
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+    "methods": ["GET"],
+    "uri": "/*",
+    "plugins": {
+        "auth-hook": {
+                       "auth_hook_id": "order",
+                       "auth_hook_method": "POST",
+                       "auth_hook_uri": "http://common-user-pro_1.dev.xthktech.cn/api/user/gateway-auth",
+                       "hook_cache": false,
+                       "check_termination": true,
+                       "hook_headers": [
+                         "X-app-name"
+                       ],
+                       "hook_res_to_header_prefix": "XT-",
+                       "hook_res_to_headers": [
+                         "user_id",
+                         "student_id"
+                       ]
+                     }
+    },
+    "upstream": {
+        "type": "roundrobin",
+        "nodes": {
+            "www.baidu.com:80": 1
+        }
+    }
+}'
+```
+
+## Test plugin
+
+#### First get the custom `auth-server` authentication service token:
+
+Assume:
+
+```shell script
+eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2MTI2OTY1NTIsInN0dWRlbnRfaWQiOjk0ODY3LCJ1c2VyX2lkIjoxMDE0czONTV9.WYqjytm6.
+```
+
+#### Use the obtained token to make a request attempt
+
+-Missing token

Review comment:
       Need a space after `-`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org