-
Notifications
You must be signed in to change notification settings - Fork 0
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: avoid assuming api.konghq in URI and support private link global api endpoint #165
Conversation
366e570
to
8d1ef82
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #165 +/- ##
==========================================
+ Coverage 27.90% 27.95% +0.04%
==========================================
Files 106 106
Lines 16347 16358 +11
==========================================
+ Hits 4562 4573 +11
Misses 11303 11303
Partials 482 482 ☔ View full report in Codecov by Sentry. |
@harshadixit12 Let's add a unit test for the changes made in this PR. |
@Prashansa-K I see the repo currently has integration tests - should I create new unit test and update the github pipeline workflow to run the unit test as well? |
@harshadixit12 There are unit tests too in this repo that run in the CI Test workflow (.github/workflows/test.yaml). |
Ah right, my bad, was looking in the wrong dir for unit tests. |
8d1ef82
to
683a9d3
Compare
pkg/konnect/login_service.go
Outdated
@@ -47,6 +47,13 @@ func (s *AuthService) Login(ctx context.Context, email, | |||
|
|||
// getGlobalEndpoint returns the global endpoint for a given base Konnect URL. | |||
func getGlobalEndpoint(baseURL string) string { | |||
// If svc.konghq is present in string, continue with global endpoint private link | |||
if strings.Contains(baseURL, "svc.konghq") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"svc.konghq" can be a constant.
pkg/konnect/login_service.go
Outdated
|
||
return baseEndpointPrivateLink + parts[len(parts)-1] | ||
} | ||
|
||
parts := strings.Split(baseURL, "api.konghq") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string can be a const too.
fix: avoid assuming api.konghq in URI and support private link global api endpoint
Summary
IAM for konnect is global, and we call the global endpoint during login.
This breaks for konnect over privatelink since the base URL does not contain the separator we are looking for.
How have we fixed it?
While creating the baseURL for global endpoint, we are checking for a new separator first for privatelink, since it is unlikely to change.
Why did we choose this approach?
We cannot use the Konnect address provided as-is since IAM is global, and need to switch region in subdomain to global
More details:
https://konghq.atlassian.net/wiki/spaces/~712020bb1b1f365f32471bbc7f249f5d9df3ef/pages/4300111923/Konnect+URL+invalid+when+api.konghq+is+not+in+passed+url
How have I tested this?
Issues resolved
Fix #1488 in Deck
Kong/deck#1488
Testing