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: use tls config from BTP when connecting to the OIDC provider's well-known endpoint. #4857

Merged
merged 22 commits into from
Jan 7, 2025

Conversation

zhaohuabing
Copy link
Member

Fixes #4838

Release Notes: Yes

@zhaohuabing zhaohuabing requested a review from a team as a code owner December 6, 2024 14:11
@zhaohuabing zhaohuabing marked this pull request as draft December 6, 2024 14:11
Signed-off-by: Huabing Zhao <[email protected]>
test/e2e/tests/oidc_testclient.go Dismissed Show dismissed Hide dismissed
Signed-off-by: Huabing Zhao <[email protected]>
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 51 lines in your changes missing coverage. Please review.

Project coverage is 66.72%. Comparing base (2a5ecaf) to head (f4fbc4a).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/ir/xds.go 0.00% 37 Missing ⚠️
internal/gatewayapi/securitypolicy.go 70.83% 10 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4857      +/-   ##
==========================================
- Coverage   66.77%   66.72%   -0.05%     
==========================================
  Files         209      209              
  Lines       32100    32162      +62     
==========================================
+ Hits        21434    21460      +26     
- Misses       9379     9416      +37     
+ Partials     1287     1286       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhaohuabing zhaohuabing marked this pull request as ready for review December 10, 2024 08:16
Signed-off-by: Huabing Zhao <[email protected]>
@zhaohuabing zhaohuabing changed the title fix: use tls config from BTP to fetch oidc provider endpoints fix: use tls config from BTP when connecting to the OIDC provider's well-known endpoint. Dec 10, 2024
Signed-off-by: Huabing Zhao <[email protected]>
@zhaohuabing zhaohuabing marked this pull request as draft December 10, 2024 09:51
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
@zhaohuabing zhaohuabing marked this pull request as ready for review December 10, 2024 11:22
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
issuer: "http://keycloak.gateway-conformance-infra/realms/master"
authorizationEndpoint: "http://keycloak.gateway-conformance-infra/realms/master/protocol/openid-connect/auth"
tokenEndpoint: "http://keycloak.gateway-conformance-infra/realms/master/protocol/openid-connect/token"
issuer: "https://keycloak.gateway-conformance-infra/realms/master" # Test fetching auth endpoint from the issuer url
Copy link
Member Author

@zhaohuabing zhaohuabing Dec 10, 2024

Choose a reason for hiding this comment

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

Removing tokenEndpoint and authorizationEndpoint so they will be fetched by the Gateway API translator. This is used to verify that EG uses the CA from BackendTLSPolicy when connecting to the OIDC provider's well-known endpoint.

image: busybox:stable
command: ["sh", "-c", "until nc -v -z -w3 keycloak 80; do sleep 2; done"]
image: curlimages/curl:latest
command: ["sh", "-c", "until curl -s -o /dev/null -w '%{http_code}' http://keycloak:80; do sleep 2; done"]
Copy link
Member Author

@zhaohuabing zhaohuabing Dec 10, 2024

Choose a reason for hiding this comment

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

Using curl instead of nc to verify that keycload is ready. This change fixed some flaky OIDC tests.

@@ -23,7 +23,7 @@ func init() {
var OIDCBackendClusterTest = suite.ConformanceTest{
ShortName: "OIDC with BackendCluster",
Description: "Test OIDC authentication",
Manifests: []string{"testdata/oidc-keycloak.yaml", "testdata/oidc-securitypolicy-backendcluster.yaml"},
Manifests: []string{"testdata/oidc-keycloak.yaml"},
Copy link
Contributor

@arkodg arkodg Dec 10, 2024

Choose a reason for hiding this comment

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

see test/e2e/testdata/oidc-securitypolicy-backendcluster.yaml being updated but not in use

Copy link
Member Author

Choose a reason for hiding this comment

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

It's used here:

Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
		t.Run("oidc provider represented by a BackendCluster", func(t *testing.T) {
			testOIDC(t, suite, "testdata/oidc-securitypolicy-backendcluster.yaml")

The creation of SecurityPolicy is now started after keycloak pod is ready, so EG can fetch the auth and token points from the keycloak's well-known endpoint.

@zhaohuabing zhaohuabing requested a review from arkodg December 11, 2024 00:49
arkodg
arkodg previously approved these changes Jan 6, 2025
Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@arkodg arkodg requested review from a team January 6, 2025 22:03
zirain
zirain previously approved these changes Jan 7, 2025
@zhaohuabing zhaohuabing dismissed stale reviews from zirain and arkodg via f4fbc4a January 7, 2025 02:13
@zhaohuabing zhaohuabing requested a review from arkodg January 7, 2025 02:15
Copy link
Contributor

@shawnh2 shawnh2 left a comment

Choose a reason for hiding this comment

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

lgtm

@zirain zirain merged commit 3a39c35 into envoyproxy:main Jan 7, 2025
21 of 22 checks passed
@zhaohuabing zhaohuabing deleted the fix-oidc-issuer-tls branch January 13, 2025 01:28
zhaohuabing added a commit to zhaohuabing/gateway that referenced this pull request Jan 13, 2025
…ell-known endpoint. (envoyproxy#4857)

* add e2e test for OIDC provider with TLS

Signed-off-by: Huabing Zhao <[email protected]>

* delete file

Signed-off-by: Huabing Zhao <[email protected]>

* fix lint

Signed-off-by: Huabing Zhao <[email protected]>

* use TLS config from BTLPolicy to fetch auth endpoint

Signed-off-by: Huabing Zhao <[email protected]>

* refactor

Signed-off-by: Huabing Zhao <[email protected]>

* update release note

Signed-off-by: Huabing Zhao <[email protected]>

* update release note

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix lint

Signed-off-by: Huabing Zhao <[email protected]>

---------

Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
(cherry picked from commit 3a39c35)
Signed-off-by: Huabing Zhao <[email protected]>
zhaohuabing added a commit that referenced this pull request Jan 14, 2025
* fix: nil pointer error (#5000)

* fix: nil pointer error

Signed-off-by: Huabing Zhao <[email protected]>
(cherry picked from commit 10a31f1)
Signed-off-by: Huabing Zhao <[email protected]>

* fix: store one copy of HTTPRoute Extension Filters (#5002)

* fix: store one copy of HTTPRoute Extension Filters

Signed-off-by: Guy Daich <[email protected]>

* fix code review comments

Signed-off-by: Guy Daich <[email protected]>

* check if httproutefilter crd exists

Signed-off-by: Guy Daich <[email protected]>

---------

Signed-off-by: Guy Daich <[email protected]>
(cherry picked from commit 2a5ecaf)
Signed-off-by: Huabing Zhao <[email protected]>

* fix: enable ipv4 compat mode for dual stack cluster support (#5018)

enable ipv4 compat mode for dual stack cluster support

Signed-off-by: Will Tekulve <[email protected]>
(cherry picked from commit e028254)
Signed-off-by: Huabing Zhao <[email protected]>

* fix: explicitly set ip family and family policy in gateway spec (#5019)

* explicitly set ip family and family policy

Signed-off-by: Will Tekulve <[email protected]>

* add TestService cases

Signed-off-by: Will Tekulve <[email protected]>
(cherry picked from commit 4d5d3f0)
Signed-off-by: Huabing Zhao <[email protected]>

* fix: check before setting cookie TTL in sessionPersistence (#5026)

* Check before setting Cookie TTL in Session Persistence

Fixes a null ptr exception when the cookie ttl is nil but was being
accessed without checking if its valid or not

Signed-off-by: Arko Dasgupta <[email protected]>

* simplify logic

Signed-off-by: Arko Dasgupta <[email protected]>
(cherry picked from commit dff0531)
Signed-off-by: Huabing Zhao <[email protected]>

* fix: dont shift listener ports for Standalone mode (#5027)

* fix: dont shift listener ports for Standalone mode

Fixes: #4981

Signed-off-by: Arko Dasgupta <[email protected]>

* test

Signed-off-by: Arko Dasgupta <[email protected]>

* fix lint

Signed-off-by: Arko Dasgupta <[email protected]>

---------

Signed-off-by: Arko Dasgupta <[email protected]>
(cherry picked from commit 84f2ad2)
Signed-off-by: Huabing Zhao <[email protected]>

* fix: shutdown-manager not respecting security context of container spec (#4938)

* Fix shutdown-manager not respecting security context of container spec

Signed-off-by: Dean Coakley <[email protected]>

* Update securityContext testdata

Signed-off-by: Dean Coakley <[email protected]>

* Lint with gci

Signed-off-by: Dean Coakley <[email protected]>

---------

Signed-off-by: Dean Coakley <[email protected]>
(cherry picked from commit 43621b4)
Signed-off-by: Huabing Zhao <[email protected]>

* fix: use tls config from BTP when connecting to the OIDC provider's well-known endpoint. (#4857)

* add e2e test for OIDC provider with TLS

Signed-off-by: Huabing Zhao <[email protected]>

* delete file

Signed-off-by: Huabing Zhao <[email protected]>

* fix lint

Signed-off-by: Huabing Zhao <[email protected]>

* use TLS config from BTLPolicy to fetch auth endpoint

Signed-off-by: Huabing Zhao <[email protected]>

* refactor

Signed-off-by: Huabing Zhao <[email protected]>

* update release note

Signed-off-by: Huabing Zhao <[email protected]>

* update release note

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix lint

Signed-off-by: Huabing Zhao <[email protected]>

---------

Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
(cherry picked from commit 3a39c35)
Signed-off-by: Huabing Zhao <[email protected]>

---------

Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Guy Daich <[email protected]>
Signed-off-by: Will Tekulve <[email protected]>
Signed-off-by: Arko Dasgupta <[email protected]>
Signed-off-by: Dean Coakley <[email protected]>
Signed-off-by: Huabing (Robin) Zhao <[email protected]>
Co-authored-by: Guy Daich <[email protected]>
Co-authored-by: Will Tekulve <[email protected]>
Co-authored-by: Arko Dasgupta <[email protected]>
Co-authored-by: Dean Coakley <[email protected]>
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.

Envoy Gateway OIDC: Error with Self-Signed Certificate
4 participants