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

login: use browser for interactive login #6593

Merged
merged 13 commits into from
Jun 20, 2018

Conversation

yugangw-msft
Copy link
Contributor

By default, if browser is available, CLI will use it for login. No more device code copy & paste.
The device code login is still available, through az login --use-device-code in case desktop is unavailable say SSH session, cloud shell, etc. CLI will also pick this up if it can't launch the browser in such situations.

this will address #5413

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

  • I adhere to the Command Guidelines.

@codecov-io
Copy link

codecov-io commented Jun 18, 2018

Codecov Report

Merging #6593 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff         @@
##           dev   #6593   +/-   ##
===================================
  Coverage    0%      0%           
===================================
  Files       11      11           
  Lines      145     145           
  Branches    11      11           
===================================
  Misses     145     145

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b4a58e...f9edc9c. Read the comment docs.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

Mostly questions. Would like @troydai to take a look at the web server stuff.

2.0.39
++++++
* Minor fixes
* authentication: support authorization code flow for interactive login
Copy link
Member

Choose a reason for hiding this comment

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

I would make this more clear:

* `login`: Improve flow when using interactive login. The browser will not be opened for you.

Question, does the auth code auto-populate the field?

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 is a new flow and device code is no longer involved

# pylint: disable=line-too-long

# backup greeting pages if official ones from "docs.microsoft.com" are unavailable
ok_html = ('<!DOCTYPE html>'
Copy link
Member

Choose a reason for hiding this comment

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

I'd recommend extracting this out into a separate HTML file for easier maintenance.

# handle 2 things:
# a. On OSX sierra, 'python -m webbrowser -t <url>' emits out "execution error: <url> doesn't
# understand the "open location" message"
# b. Python 2.x can't sniff out the default browser
Copy link
Member

Choose a reason for hiding this comment

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

This code is addressing these issues, or these need to be addressed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is addressing these issues. The code was moved over from the appservice module since core module also needs to launch a browser now.

raise CLIError("usage error: '--identity' is not applicable with other arguments")
if any([password, service_principal, username, identity]) and use_device_code:
raise CLIError("usage error: '--use-device-code' is not applicable with other arguments")
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a new parameter for this? If you log in interactively why wouldn't you always want to use the device code?

Copy link
Contributor Author

@yugangw-msft yugangw-msft Jun 18, 2018

Choose a reason for hiding this comment

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

it is just for safeness that in case people still like to use the old device code. I have updated the argument description of --use-device-code to clarify this.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

Correct one typo but otherwise LGTM.

@@ -49,7 +49,7 @@ def load_arguments(self, command):
c.argument('identity', options_list=('-i', '--identity'), action='store_true', help="Log in using the Virtual Machine's identity", arg_group='Managed Service Identity')
c.argument('identity_port', type=int, help="the port to retrieve tokens for login. Default: 50342", arg_group='Managed Service Identity')
c.argument('use_device_code', action='store_true',
help='Login through device code, useful in mobile devices or when browsers are unavailable, e.g. in remote SSH sessions or Cloud Shell')
help="Use CLI's old authentication flow based on device dode. CLI will also use this if it can't launch a browser in your behalf, e.g. in remote SSH or Cloud Shell")
Copy link
Member

Choose a reason for hiding this comment

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

typo: "device code" instead of "device dode".

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.

3 participants