Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make the message clearer when API key is missing #11370

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading