Skip to content

Conversation

@xrstf
Copy link
Contributor

@xrstf xrstf commented Oct 6, 2025

Summary

The original design for per-workspace-auth was in the front-proxy only, only later did I add it to each shard, primarily to make writing e2e tests easier.

In the front-proxy, there is a chain of middleware handlers that

  • resolve the cluster path
  • find the authenticator for a workspace
  • inject the authenticator into the request context
  • the handle the "optional auth", where the authenticator is read from the context again

This means the actual authenticator used (i.e. in genericConfig.Authentication.Authenticator) is one that simply reads the authenticator from step 3 (out of the context) and calls it.

In the shard variant, this concept was kept the same, i.e. there are handlers that are involved to make the per-workspace-authenticator work. This however means that any other component in kcp that uses the .Authenticator has one that has no concept of per-workspace auth anymore, since the middlewares are not being called.

Thankfully the concept of middlewares is not required to make per-workspace-auth working on the shard level, so this commit condenses the logic on the shards to instead provide a "standalone" authenticator that does all steps listed above in one big function. This required the Kube patch introduced via #3622 (kcp-dev/kubernetes#180)

Required for this refactoring is untangling the previous LocalProxy initialisation routine. Now the cluster index is started separatedly (since the new standalone auther needs it) and then handed into the middleware.

What Type of PR Is This?

/kind bug

Related Issue(s)

Fixes #3614

Release Notes

Fix TokenReviews when using WorkspaceAuthentication

@kcp-ci-bot kcp-ci-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/bug Categorizes issue or PR as related to a bug. labels Oct 6, 2025
@kcp-ci-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kcp-ci-bot kcp-ci-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 6, 2025
@xrstf
Copy link
Contributor Author

xrstf commented Oct 6, 2025

/test all

@xrstf
Copy link
Contributor Author

xrstf commented Oct 7, 2025

/test all

@xrstf
Copy link
Contributor Author

xrstf commented Oct 7, 2025

/retest

1 similar comment
@xrstf
Copy link
Contributor Author

xrstf commented Oct 7, 2025

/retest

@xrstf xrstf marked this pull request as ready for review October 8, 2025 08:59
@kcp-ci-bot kcp-ci-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 8, 2025
@xrstf
Copy link
Contributor Author

xrstf commented Oct 8, 2025

/retest

@xrstf
Copy link
Contributor Author

xrstf commented Oct 8, 2025

what is going on

/retest

@xrstf
Copy link
Contributor Author

xrstf commented Oct 8, 2025

/retest

1 similar comment
@xrstf
Copy link
Contributor Author

xrstf commented Oct 8, 2025

/retest

Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

/approve

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2025
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: ec0dd348203a2a35a800c02ad66cf4e57fc03d19

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 14, 2025
@embik
Copy link
Member

embik commented Oct 14, 2025

/retest

@kcp-ci-bot kcp-ci-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 15, 2025
xrstf added 2 commits October 16, 2025 08:46
…eviews to be handled

The original design for per-workspace-auth was in the front-proxy only, only later did I add it to
each shard, primarily to make writing e2e tests easier.

In the front-proxy, there is a chain of middleware handlers that

* resolve the cluster path
* find the authenticator for a workspace
* inject the authenticator into the request context
* the handle the "optional auth", where the authenticator is read from the context again

This means the actual authenticator used (i.e. in genericConfig.Authentication.Authenticator) is one
that simply reads the authenticator from step 3 (out of the context) and calls it.

In the shard variant, this concept was kept the same, i.e. there are handlers that are involved to
make the per-workspace-authenticator work. This however means that any other component in kcp that
uses the .Authenticator has one that has no concept of per-workspace auth anymore, since the
middlewares are not being called.

Thankfully the concept of middlewares is not required to make per-workspace-auth working on the
shard level, so this commit condenses the logic on the shards to instead provide a "standalone"
authenticator that does all steps listed above in one big function.

Required for this refactoring is untangling the previous LocalProxy initialisation routine. Now the
cluster index is started separatedly (since the new standalone auther needs it) and then handed into
the middleware.

On-behalf-of: @SAP [email protected]
Signed-off-by: Marvin Beckers <[email protected]>
This test will only work in sharded setups if and when we extend the local workspace authenticator
to use replication, so it can see other shards.

On-behalf-of: @SAP [email protected]
Signed-off-by: Marvin Beckers <[email protected]>
@kcp-ci-bot kcp-ci-bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 16, 2025
@kcp-ci-bot kcp-ci-bot requested a review from embik October 16, 2025 06:47
@kcp-ci-bot kcp-ci-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 16, 2025
@embik
Copy link
Member

embik commented Oct 16, 2025

/retest

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 16, 2025
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 71602157249b683d0cd5ed0011b7bb80391cd73d

@kcp-ci-bot kcp-ci-bot merged commit d2e3d9e into kcp-dev:main Oct 16, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: TokenReviews not working with WorkspaceAuthentication

3 participants