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

Making username and password as required fields for basic auth plugin #1248

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions lua/apisix/plugins/basic-auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ local schema = {
username = { type = "string" },
password = { type = "string" },
},
required = {"username", "password"}
}

local plugin_name = "basic-auth"
Expand Down
5 changes: 4 additions & 1 deletion t/plugin/basic-auth.t
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ passed
ngx.HTTP_PUT,
[[{
"plugins": {
"basic-auth": {}
"basic-auth": {
"username": "foo",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is wrong.

When a user requests, the authentication information is placed in an HTTP header.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @membphis , I'm a bit unclear, this test case is enabling basic auth plugin using admin api.

The test case 8 does the verification by adding the http header.


=== TEST 8: verify
--- request
GET /hello
--- more_headers
Authorization: Basic Zm9vOmJhcg==
--- response_body
hello world
--- no_error_log
[error]

I agree, in order to enable basic auth the admin does not have to send the same info again. Any suggestion how to tackle this would be helpful. I guess the scenario is the same with key-auth plugin as well.

"password": "bar"
}
},
"upstream": {
"nodes": {
Expand Down