-
Notifications
You must be signed in to change notification settings - Fork 671
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: Modify the callback URL string in auth flow, to support custom base URLs in deployments #5192
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package auth | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"golang.org/x/oauth2" | ||
|
||
"github.com/flyteorg/flyte/flyteadmin/auth/config" | ||
) | ||
|
||
func TestOAuth2ClientConfig(t *testing.T) { | ||
authCtx := Context{ | ||
oauth2Client: &oauth2.Config{}, | ||
} | ||
|
||
type test struct { | ||
name string | ||
url string | ||
expectedRedirectURL string | ||
} | ||
tests := []test{ | ||
{ | ||
name: "simple publicUrl", | ||
url: "https://flyte.com", | ||
expectedRedirectURL: "https://flyte.com/callback", | ||
}, | ||
{ | ||
name: "custom subpath", | ||
url: "https://flyte.com/custom-subpath/console", | ||
expectedRedirectURL: "https://flyte.com/custom-subpath/callback", | ||
}, | ||
{ | ||
name: "complex publicUrl", | ||
url: "https://flyte.com/login?redirect_url=https://flyte.com/console/select-project", | ||
expectedRedirectURL: "https://flyte.com/callback", | ||
}, | ||
{ | ||
name: "complex publicUrl with custom subpath", | ||
url: "https://flyte.com/custom-subpath/login?redirect_url=https://flyte.com/custom-subpath/console/select-project", | ||
expectedRedirectURL: "https://flyte.com/custom-subpath/callback", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
cfg := authCtx.OAuth2ClientConfig(config.MustParseURL(tt.url)) | ||
assert.Equal(t, tt.expectedRedirectURL, cfg.RedirectURL) | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I believe this is necessary, because when Flyteadmin generates the callback URL, the logic looks like
URL("foo.tech").ResolveReference(URL("/callback")) -> "foo.tech/callback"
In fact, the base URL can have any path after it, but the result is the same.
URL("foo.tech/any/path").ResolveReference(URL("/callback")) -> "foo.tech/callback"
This causes issues when flyte is configured on a custom subpath. To fix this...
By adding
foo.tech/custom-subpath/login
as an AuthorizedURI, and changing the reference to "callback", the logic becomesURL("foo.tech/custom-subpath/login").ResolveReference(URL("callback")) -> "foo.tech/custom-subpath/callback"
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.
Should any tests be updated in
flyte/flyteadmin/auth/handlers_test.go
Line 117 in 2528de7
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.
Added the test here https://github.com/flyteorg/flyte/pull/5192/files#diff-aa5ac252b2ec45c95649a3a874e727e436be5c932e3d93b5b2aadcfcc83d57feR12
Although I could also merge this into handlers_test.go, no strong preference.
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.
I think what you did is better / clearer - thanks!