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

AWS SSO CLI fallback to device authorization grant doesn't work #9092

Closed
1 task
ikattur-ota opened this issue Nov 20, 2024 · 6 comments
Closed
1 task

AWS SSO CLI fallback to device authorization grant doesn't work #9092

ikattur-ota opened this issue Nov 20, 2024 · 6 comments
Labels
bug This issue is a bug. closed-for-staleness configure p2 This is a standard priority issue sso

Comments

@ikattur-ota
Copy link

ikattur-ota commented Nov 20, 2024

Describe the bug

Running this in a Vagrant box, PKCE-based Authorization for SSO doesn't work as it needs a browser.
Following recommendations in the official blog post and docs, I tried using the --use-device-code flag but it doesn't seem to make a difference:

vagrant@ubuntu2204:~$ aws configure sso --profile "AWSAdministratorAccess" --use-device-code
SSO session name (Recommended): my-sso
SSO start URL [None]: https://d-xxx.awsapps.com/start
SSO region [None]: us-east-1
SSO registration scopes [sso:account:access]:
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:

https://oidc.us-east-1.amazonaws.com/authorize?response_type=code&client_id=xxxx...

Workaround:
I had to follow this two-step process, as the --use-device-code flag seems to work for the aws sso login command:

vagrant@ubuntu2204:~$ aws configure sso-session
SSO session name: my-sso
SSO start URL [None]: https://d-xxx.awsapps.com/start
SSO region [None]: us-east-1
SSO registration scopes [sso:account:access]:

Completed configuring SSO session: my-sso
Run the following to login and refresh access token for this session:

aws sso login --sso-session my-sso

vagrant@ubuntu2204:~$ aws sso login --sso-session my-sso --use-device-code
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:

https://device.sso.us-east-1.amazonaws.com/

Then enter the code:

xxxx-xxxx
Successfully logged into Start URL: https://d-xxx.awsapps.com/start

And then configure an SSO profile:

vagrant@ubuntu2204:~$ aws configure sso --profile "AWSAdministratorAccess"
SSO session name (Recommended): my-sso
There are n AWS accounts available to you.
Using the account ID xxx
There are 2 roles available to you.
Using the role name "AWSAdministratorAccess"
CLI default client Region [None]: us-west-2
CLI default output format [None]: json

To use this profile, specify the profile name using --profile, as shown:

aws s3 ls --profile AWSAdministratorAccess

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

SSO authorization workflow via OAuth 2.0 device authorization grant to work in the aws configure sso command when --use-device-code option is used.

Current Behavior

See description

Reproduction Steps

See description

Possible Solution

No response

Additional Information/Context

No response

CLI version used

2.22.1

Environment details (OS name and version, etc.)

Linux/5.15.0-91-generic exe/x86_64.ubuntu.22 Python/3.12.6

@ikattur-ota ikattur-ota added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 20, 2024
@ashovlin
Copy link
Member

Thanks for the report! This is an issue in the flag's introduction in 2.22.0. #9090 addresses it, and is queued up for today's daily release. I'll reply again once the release is finished.

@ashovlin
Copy link
Member

This should be addressed in 2.22.2 which was released today.

% aws configure sso --use-device-code
...
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:

https://device.sso.us-east-1.amazonaws.com/

Then enter the code:
...

Let us know if you're still seeing any issues.

@ashovlin ashovlin added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 20, 2024
@ntang-tmx
Copy link

ntang-tmx commented Nov 20, 2024

The behavior changed from the original cli. --no-browser option should give the device url and not the oidc with callback. --use-device-code do work.

aws sso login --profile xxx --no-browser
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:

https://oidc.us-east-1.amazonaws.com/authorize?response_type=code&client_id=W
aws sso login --profile xxx --use-device-code
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:

https://device.sso.us-east-1.amazonaws.com/

Then enter the code:

XXXX-XXXX
aws-cli/2.22.2 Python/3.12.6 Linux/3.10.0-1160.119.1.el7.x86_64 exe/x86_64.rhel.7

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 20, 2024
@ashovlin
Copy link
Member

@ntang-tmx the intended behavior is:

  • --no-browser controls whether the CLI will attempt to open the authorization link in a browser automatically, for both the device code flow and the new authorization code flow. When this is set, the CLI should just print the link without attempting to open it.
  • --use-device-code is the new option to fallback to the device code flow, after 2.22.0 change the default behavior to the auth grant with the callback.

Is your first snippet from 2.22.2 as well? I'd expect to see something like this instead:

% aws sso login --profile <profile> --no-browser
Browser will not be automatically opened.
Please visit the following URL:

https://oidc.us-east-1.amazonaws.com/authorize?response_type...

@ntang-tmx
Copy link

Indeed, the snippet is from another version. 2.22.2 displays the snippet you showed.

You're right, I did not check the 2.22.0 change from 2 days ago.

@ashovlin
Copy link
Member

@ntang-tmx Thanks, so I believe that's working as expected then, but let us know if you're still hitting issues

@ashovlin ashovlin added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 21, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Nov 21, 2024
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness configure p2 This is a standard priority issue sso
Projects
None yet
Development

No branches or pull requests

4 participants