Skip to content

SSO OIDC access token may expire while application is running #3777

Description

@GFriedrich

Describe the bug

When using the SSO session introduced in last November, the access token of the SSO session is used.
If this access token is expiring while the application is running, all requests to AWS will fail.

Expected Behavior

I would expect that the access token of SSO sessions are refresh throughtout the applications lifetime, so AWS requests don't fail.

Current Behavior

The access token of the SSO session is only refreshed when the client gets constructed. If the access token expires throughout the applications lifetime, the AWS calls will fail.

Reproduction Steps

  1. Make your local AWS config use the SSO sessions.
  2. Start an application e.g. using an S3 client via:
S3Client.builder().credentialsProvider(ProfileCredentialsProvider.create(SOME_SSO_PROFILE_NAME))
  1. Keep the application running until the access token of your current session expires.
  2. Try to call the S3 client.

Possible Solution

When checking the code I found this part:

SdkToken sdkToken = tokenProvider.resolveToken();
Validate.paramNotNull(sdkToken, "Token provided by the TokenProvider is null");
Supplier<GetRoleCredentialsRequest> supplier = () -> request.toBuilder()
.accessToken(sdkToken.token())
.build();

You can see that resolveToken() is called during construction time. This method refreshes the access token if required.
But the following supplier will simply make use of the given access token.

I'm wondering whether it would be enough to simply call the resolveToken() inside of the supplier for the GetRoleCredentialsRequest, so that the access token gets refreshed beforehand. 🤔

Additional Information/Context

No response

AWS Java SDK version used

2.20.7

JDK version used

17.0.6

Operating System and version

Windows 10 22H2

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issue

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions