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

Add support for non-interactive logins on headless machines #116

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

Conversation

trietsch
Copy link
Contributor

@trietsch trietsch commented Dec 9, 2022

This is an opinionated approach to support non-interactive logins on headless machines. These types of machines do not have access to a browser, and thus need to receive an authorization code as the starting point to successfully complete the regular OAuth 2.0 Authorization Code flow. This PR implements that and therefore resolves #13, not as a fallback, but explicitly.
Generally it goes as follows:

  1. Create a config, with NonInteractive set to true
  2. Initiate the GetToken process, and you'll be prompted with an input
  3. In a separate process, initiate GetCodeAndConfig, and complete the login flow in the browser. Take note of the printed result, which is a base64 encoded struct, that holds both the authorization code and the used oauth2.config, which is necessary to successfully exchange the code for a token.
  4. Paste the base64 encoded OAuth2ConfigAndCode, which is decoded and unmarshalled, after which the oauth.config in the provided oauth2cli.Config is overwritten by the oauth2.config used during the retrieval of the code.
  5. The code is exchanged for a token

Note that the processes can be executed on the same machine (why would you do that? 😄), or on separate machines (the entire goal of this PR).

@int128 let me know what you think!

@trietsch
Copy link
Contributor Author

@int128 any chance you could take a look at this PR? :)

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.

Provide fallback method if local server is not reachable
1 participant