Terser authentication logic in front-proxy#4126
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| } | ||
|
|
||
| // When configured to enable auth other than ClientCert, this returns true. | ||
| func (c *Authentication) AdditionalAuthEnabled() bool { |
There was a problem hiding this comment.
Will be suprised if this will not break anything.
|
This whole thing is a mess. Basically the front-proxy tries to authenticate a request but just lets it through if it doesn't succeed unless the workspace has per-workspace auth configured. This causes a problem in the tests because there the shards have fixed identities with tokens (from the csv file) that the front-proxy doesn't know about. This only works because the This also hides a bug if a static token is used to access a worksapce with per-workspace auth - this will get declined on the front-proxy simply because per-workspace auth does not recognize the static token. |
1fafcb7 to
24c9370
Compare
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Summary
That logic never sat right with me and it seems to cause a logic error.
The original error was fixed with #4125, which moved the front-proxy back to its old behaviour that relies on essentially a race for the test to function:
The root cause of the error was that an authenticated request came through but the authenticator wasn't yet ready, so the original code here:
kcp/pkg/proxy/filters/filters.go
Lines 49 to 59 in 5a9d2e2
Would return
nil, falsefrom herekcp/pkg/authentication/filters.go
Lines 67 to 73 in 5a9d2e2
Because the handler that should add the workspace authenticator in the cotext silently fails here:
kcp/pkg/authentication/filters.go
Lines 41 to 44 in 5a9d2e2
Because of the change that validated authenticators before returning them the authenticator was in the index later than the test assumed, turning this into a race.
Anyhow - this doesn't fix that issue. I just noticed this issue because of that.
This fixes another problem that currently isn't tested - if a request with a static token comes in for a workspace that has per-workspace authentication configured the request will get denied.
I skipped writing a test for this because this will be fixed as part of #4100
What Type of PR Is This?
/kind bug
Related Issue(s)
Fixes #
Release Notes