int128 / int128/oauth2cli

Provide fallback method if local server is not reachable

Open
#13 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
64
Forks
20
Avg merge
7h 13m
Merged PRs (30d)
18

Description

It would be nice if oauth2cli provides a fallback method if the local server is not reachable such as a remote host. This issue is originally from https://github.com/int128/kubelogin/issues/148.

User interaction

Open http://localhost:8000
If you cannot open the browser, visit https://accounts.google.com/... and enter code: xxxxxxxx

Authorization will finish when the local server received a code or user entered a code by keyboard.

Implementation consideration

Redirect URIs are different between the local server and keyboard as:

  • By the local server: redirect_uri=http://localhost:8000
  • By keyboard: redirect_uri=urn:ietf:wg:oauth:2.0:oob

Note that post-process (exchanging code) must use the corresponding redirect URI, or error will be returned.

It may be complex design as:

  1. Goroutine 1 serves the local server.
  2. Goroutine 2 waits for an authorization response and shuts down the local server.
  3. Goroutine 3 waits for a code from keyboard and shuts down the local server.

Unfortunately fmt.Scanf() and io.Stdin.Read() do not support a context and there is no way to break an interaction for now (as https://github.com/golang/go/issues/20280). So the goroutine3 will remain after the authorization.

See also: https://github.com/int128/kubelogin/blob/1.0/oidc.go#L81

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the OAuth flow referenced in kubelogin's oidc.go at line 81 and the issue's redirect URI requirements. Define how the local-server and keyboard paths coordinate, including server shutdown and code exchange. Done means authorization can complete through either the local server or the remote keyboard fallback with the matching redirect URI.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
authentication, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.