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: allow the same OIDC configuration target multiple HTTPRoutes #3252

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

zhaohuabing
Copy link
Member

@zhaohuabing zhaohuabing commented Apr 23, 2024

This PR changes OIDC cookie suffix to OIDC clientID so multiple HTTPRoutes can share the same OIDC configuration.

Related: #3253

@sadovnikov

@zhaohuabing zhaohuabing requested a review from a team as a code owner April 23, 2024 14:40
@zhaohuabing zhaohuabing requested a review from arkodg April 23, 2024 14:41
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing force-pushed the oidc-enhancement branch 2 times, most recently from 2fc6b38 to a131c18 Compare April 23, 2024 14:44
@zhaohuabing zhaohuabing marked this pull request as draft April 23, 2024 14:48
// We should change this back to use policy UID after Gateway API supports
// targeting a policy to multiple routes.
// See https://github.com/kubernetes-sigs/gateway-api/discussions/2927#discussioncomment-8991869
suffix := utils.Digest32(*oidc.RedirectURL)
Copy link

Choose a reason for hiding this comment

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

The oidc is not present in every security policy and, if it's present, the redirectURL might be missing. I think the code should default to policy.UID, unless the both conditions are met

Copy link
Member Author

Choose a reason for hiding this comment

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

If oidc is not present, then the oauth2 filter won't be created. If RedirectURL is missing, a default RedirectURL is used. However, we should use ClientID here.

@@ -589,7 +589,18 @@ func (t *Translator) buildOIDC(
}

// Generate a unique cookie suffix for oauth filters
suffix := utils.Digest32(string(policy.UID))
// We use the digest of the redirect URL to generate the cookie suffix so that
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont think this is is needed
#2944 adds support for a single oauth2 filter based on the policy name instead of 1 per route, so using a suffix off policy should work

Copy link
Member Author

Choose a reason for hiding this comment

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

For SecurityPolicy targeting Gateway, this is not needed. The purpose is to support multiple routes with the same OIDC configuration.

See test: https://github.com/envoyproxy/gateway/blob/f47625eb5f5762ad4a6bc7da7d5d5d5c1c01eb8c/test/e2e/testdata/oidc-securitypolicy.yaml

Copy link
Contributor

Choose a reason for hiding this comment

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

the issue linked is #2913 which is referring to targeting a SecurityPolicy to a Gateway with oidc set

suggest opening a new issue to handle this case of how to author different SecurityPolicies targeting different routes and yet reuse the same cookie prefix, for that case, my suggestion would be to expose an optional CookiePrefix field in the API

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe only the OIDC configurations with the same ClientID should/must use the same CookiePrefix. If this is true, exposing CookiePrefix to API would be unnecessary and result in abuse.

Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
@zhaohuabing zhaohuabing marked this pull request as ready for review April 23, 2024 17:07
@zhaohuabing zhaohuabing changed the title OIDC enhancement feat: allow the same OIDC configuration target multiple HTTPRoutes Apr 23, 2024
@zhaohuabing
Copy link
Member Author

zhaohuabing commented Apr 24, 2024

@sadovnikov In today's meeting, @arkodg mentioned that EG is going to support targeting a policy to multiple targets. I suggest we hold this and focus on #2999.

https://gateway-api.sigs.k8s.io/geps/gep-2648/#multiple

@zhaohuabing zhaohuabing marked this pull request as draft April 24, 2024 00:33
@sadovnikov
Copy link

@zhaohuabing sounds good. Do you have an idea when https://github.com/kubernetes-sigs/gateway-api will have a new release?

@zhaohuabing
Copy link
Member Author

@zhaohuabing sounds good. Do you have an idea when https://github.com/kubernetes-sigs/gateway-api will have a new release?

The decision has been made, and It doesn't rely on gateway API since SecurityPolicy is EG's extension. I just need to work on this when I have some circles.

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.

None yet

3 participants