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

Add 'WWW-Authenticate' header for reponses w/ status code 401 Unauthorized. #588

Merged
merged 1 commit into from
Oct 13, 2015

Conversation

ybv
Copy link
Contributor

@ybv ybv commented Oct 4, 2015

Adds a new header 'WWW-Authenticate' for 401 responses, the header value typically should include a challenge with some information about the authentication scheme (key-auth) #587

@ybv
Copy link
Contributor Author

ybv commented Oct 4, 2015

Lokks ike the tests are failing on master too?

@@ -61,6 +61,8 @@ local function send_response(status_code)
ngx.log(ngx.ERR, tostring(content))
end
ngx.ctx.stop_phases = true -- interrupt other phases of this request
elseif status_code == _M.status_codes.HTTP_UNAUTHORIZED then
ngx.header["WWW-Authenticate"] = "Key realm=\""..constants.NAME.."\"" -- respond with a challenge
Copy link
Member

Choose a reason for hiding this comment

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

This cannot be hard-coded here since 401 is also returned for Basic authentication. This should probably be handled in the access.lua file of authentication plugins. Feel free to disagree or update the PR, otherwise I'll change it myself, but we appreciate contributions so... :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thibaultcha definitely, I'm so new to lua/kong land. Just made this PR after 30 mins of going through code, I'll update the PR soon, thanks so much for pointing in the right direction!

@ybv ybv force-pushed the www-auth-header-401 branch 2 times, most recently from 9fb994a to c07893e Compare October 10, 2015 07:06
@ybv
Copy link
Contributor Author

ybv commented Oct 10, 2015

@thibaultcha let me know if it looks alright now.

@ybv
Copy link
Contributor Author

ybv commented Oct 10, 2015

@thibaultcha removing the header check, not sure how to get headers from kong.tools.http_call =, thoughts?

@thibaultcha
Copy link
Member

On mobile now, but the headers are the third returned argument I think. It is used many times in the tests. Otherwise this looks good, just a test on each would be amazing.

@ybv
Copy link
Contributor Author

ybv commented Oct 11, 2015

@thibaultcha looks like the table returned from http_call here has only 2 keys. The other tests that test for headers seem to send those headers as a part of request?

@thibaultcha
Copy link
Member

Only because it ignores the third one

On Oct 10, 2015, at 10:26 PM, Vaibhav Krishna Irugu Guruswamy notifications@github.com wrote:

@thibaultcha looks like the table returned from http_call here has only 2 keys.


Reply to this email directly or view it on GitHub.

@ybv
Copy link
Contributor Author

ybv commented Oct 11, 2015

@thibaultcha alright done, let me know if all looks good and I'll squash my commits to just one.

@ybv
Copy link
Contributor Author

ybv commented Oct 12, 2015

@thibaultcha ping!

@subnetmarco
Copy link
Member

@ybv looks good to me, can you squash?

@ybv
Copy link
Contributor Author

ybv commented Oct 13, 2015

@thefosk @thibaultcha done!

@thibaultcha
Copy link
Member

Thank you!

thibaultcha added a commit that referenced this pull request Oct 13, 2015
Add 'WWW-Authenticate' header for reponses w/ status code 401 Unauthorized.
@thibaultcha thibaultcha merged commit f080069 into Kong:master Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants