Skip to content

feat: Support verifying govcloud aws sessions #4087

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

strazzere
Copy link
Contributor

Add support to query govcloud sts endpoints for session tokens.

Description:

While doing some experimentation I noticed that govcloud sessions would never detect, so I added the logic to the session verifier to perform these.

I'm unsure exactly if this is the best way to add the logic in, as if the commercial check fails it will then check if it is a valid govcloud account. So essentially a true-negative will now make two http calls. This might possibly be something that should be gated behind a feature? I was hoping someone at Truffle would have more information on which would be preferred. Part of me thought, no one has ever complained this didn't work so no one else might want it. Though this also could mean no one else has ever realized it wasn't working? Lastly, if this ends up being merged, we may want to do the same with the account check code as well since this also utilizes a similar endpoint.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

Add support to query govcloud sts endpoints
for session tokens.
@strazzere strazzere requested a review from a team as a code owner April 23, 2025 20:33
@kashifkhan0771
Copy link
Contributor

While doing some experimentation I noticed that govcloud sessions would never detect, so I added the logic to the session verifier to perform these.

I believe you meant they are never verified, not "detected," right?
Is the session token pattern the same for both commercial and GovCloud sessions?
If the pattern is indeed the same, and we have two endpoints to verify against with no clear way to determine which secret belongs to which endpoint then your approach seems reasonable.

That said, does the verification API return a specific error when a token is checked against the wrong endpoint?
If so, we should only retry verification in response to that specific error, otherwise we’ll end up re-verifying on every error.

@strazzere
Copy link
Contributor Author

Correct, I meant verified.

Is the session token pattern the same for both commercial and GovCloud sessions?

Yes, there seems to be no difference in the pattern, it is just a base64'ed protobuf blob - per the comments in the code. I attempted to decode them with the referenced links, in hope that the region was accessible (which would give an indication of govcloud or not) however it is not a fully parsed protobuf with any determinable differences.

That said, does the verification API return a specific error when a token is checked against the wrong endpoint?
It will just return a 403 with no special information indicating that it might be govcloud or valid. This is pretty consistent with how using govcloud things for non-govcloud endpoints tends to reply. It just looks "broken" or "invalid".

return true, data, nil
}

ok, data, err = s.attemptVerifyMatch(ctx, resIDMatch, resSecretMatch, resSessionMatch, retryOn403, regionGovCloud, hostGovCloud)
Copy link
Contributor

Choose a reason for hiding this comment

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

As you mentioned, there isn’t a clear way to identify the specific endpoint. The changes look good to me overall.
My only concern is that we might end up attempting GovCloud verification for every error we receive from Commercial.
That said, I’m approving this from my side. If anyone has suggestions for a better approach, feel free to add.

Copy link
Contributor

@abmussani abmussani left a comment

Choose a reason for hiding this comment

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

Please correct me if I am wrong, Everytime attemptVerifyMatch returns with err = nil and ok = false, The changes will try to verify for gov region ?

Even If the token has been expired, attemptVerifyMatch will returns err = nil and ok = false . Aren't we confident that credentials are unverified in this case?

@strazzere
Copy link
Contributor Author

Please correct me if I am wrong, Everytime attemptVerifyMatch returns with err = nil and ok = false, The changes will try to verify for gov region ?

Correct

Even If the token has been expired, attemptVerifyMatch will returns err = nil and ok = false . Aren't we confident that credentials are unverified in this case?

No, if you find gov cloud credentials, they look like expired and unverifiable credentials when hitting the regular endpoint. Upon trying the gov cloud endpoint, it can be seen these are valid and unexpired gov cloud specific credentials.

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