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(oauth2): add missing www-authenticate headers #11833

Merged

Conversation

nowNick
Copy link
Contributor

@nowNick nowNick commented Oct 24, 2023

Summary

When kong returns 401 Unauthorized response it should return WWW-Authenticate header with proper challenge. Oauth2 was missing this header on some responses.

Related PRs:

RFCs & Materials

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • N/A There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Full changelog

  • add WWW-Authenticate header to all oauth2 401 response

Issue reference

@@ -831,6 +831,11 @@ local function retrieve_token(conf, access_token)
[ERROR] = "invalid_token",
error_description = "The access token is global, but the current " ..
"plugin is configured without 'global_credentials'",
},
{
["WWW-Authenticate"] = 'Bearer realm="service" error=' ..
Copy link
Member

Choose a reason for hiding this comment

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

Did we decide to hardcode realm=service? Or should it be dynamic? Or is there no good way to figure it out? Which would me we’d need to add config.realm so that it could be specified?

@nowNick nowNick force-pushed the feat/implement-missing-www-authenticate-headers-oauth2 branch from feaa52c to db8982b Compare May 9, 2024 12:03
@pull-request-size pull-request-size bot added size/L and removed size/S labels May 9, 2024
@github-actions github-actions bot added schema-change-noteworthy cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee labels May 9, 2024
@nowNick nowNick force-pushed the feat/implement-missing-www-authenticate-headers-oauth2 branch 3 times, most recently from 166d5b3 to 466acab Compare May 9, 2024 12:53
@nowNick nowNick marked this pull request as ready for review May 9, 2024 15:01
@nowNick nowNick requested review from jschmid1 and hanshuebner May 13, 2024 07:35
@nowNick nowNick force-pushed the feat/implement-missing-www-authenticate-headers-oauth2 branch from 466acab to 6831da1 Compare May 21, 2024 16:18
@nowNick nowNick force-pushed the feat/implement-missing-www-authenticate-headers-oauth2 branch from 6831da1 to bded47d Compare May 21, 2024 16:32
@nowNick nowNick removed the cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee label Jun 18, 2024
When server returns 401 Unauthorized response it should
return WWW-Authenticate header as well with proper challenge.
Not all oauth2 401 responses had this header.

Fix: #7772
KAG-321
@nowNick nowNick force-pushed the feat/implement-missing-www-authenticate-headers-oauth2 branch from c3e6432 to 5b40a68 Compare June 18, 2024 14:35
@github-actions github-actions bot added the cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee label Jun 18, 2024
@jschmid1 jschmid1 merged commit e8080e5 into master Jun 19, 2024
27 checks passed
@jschmid1 jschmid1 deleted the feat/implement-missing-www-authenticate-headers-oauth2 branch June 19, 2024 08:21
@github-actions github-actions bot added the incomplete-cherry-pick A cherry-pick was incomplete and needs manual intervention label Jun 19, 2024
@kikito kikito removed the incomplete-cherry-pick A cherry-pick was incomplete and needs manual intervention label Jun 25, 2024
@Kong Kong deleted a comment from team-gateway-bot Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WWW-Authenticate header not present when Kong and plugins return HTTP status 401
5 participants