-
Notifications
You must be signed in to change notification settings - Fork 862
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
AWSCredentialsFactory.TryGetAWSCredentials() returns invalid SSOAWSCredentials #1821
Comments
Examine behavior in other SDKs on how these handle client name and callback. |
As a original author of #1701 , do you have any input or better workaround for this @awschristou ? |
I don't believe the SDK can make assumptions around how to handle SSOAWSCredentials by default. For example, it may be reasonable to open a browser to log in when running an application that uses the SDK on a desktop, but if a system is running at the command line or within a service, different behavior may be required. SSOAWSCredentials may also need to be configured to suit the security and auditing needs of a system, so a generalized configuration may not be ideal. Having said this, I defer to members of the SDK team (eg @ashishdhingra @ppittle @normj ) for their expertise in this space. |
THANK YOU the 2.1.0 release of Amazon.Extensions.Configuration.SystemsManager broke the IConfigurationBuilder.AddSystemsManager extension method (2.0.0 worked fine for SSO) for running locally and this is the only thing that fixed it. |
@awschristou I agree that assuming default settings for authentication (especially SSO) is always fraught with danger and conflicts because everyone will have a slightly different set up. However, there is a reasonable case to be made that neither of these missing If an
At the very least, even setting these values specifically to |
I have a suggestion that I think would resolve this in a satisfactory way (hopefully). I validated when the I think the biggest issue here is that it's currently checking for that If it would delay the validation of those two properties until they were actually required then users could use the AWS CLI or similar method to execute their AWS SSO login. Then the code can happily use that login until that cached authorization is expired. If they would prefer that their project code does the login then they would need to add custom code like mentioned aboved to allow that individual project to execute the login process. TL;DR: If it's going to use the cached login then don't check for these properties until a new login is needed. Then the project can support other methods of SSO login like using the AWS CLI's SSO login. |
Based on @KenHundley's merged PR, I was able to get my .net core test project to work with AWS CLI v2 sso login. I did however have to keep the AWSSDK.SSOOIDC package reference. I have created AWSSSO.S3Buckets as a sample project for demonstration purposes. |
Hi @RamonEbdonSS, Good afternoon. Please review the comment from @boyersnet and see if the issue is resolved for you in the latest SDK version. Thanks, |
I thought I had tested it without the SSOOIDC project, but I guess the dlls were still in the bin folder. I took a look at the code again and it would be pretty easy to remove the reference to SSOOIDC, but I would not be able to remove the AWSSDK.SSO reference since it's used to generate the credentials even when the token is cached. However, if you don't want you include the SSO and SSOOIDC Dlls in your production release you can add <PackageReference Include="AWSSDK.SSO" Version="3.7.0.23">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="AWSSDK.SSOOIDC" Version="3.7.0.23">
<PrivateAssets>all</PrivateAssets>
</PackageReference> This will include them when building locally, but exclude them when using |
Apologies for the delayed response as I am no longer working for that company (this is my personal GH account). @KenHundley 's PR #1850 seems to at least allow a workflow where you obtain a token on the CLI first, then use those AWS Credentials without further modification. That's at least as good as the process when I was using saml2aws, so I'm happy to close this issue as "resolved". Regards, |
|
Apologies for drudging up this (already closed) issue, but I believe I'm still experiencing the aformentioned symptoms and I'd love some help troubleshooting. .NET Core version: netcoreapp3.1 AWS SDK Version(s)
Code in question
I've confirmed that the C# type of Steps I've taken on the CLI (note that I've swapped my real profile name with
I can confirm that at this stage, @KenHundley @ashishdhingra, any ideas? Are there steps I can take to troubleshoot why my token isn't being found in the SSO token cache originally implemented (I guess I'd need to verify that hashing the start url and hex-encoding the resulting bytes actually produes the correct identifier)? Should I open a new issue with this information? |
Ah, ok, I think I found the issue by enabling logging to the console. Looks like the token file that's been generated in the cache has an unparseable ExpiresAt time. I'm not sure who's generating that file, but this seems like a bug somewhere. Please advise. @KenHundley @ashishdhingra 439 [11] ERROR Amazon.Runtime.Credentials.Internal.SsoTokenCache (null) - Unable to load token cache for start url: |
Are you running the latest CLI version? I think the may have changed the format of the cached date at some point. |
Ah, thanks @KenHundley, that did it. All appears to be working now! Hope this helps the next reader. |
@ardove - I'm curious to understand why you are getting the credentials out of the credential store?
If you use the options builder and specify the profile in the configuration you should get that "for free" like I've done here: https://github.com/boyersnet/AWSSSO.S3Buckets/blob/main/AWSSSO.S3Buckets/Program.cs#L15 |
@boyersnet for this specific use case, I was only using it to try to identify where my problem was coming from and limit the number of classes in play. We do actually use it in some legacy situations with .NET Framework though. I'm already familiar with how the configuration system in .NET Framework & the AWS SDK works. Thanks! |
Description
My company has an SSO setup in AWS (auth via Azure) to allow users to obtain temporary role credentials. Having just updated one of our .NET AWS applications to AWSSDK v3.7.x (via NuGET) from v3.3.x, I was no longer able to run the app locally to access AWS using my credentials (which can be successfully obtained via AWS CLI v2).
The app was previously (using AWSSDK v3.3.x) implicitly detecting my credentials in both ~/.aws/credentials and local Environment vars when creating an
AmazonS3Client()
, but this is now failing. According to the sequence of credentials detection, it should be fine, and it does appear as if the SDK is finding my shared credentials file, since it's returning the correct type, but the app is throwing an exception when trying to use the returnedAWSCredentials
object.Following the basic guide to access credentials and profiles, creating a
new SharedCredentialsFile()
successfully locates and loads my credentials file, and the returnout AWSCredentials
is returning anSSOAWSCredentials
object, but the object is invalid because two mandatory properties in the(SSOAWSCredentialsOptions)Options
property are null:ClientName
andSsoVerificationCallback
.When attempting to use the generated credentials in an
AmazonS3Client()
, exceptions are returned saying either:Or:
But, if I manually set those two properties, it all works:
ClientName
appears to accept (and work with) any random string. It doesnt appear to be relevant to any credentials Profile names.The new inline delegate() for
SsoVerificationCallback
is simply sendingVerificationUriComplete
to my systems default browser to do the SSO login and device authentication. (I have a check to make sureSystem.Environment.UserInteractive
is true as well.)Reproduction Steps
Attempt to access any AWS service using an
SSOAWSCredentials
object returned byAWSCredentialsFactory.TryGetAWSCredentials()
Environment
Resolution
Can the AWSSDK be updated to return some sort of default values in
ClientName
andSsoVerificationCallback
in anSSOAWSCredentials.Options
object?Or at least update the linked documentation above with a notice to manually handle this scenario and specify that it must be dealt with?
This is a 🐛 bug-report
The text was updated successfully, but these errors were encountered: