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

Implement a disconnected login flow #55

Merged
merged 2 commits into from
Nov 15, 2022
Merged

Conversation

charlieegan3
Copy link
Contributor

@charlieegan3 charlieegan3 commented Oct 28, 2022

Fixes #50.

Test this with:

go run main.go auth login --disconnected

Signed-off-by: Charlie Egan charlieegan3@users.noreply.github.com

Fixes #54.

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
@irbekrm
Copy link
Contributor

irbekrm commented Oct 28, 2022

Thanks Charlie!

Have you tested it?
I tried running go run main.go auth login --disconnected from my laptop and got this output:

irbe@jsctl$ go run main.go auth login --disconnected
Navigate to the URL below to login:
https://auth.jetstack.io/authorize?access_type=offline&audience=https%3A%2F%2Fpreflight.jetstack.io%2Fapi%2Fv1&client_id=jmQwDGl86WAevq6K6zZo6hJ4WUvp14yD&redirect_uri=http%3A%2F%2Flocalhost%3A9999%2Foauth%2Fcallback&response_type=code&scope=openid+profile+offline_access&state=0a3464bd-fa67-4063-8822-1b97a8ba19b4
Enter the URL you were redirected to (http://localhost:9999...) and press enter

I then tried entering the https://auth.jetstack.io/authorize?access_type=offline... URL from my phone, but got an error:

callback

(sorry for the mega image, just wanted to show the URL as well)

@irbekrm
Copy link
Contributor

irbekrm commented Oct 28, 2022

Also, might be good to allow a user to Ctrl-C out of the command whilst it's hanging waiting for user input, perhaps a matter of passing in context, I've not looked at the code yet.

@charlieegan3
Copy link
Contributor Author

I have tested this and it does work. The URL to enter is the localhost9999 one after the redirect completes. The server isn't running so the connection_refused error is expected.

I tried to explain this in the message:

Enter the URL you were redirected to (http://localhost:9999...) and press enter

I do however need to make sure that ctrl+C works so I'll do that now.

@charlieegan3
Copy link
Contributor Author

I have added the interrupt in 98b1cf9

@irbekrm
Copy link
Contributor

irbekrm commented Oct 28, 2022

I have tested this and it does work. The URL to enter is the localhost9999 one after the redirect completes. The server isn't running so the connection_refused error is expected.

Cool I think I have misunderstood it, I assumed that the use case is enterprise VPN setup where folks might not be able to access Jetstack Secure and their cluster from the same machine. What is the use case then and how can this PR be tested?

@charlieegan3
Copy link
Contributor Author

This can be tested on a normal machine / env.

First, run:

go run main.go auth login --disconnected

Visit the URL on any device. Phone or even the same machine.

Copy the localhost:9999 URL into the terminal window.

Press enter.

Verify that you are logged in.

@charlieegan3
Copy link
Contributor Author

waiting for feedback on #50 (comment) before merging

@charlieegan3
Copy link
Contributor Author

We've had some acknowledgment that this ought to work ok now. @irbekrm can you ✅ ?

Copy link
Contributor

@irbekrm irbekrm left a comment

Choose a reason for hiding this comment

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

Thanks for working on this Charlie

/lgtm

@charlieegan3 charlieegan3 merged commit b104053 into main Nov 15, 2022
@charlieegan3 charlieegan3 deleted the disconnected-login branch November 15, 2022 09:29
@charlieegan3
Copy link
Contributor Author

Thanks Irbe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement Request: Authentication on headless machines
3 participants