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: Modify the callback URL string in auth flow, to support custom base URLs in deployments #5192

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ddl-rliu
Copy link
Contributor

@ddl-rliu ddl-rliu commented Apr 5, 2024

Why are the changes needed?

In the auth flow, it seems that Flyteadmin always generates a callback URL, that looks like foo.tech/callback

However, when Flyte is configured on a custom subpath, this causes an issue, and we actually want the callback to look like foo.tech/custom-subpath/callback

What changes were proposed in this pull request?

By changing the callbackURL variable to "callback", the logic is fixed. Note that this also may require a change to the flyte config, since e.g. foo.tech/custom-subpath/login should be set as an AuthorizedURI in the config.yaml

How was this patch tested?

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

@ddl-rliu ddl-rliu marked this pull request as draft April 5, 2024 22:51
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Apr 5, 2024
@ddl-rliu ddl-rliu changed the title x fix: Use absolute redirectURL in auth callback rather than relative redirectURL, to support custom base URLs in deployments Apr 5, 2024
@@ -29,7 +29,7 @@ const (
)

var (
callbackRelativeURL = config.MustParseURL("/callback")
callbackRelativeURL = config.MustParseURL("callback")
Copy link
Contributor Author

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 becomes URL("foo.tech/custom-subpath/login").ResolveReference(URL("callback")) -> "foo.tech/custom-subpath/callback"

Copy link
Contributor

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

func TestGetCallbackHandler(t *testing.T) {
to help verify this change?

Copy link
Contributor Author

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.

Copy link
Contributor

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!

@ddl-rliu ddl-rliu changed the title fix: Use absolute redirectURL in auth callback rather than relative redirectURL, to support custom base URLs in deployments fix: Modify the callback URL string in auth flow, to support custom base URLs in deployments Apr 9, 2024
@ddl-rliu ddl-rliu force-pushed the rliu.redirect-url branch 2 times, most recently from e9a568c to 3975fa2 Compare April 9, 2024 22:19
@ddl-rliu ddl-rliu marked this pull request as ready for review April 9, 2024 23:29
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Apr 9, 2024
@ddl-rliu ddl-rliu force-pushed the rliu.redirect-url branch 2 times, most recently from 30016de to bb76066 Compare April 9, 2024 23:33
x
Signed-off-by: ddl-rliu <richard.liu@dominodatalab.com>

x

Signed-off-by: ddl-rliu <richard.liu@dominodatalab.com>

x

Signed-off-by: ddl-rliu <richard.liu@dominodatalab.com>
x
Signed-off-by: ddl-rliu <richard.liu@dominodatalab.com>
@ddl-ebrown
Copy link
Contributor

Just FYI - we are successfully running this in our environment with flyte hosted under /flyte. That requires us to do a custom build of flyteadmin though, so we're hoping to see this one make it in as its backwards compatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants