[go: nahoru, domu]

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: hidding real message when password or username is error #6707

Merged
merged 2 commits into from
Mar 27, 2022
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
4 changes: 2 additions & 2 deletions apisix/plugins/basic-auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ function _M.rewrite(conf, ctx)
-- 3. check user exists
local cur_consumer = consumers[username]
if not cur_consumer then
return 401, { message = "Invalid user key in authorization" }
return 401, { message = "Invalid user authorization" }
end
core.log.info("consumer: ", core.json.delay_encode(cur_consumer))


-- 4. check the password is correct
if cur_consumer.auth_conf.password ~= password then
return 401, { message = "Password is error" }
return 401, { message = "Invalid user authorization" }
end

-- 5. hide `Authorization` request header if `hide_credentials` is `true`
Expand Down
2 changes: 1 addition & 1 deletion apisix/plugins/ldap-auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function _M.rewrite(conf, ctx)
create_consumer_cache, consumer_conf)
local consumer = consumers[userdn]
if not consumer then
return 401, {message = "Invalid API key in request"}
return 401, {message = "Invalid user authorization"}
end
consumer_mod.attach_consumer(ctx, consumer, consumer_conf)

Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/plugins/basic-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ HTTP/1.1 401 Unauthorized
$ curl -i -ubar:bar http://127.0.0.1:9080/hello
HTTP/1.1 401 Unauthorized
...
{"message":"Invalid user key in authorization"}
{"message":"Invalid user authorization"}
```

- password is invalid:
Expand All @@ -114,7 +114,7 @@ HTTP/1.1 401 Unauthorized
$ curl -i -ufoo:foo http://127.0.0.1:9080/hello
HTTP/1.1 401 Unauthorized
...
{"message":"Password is error"}
{"message":"Invalid user authorization"}
```

- success:
Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/plugins/ldap-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ HTTP/1.1 401 Unauthorized
$ curl -i -uuser:password1 http://127.0.0.1:9080/hello
HTTP/1.1 401 Unauthorized
...
{"message":"Invalid user key in authorization"}
{"message":"Invalid user authorization"}
```

- password is invalid:
Expand All @@ -113,7 +113,7 @@ HTTP/1.1 401 Unauthorized
$ curl -i -uuser01:passwordfalse http://127.0.0.1:9080/hello
HTTP/1.1 401 Unauthorized
...
{"message":"Password is error"}
{"message":"Invalid user authorization"}
```

- success:
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/latest/plugins/basic-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ HTTP/1.1 401 Unauthorized
$ curl -i -ubar:bar http://127.0.0.1:9080/hello
HTTP/1.1 401 Unauthorized
...
{"message":"Invalid user key in authorization"}
{"message":"Invalid user authorization"}
```

- 密码错误:
Expand All @@ -114,7 +114,7 @@ HTTP/1.1 401 Unauthorized
$ curl -i -ufoo:foo http://127.0.0.1:9080/hello
HTTP/1.1 401 Unauthorized
...
{"message":"Password is error"}
{"message":"Invalid user authorization"}
...
```

Expand Down
4 changes: 2 additions & 2 deletions t/plugin/basic-auth.t
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ GET /hello
Authorization: Basic YmFyOmJhcgo=
--- error_code: 401
--- response_body
{"message":"Invalid user key in authorization"}
{"message":"Invalid user authorization"}
--- no_error_log
[error]

Expand All @@ -209,7 +209,7 @@ GET /hello
Authorization: Basic Zm9vOmZvbwo=
--- error_code: 401
--- response_body
{"message":"Password is error"}
{"message":"Invalid user authorization"}
--- no_error_log
[error]

Expand Down