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

feat(acl): added a config always_use_authenticated_groups to support using authenticated groups even when an authenticated consumer exists. #13184

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

catbro666
Copy link
Contributor

@catbro666 catbro666 commented Jun 7, 2024

Summary

Currently, authenticated groups will only be used when there is no consumer or the consumer is anonymous. When there is an authenticated consumer, there is no way to use authenticated groups, only the groups associated with the consumer will be used.

This PR adds a config always_use_authenticated_groups to support using authenticated groups even when an authenticated consumer exists. If enabled, it will first try to use authenticated groups and will fallback to use the groups associated with the consumer if authenticated groups don't exist, which is consistent with the logic in the anonymous consumer case.

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
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

https://konghq.atlassian.net/browse/FTI-5945

@github-actions github-actions bot added core/clustering plugins/acl schema-change-noteworthy cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee labels Jun 7, 2024
@catbro666 catbro666 force-pushed the fti-5945-authenticated-groups-when-consumer-exists branch 5 times, most recently from d5f6aaa to 66e51d0 Compare June 11, 2024 03:22
@catbro666 catbro666 force-pushed the fti-5945-authenticated-groups-when-consumer-exists branch from 66e51d0 to eef8f21 Compare June 17, 2024 09:34
@catbro666 catbro666 force-pushed the fti-5945-authenticated-groups-when-consumer-exists branch from eef8f21 to 3056a31 Compare July 2, 2024 03:59
@catbro666 catbro666 force-pushed the fti-5945-authenticated-groups-when-consumer-exists branch from 3056a31 to 3b10c9e Compare July 8, 2024 02:27
@catbro666 catbro666 requested a review from StarlightIbuki July 31, 2024 08:35
@StarlightIbuki
Copy link
Contributor

Please resolve the conflict.

@catbro666 catbro666 force-pushed the fti-5945-authenticated-groups-when-consumer-exists branch from 3b10c9e to ac6d84c Compare August 1, 2024 02:54
…t using authenticated groups even when an authenticated consumer exists.

Currently, authenticated groups will only be used when there is no consumer
or the consumer is anonymous. When there is an authenticated consumer,
there is no way to use authenticated groups, only the groups associated
with the consumer will be used.

This PR adds a config `always_use_authenticated_groups` to support using
authenticated groups even when an authenticated consumer exists. If
enabled, it will first try to use authenticated groups and will fallback
to use the groups associated with the consumer if authenticated groups
don't exist, which is consistent with the logic in the anonymous consumer
case.

https://konghq.atlassian.net/browse/FTI-5945
@catbro666 catbro666 force-pushed the fti-5945-authenticated-groups-when-consumer-exists branch from ac6d84c to 441dc7b Compare August 1, 2024 02:57
kong/plugins/acl/handler.lua Outdated Show resolved Hide resolved
@@ -16,6 +16,7 @@ return {
type = "array",
elements = { type = "string" }, }, },
{ hide_groups_header = { type = "boolean", required = true, default = false, description = "If enabled (`true`), prevents the `X-Consumer-Groups` header from being sent in the request to the upstream service." }, },
{ always_use_authenticated_groups = { type = "boolean", required = true, default = false, description = "If enabled (`true`), the authenticated groups will always be used even when an authenticated consumer already exists. If the authenticated groups don't exist, it will fallback to use the groups associated with the consumer. By default the authenticated groups will only be used when there is no consumer or the consumer is anonymous." } },
Copy link
Contributor

Choose a reason for hiding this comment

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

Which part of the code implements the logic of:

it will fallback to use the groups associated with the consumer

and is it covered in the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@windmgc windmgc merged commit c882de9 into master Aug 6, 2024
27 checks passed
@windmgc windmgc deleted the fti-5945-authenticated-groups-when-consumer-exists branch August 6, 2024 07:54
@team-gateway-bot
Copy link
Collaborator

Cherry-pick failed for master, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git remote add upstream https://github.com/kong/kong-ee
git fetch upstream master
git worktree add -d .worktree/cherry-pick-13184-to-master-to-upstream upstream/master
cd .worktree/cherry-pick-13184-to-master-to-upstream
git checkout -b cherry-pick-13184-to-master-to-upstream
ancref=$(git merge-base 3a1eeed4a7011259b845cc51b9585e1e1c54de76 6f24d0413fc4b0ce99103ba75595f7c08892464f)
git cherry-pick -x $ancref..6f24d0413fc4b0ce99103ba75595f7c08892464f

@github-actions github-actions bot added the incomplete-cherry-pick A cherry-pick was incomplete and needs manual intervention label Aug 6, 2024
@kikito kikito removed the incomplete-cherry-pick A cherry-pick was incomplete and needs manual intervention label Aug 13, 2024
oowl pushed a commit that referenced this pull request Aug 15, 2024
…t using authenticated groups even when an authenticated consumer exists. (#13184)

* feat(acl): added a config `always_use_authenticated_groups` to support using authenticated groups even when an authenticated consumer exists.

Currently, authenticated groups will only be used when there is no consumer
or the consumer is anonymous. When there is an authenticated consumer,
there is no way to use authenticated groups, only the groups associated
with the consumer will be used.

This PR adds a config `always_use_authenticated_groups` to support using
authenticated groups even when an authenticated consumer exists. If
enabled, it will first try to use authenticated groups and will fallback
to use the groups associated with the consumer if authenticated groups
don't exist, which is consistent with the logic in the anonymous consumer
case.

https://konghq.atlassian.net/browse/FTI-5945

---------

Co-authored-by: Xumin <[email protected]>
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.

5 participants