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

Discard the local login server on non-desktop environment #1502

Merged
merged 1 commit into from Oct 15, 2019

Conversation

bamarni
Copy link
Contributor

@bamarni bamarni commented Oct 11, 2019

For the dcos-oidc-auth0 login provider, when the user operates the CLI
from a container or a remote machine, the local webserver will not run
on the same machine as the browser. Later on the browser will try to
send the token to eg. localhost:43383, which won't be reachable.

When this situation arises, we had designed the UI to fallback to
printing the login token for copy-pasting, but once the CLI has
successfully initiated the local web server, it doesn't accept input
from STDIN at all, so the user has no chance to copy-paste the token.

This commit updates the CLI to fallback to reading from STDIN when the
browser can't be opened.

Note: as an alternative, it would have been possible to concurrently
wait for data on both the local web server and STDIN, but the current
fix is simpler and covers the container / remote use-cases as expected.

https://jira.mesosphere.com/browse/DCOS_OSS-5591

@@ -21,3 +21,11 @@ func NewOsOpener(logger *logrus.Logger) *OsOpener {
logger: logger,
}
}

// OpenerFunc is a func adapter for the Opener interface.
type OpenerFunc func(string) error
Copy link
Contributor

Choose a reason for hiding this comment

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

This is used only in test https://github.com/dcos/dcos-cli/pull/1502/files#diff-48a7e37bb2ef223e6225547541997ea1R58 so it can be placed in _test.go file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even though it is only used in a test right now, it is meant to be exposed to other projects using this package (to provide a custom open mechanism, or for their own tests).

pkg/login/flow.go Show resolved Hide resolved
@@ -167,29 +167,39 @@ func (f *Flow) triggerMethod(provider *Provider) (acsToken string, err error) {
if provider.ID == DCOSOIDCAuth0 {
loginServer, err = loginserver.New(startFlowURL)
if err != nil {
return "", err
f.logger.Error(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously we returned at this point. Why 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.

This lets use fallback to reading from stdin in that case.

For the `dcos-oidc-auth0` login provider, when the user operates the CLI
from a container or a remote machine, the local webserver will not run
on the same machine as the browser. Later on the browser will try to
send the token to eg. `localhost:43383`, which won't be reachable.

When this situation arises, we had designed the UI to fallback to
printing the login token for copy-pasting, but once the CLI has
successfully initiated the local web server, it doesn't accept input
from STDIN at all, so the user has no chance to copy-paste the token.

This commit updates the CLI to fallback to reading from STDIN when the
browser can't be opened.

Note: as an alternative, it would have been possible to concurrently
wait for data on both the local web server and STDIN, but the current
fix is simpler and covers the container / remote use-cases as expected.

https://jira.mesosphere.com/browse/DCOS_OSS-5591
@bamarni
Copy link
Contributor Author

bamarni commented Oct 14, 2019

@mesosphere-ci run integration tests

@bamarni bamarni merged commit 0adca28 into dcos:master Oct 15, 2019
bamarni added a commit to bamarni/dcos-cli that referenced this pull request Oct 23, 2019
bamarni added a commit to bamarni/dcos-cli that referenced this pull request Oct 23, 2019
This fixes a regression introduced in dcos#1502.

This issue only happens on non-desktop environments.

https://jira.mesosphere.com/browse/DCOS-60349
bamarni added a commit to bamarni/dcos-cli that referenced this pull request Oct 24, 2019
This fixes a regression introduced in dcos#1502, which can cause a
panic on non-desktop environments with browser-based login flows
other than auth0.

https://jira.mesosphere.com/browse/DCOS-60349
bamarni added a commit to bamarni/dcos-cli that referenced this pull request Oct 24, 2019
This fixes a regression introduced in dcos#1502, which can cause a
panic on non-desktop environments with browser-based login flows
other than auth0.

https://jira.mesosphere.com/browse/DCOS-60349
bamarni added a commit to bamarni/dcos-cli that referenced this pull request Oct 24, 2019
This fixes a regression introduced in dcos#1502, which can cause a
panic on non-desktop environments with browser-based login flows
other than auth0.

https://jira.mesosphere.com/browse/DCOS-60349
bamarni added a commit that referenced this pull request Oct 24, 2019
This fixes a regression introduced in #1502, which can cause a
panic on non-desktop environments with browser-based login flows
other than auth0.

https://jira.mesosphere.com/browse/DCOS-60349
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