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

Use new OAuth endpoint for login #4267

Merged
merged 1 commit into from
May 24, 2021
Merged

Use new OAuth endpoint for login #4267

merged 1 commit into from
May 24, 2021

Conversation

rl-gitpod
Copy link
Contributor

Remove testing code
Use correct scope for all workspaces
Clean up logging + error behaviour

// Login walks through the login flow for obtaining a Gitpod token
func Login(ctx context.Context, opts LoginOpts) (token string, err error) {
rl, err := net.Listen("tcp", "localhost:0")
rl, err := net.Listen("tcp", "localhost:64110")
Copy link
Contributor

Choose a reason for hiding this comment

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

I reckon the "use unused port" way is less error prone - or am I missing a reason to hardcode this?

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 agree, but yes, (unfortunately) the redirect URL has to be known to the backend.

Copy link
Member

Choose a reason for hiding this comment

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

Could it be configurable if the port is already used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, not yet at least. The backend validates the full redirect uri, including port, so it would need a way to override that behaviour (which might be worth PR-ing on the lib).

In the interim I've changed it, along with the backend, to try a range of 10 ports and be more explicit about using IPV4 to workaround issues with IPV6 I saw while testing.

@rl-gitpod rl-gitpod force-pushed the rl/local-app-oauth branch 4 times, most recently from c33c7ca to 3ffccb8 Compare May 23, 2021 00:27
Copy link
Contributor

@csweichel csweichel left a comment

Choose a reason for hiding this comment

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

Trying on several ports is a great first step towards making this more resilient.
I tried the login process as part of the OAuth PR. Changes LGTM.

Comment on lines 70 to 71
port := STARTING_PORT_NUM
for port < ENDING_PORT_NUM {
Copy link
Contributor

Choose a reason for hiding this comment

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

A more classic for loop would be easier to understand here I reckon (no searching for port++).

Remove testing code
Use correct scope for all workspaces
Clean up logging + error behaviour

Use tcp4 and 127.0.0.1 to avoid IPV6 issues
@rl-gitpod rl-gitpod merged commit 8402607 into main May 24, 2021
@rl-gitpod rl-gitpod deleted the rl/local-app-oauth branch May 24, 2021 23:24
@rl-gitpod
Copy link
Contributor Author

rl-gitpod commented May 25, 2021

/werft run

👍 started the job as gitpod-build-rl-local-app-oauth.7

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