Skip to content

Commit

Permalink
fix: make the message clearer when API key is missing (#11370)
Browse files Browse the repository at this point in the history
  • Loading branch information
pottekkat authored Jun 26, 2024
1 parent de1669d commit 6d2de7e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apisix/plugins/key-auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function _M.rewrite(conf, ctx)
end

if not key then
return 401, {message = "Missing API key found in request"}
return 401, {message = "Missing API key in request"}
end

local consumer_conf = consumer_mod.plugin(plugin_name)
Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/plugins/key-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ curl http://127.0.0.2:9080/index.html -i
```
HTTP/1.1 401 Unauthorized
...
{"message":"Missing API key found in request"}
{"message":"Missing API key in request"}
```

```shell
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/latest/plugins/key-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ curl http://127.0.0.2:9080/index.html -i
```shell
HTTP/1.1 401 Unauthorized
...
{"message":"Missing API key found in request"}
{"message":"Missing API key in request"}
```

```shell
Expand Down
2 changes: 1 addition & 1 deletion t/plugin/cors.t
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ ExternalHeader1: val
ExternalHeader2: val
ExternalHeader3: val
--- response_body
{"message":"Missing API key found in request"}
{"message":"Missing API key in request"}
--- error_code: 401
--- response_headers
Access-Control-Allow-Origin: https://sub.domain.com
Expand Down
2 changes: 1 addition & 1 deletion t/plugin/key-auth.t
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ apikey: 123
GET /hello
--- error_code: 401
--- response_body
{"message":"Missing API key found in request"}
{"message":"Missing API key in request"}
Expand Down

0 comments on commit 6d2de7e

Please sign in to comment.