chore(forward-auth): rename address to uri (#6114)

This commit is contained in:
罗泽轩 2022-01-16 19:31:06 +08:00 committed by GitHub
parent 77626e05a1
commit 73cefc4cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View File

@ -22,7 +22,7 @@ local http = require("resty.http")
local schema = { local schema = {
type = "object", type = "object",
properties = { properties = {
address = {type = "string"}, uri = {type = "string"},
ssl_verify = { ssl_verify = {
type = "boolean", type = "boolean",
default = true, default = true,
@ -57,7 +57,7 @@ local schema = {
keepalive_timeout = {type = "integer", minimum = 1000, default = 60000}, keepalive_timeout = {type = "integer", minimum = 1000, default = 60000},
keepalive_pool = {type = "integer", minimum = 1, default = 5}, keepalive_pool = {type = "integer", minimum = 1, default = 5},
}, },
required = {"address"} required = {"uri"}
} }
@ -106,7 +106,7 @@ function _M.access(conf, ctx)
local httpc = http.new() local httpc = http.new()
httpc:set_timeout(conf.timeout) httpc:set_timeout(conf.timeout)
local res, err = httpc:request_uri(conf.address, params) local res, err = httpc:request_uri(conf.uri, params)
-- block by default when authorization service is unavailable -- block by default when authorization service is unavailable
if not res then if not res then

View File

@ -38,7 +38,7 @@ Forward Auth cleverly moves the authentication and authorization logic to a dedi
| Name | Type | Requirement | Default | Valid | Description | | Name | Type | Requirement | Default | Valid | Description |
| -- | -- | -- | -- | -- | -- | | -- | -- | -- | -- | -- | -- |
| address | string | required | | | Authorization service address (eg. https://localhost/auth) | | uri | string | required | | | Authorization service uri (eg. https://localhost/auth) |
| ssl_verify | boolean | optional | true | | Whether to verify the certificate | | ssl_verify | boolean | optional | true | | Whether to verify the certificate |
| request_headers | array[string] | optional | | | `client` request header that will be sent to the `authorization` service. When it is not set, no `client` request headers are sent to the `authorization` service, except for those provided by APISIX (X-Forwarded-XXX). | | request_headers | array[string] | optional | | | `client` request header that will be sent to the `authorization` service. When it is not set, no `client` request headers are sent to the `authorization` service, except for those provided by APISIX (X-Forwarded-XXX). |
| upstream_headers | array[string] | optional | | | `authorization` service response header that will be sent to the `upstream`. When it is not set, will not forward the `authorization` service response header to the `upstream`. | | upstream_headers | array[string] | optional | | | `authorization` service response header that will be sent to the `upstream`. When it is not set, will not forward the `authorization` service response header to the `upstream`. |
@ -97,7 +97,7 @@ $ curl -X PUT http://127.0.0.1:9080/apisix/admin/routes/1
"uri": "/headers", "uri": "/headers",
"plugins": { "plugins": {
"forward-auth": { "forward-auth": {
"address": "http://127.0.0.1:9080/auth", "uri": "http://127.0.0.1:9080/auth",
"request_headers": ["Authorization"], "request_headers": ["Authorization"],
"upstream_headers": ["X-User-ID"], "upstream_headers": ["X-User-ID"],
"client_headers": ["Location"] "client_headers": ["Location"]

View File

@ -41,10 +41,10 @@ __DATA__
location /t { location /t {
content_by_lua_block { content_by_lua_block {
local test_cases = { local test_cases = {
{address = "http://127.0.0.1:8199"}, {uri = "http://127.0.0.1:8199"},
{request_headers = {"test"}}, {request_headers = {"test"}},
{address = 3233}, {uri = 3233},
{address = "http://127.0.0.1:8199", request_headers = "test"} {uri = "http://127.0.0.1:8199", request_headers = "test"}
} }
local plugin = require("apisix.plugins.forward-auth") local plugin = require("apisix.plugins.forward-auth")
@ -56,8 +56,8 @@ __DATA__
} }
--- response_body --- response_body
done done
property "address" is required property "uri" is required
property "address" validation failed: wrong type: expected string, got number property "uri" validation failed: wrong type: expected string, got number
property "request_headers" validation failed: wrong type: expected array, got string property "request_headers" validation failed: wrong type: expected array, got string
@ -137,7 +137,7 @@ property "request_headers" validation failed: wrong type: expected array, got st
data = [[{ data = [[{
"plugins": { "plugins": {
"forward-auth": { "forward-auth": {
"address": "http://127.0.0.1:1984/auth", "uri": "http://127.0.0.1:1984/auth",
"request_headers": ["Authorization"], "request_headers": ["Authorization"],
"upstream_headers": ["X-User-ID"], "upstream_headers": ["X-User-ID"],
"client_headers": ["Location"] "client_headers": ["Location"]
@ -155,7 +155,7 @@ property "request_headers" validation failed: wrong type: expected array, got st
data = [[{ data = [[{
"plugins": { "plugins": {
"forward-auth": { "forward-auth": {
"address": "http://127.0.0.1:1984/auth", "uri": "http://127.0.0.1:1984/auth",
"request_headers": ["Authorization"] "request_headers": ["Authorization"]
}, },
"proxy-rewrite": { "proxy-rewrite": {