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 Exception #168

Open
hutterm opened this issue Mar 31, 2023 · 7 comments · Fixed by #170
Open

AWS SSO Exception #168

hutterm opened this issue Mar 31, 2023 · 7 comments · Fixed by #170

Comments

@hutterm
Copy link

hutterm commented Mar 31, 2023

when pointing sleet to a profile with AWS SSO credentials sleet responds with

[System.InvalidOperationException] Assembly AWSSDK.SSOOIDC could not be found or loaded. This assembly must be available at runtime to use Amazon.Runtime.SSOAWSCredentials, AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604.

for reference, my sleet.json uses "profileName": "aws-dev"
and a corresponding entry is in my ~/.aws/config :

[profile aws-dev]
sso_start_url = ...
sso_region = ...
sso_account_id = ...
sso_role_name = ...
region = ...
output = json

I'm getting new credentials with aws sso login --profile aws-dev before, so everything seems to be setup correctly on my side.

Looks like sleet might just need to update it's dependency on the aws core sdk libraries?

@emgarten
Copy link
Owner

Are you using sleet.exe or the dotnet tool package?

I'll take a look at updating to the latest AWS. From the error it looks like a dependency didn't make it into the package or exe.

@hutterm
Copy link
Author

hutterm commented Mar 31, 2023

dotnet tool

@emgarten
Copy link
Owner

emgarten commented Apr 2, 2023

@hutterm try installing the updated version here: https://www.nuget.org/packages/Sleet/5.1.3

Let me know if your SSO profile works with these changes. If not I may need some help from you to get the AWS profile load correct.

@hutterm
Copy link
Author

hutterm commented Apr 3, 2023

Can confirm, it works! Thanks a lot!

heads up for anyone that comes across this:
I initially hit this ArgumentNullException: Parameter name: Options property cannot be empty: ClientName
simitlar to aws/aws-sdk-net#1821

I worked through that thread and as it turns out my AWS CLI needed an update as well. After that it worked flawlessly when previously logging in with aws sso login --profile ...

@hutterm hutterm closed this as completed Apr 3, 2023
@emgarten
Copy link
Owner

emgarten commented Apr 3, 2023

Glad it worked!

Thanks for including help on the client name, I'm sure others will run into that as well.

@hutterm
Copy link
Author

hutterm commented Apr 4, 2023

@emgarten Just to explain to you quickly what was throwing there. I went through your code to see what was happening.

First finding:
your additions here:
https://github.com/emgarten/Sleet/pull/170/files#diff-c5ea30c889009ba11fba4fe02f94c6094f2a031e07b079f92e5c1198f07c3e16R182
are actually not being hit! the SSO Credentials are correctly gotten from line 177 already.

Second:

                            if (credFile.TryGetProfile(profileName, out var profile))
                            {
                                // Successfully created the credentials using the profile
                                var awsCredentials = profile.GetAWSCredentials(profileSource: null);
                                ((SSOAWSCredentials)awsCredentials).Options.ClientName = "SSO";
                                ((SSOAWSCredentials)awsCredentials).Options.SsoVerificationCallback = ssoArgs =>
                                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
                                    {
                                        FileName = ssoArgs.VerificationUriComplete, UseShellExecute = true
                                    });
                                amazonS3Client = new AmazonS3Client(awsCredentials, config);
                            }

with this code in place, you will actually handle timed out credentials. You probably would need some considerations to not get a CastException if you have other credentials and I'm not sure if you can start a process form every context where Sleet would run, but that code at least opens the browser for me and does the SSO verification and gets a new token.
Without that code, if that ClientName and SsoVerificationCallback is missing, that's when you get the ArgumentNullException I talked about here.

@emgarten emgarten reopened this Apr 5, 2023
@emgarten
Copy link
Owner

I would happy to take a PR that improves the SSO experience. I don't have an AWS account that signs in this way which makes it difficult for me to improve this myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants