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

[buddy] Truncate AssumeRole session name to API limits #45202

Merged
merged 6 commits into from
Aug 20, 2024

Conversation

greedy52
Copy link
Contributor

@greedy52 greedy52 commented Aug 7, 2024

Fixes #44833

buddy PR:

changelog: Fixed an issue AWS access fails when the username is longer than 64 characters

lib/srv/app/cloud.go Outdated Show resolved Hide resolved
@@ -74,7 +74,7 @@ func (g *credentialsGetter) Get(_ context.Context, request GetCredentialsRequest
logrus.Debugf("Creating STS session %q for %q.", request.SessionName, request.RoleARN)
return stscreds.NewCredentials(request.Provider, request.RoleARN,
func(cred *stscreds.AssumeRoleProvider) {
cred.RoleSessionName = request.SessionName
cred.RoleSessionName = TruncateRoleSessionName(request.SessionName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark about clashes here.

@greedy52 greedy52 requested a review from codingllama August 13, 2024 15:25
lib/utils/aws/aws.go Show resolved Hide resolved

// MaxRoleSessionName is the maximum length of the role session name used by the AssumeRole call.
// https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html
MaxRoleSessionName = 64
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: just to make it explicit that this is not count but name length.

Suggested change
MaxRoleSessionName = 64
MaxRoleSessionNameLength = 64

@@ -2745,6 +2745,13 @@ message AppSessionStart {
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// AWS contains common AWS session information.
AWSSessionMetadata AWS = 9 [
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make it more generic like

Suggested change
AWSSessionMetadata AWS = 9 [
AWSMetadata AWS = 9 [

I wonder what other fields can be added to AWSSessionMetadata, where AWSMetadata would be more flexible and in the case of other AWS fields not related to AWSSession context I think that the AWSMetadata it will be a better fit.

Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

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

It seems like this exploded in scope a bit with the audit and proto changes. I would do audit separately, but happy to keep it here if you prefer.

api/proto/teleport/legacy/types/events/events.proto Outdated Show resolved Hide resolved
lib/auth/sessions.go Outdated Show resolved Hide resolved
lib/auth/sessions.go Outdated Show resolved Hide resolved
lib/auth/sessions_test.go Outdated Show resolved Hide resolved
lib/auth/sessions_test.go Outdated Show resolved Hide resolved
lib/auth/sessions_test.go Outdated Show resolved Hide resolved
lib/utils/aws/aws.go Show resolved Hide resolved
lib/utils/aws/aws.go Outdated Show resolved Hide resolved
lib/utils/aws/aws.go Outdated Show resolved Hide resolved
lib/utils/aws/aws.go Outdated Show resolved Hide resolved
@greedy52 greedy52 requested a review from codingllama August 19, 2024 18:36
@greedy52
Copy link
Contributor Author

greedy52 commented Aug 19, 2024

Guessing a value for audit makes me uneasy.

I feel the same but it's not an easy fix. I decided to drop the audit from the PR and make the fix separately. Another issue with current design (how the session event is sent) is the event happens on the root but not on the leaf.

-- update
issue tracked as #45603

@greedy52 greedy52 enabled auto-merge August 20, 2024 15:32
@greedy52 greedy52 added this pull request to the merge queue Aug 20, 2024
Merged via the queue into master with commit b09748b Aug 20, 2024
40 checks passed
@greedy52 greedy52 deleted the STeve/pr-buddy-44836 branch August 20, 2024 16:10
@public-teleport-github-review-bot

@greedy52 See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Failed
branch/v16 Failed

greedy52 added a commit that referenced this pull request Aug 21, 2024
* 44833 Truncate AssumeRole session name to API limits

* Link reference

Co-authored-by: STeve (Xin) Huang <[email protected]>

* Hash the username and add audit log

* review comments

* remove audit

---------

Co-authored-by: Joao Ubaldo <[email protected]>
@public-teleport-github-review-bot

@greedy52 See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Failed
branch/v16 Failed

greedy52 added a commit that referenced this pull request Aug 21, 2024
* 44833 Truncate AssumeRole session name to API limits

* Link reference

Co-authored-by: STeve (Xin) Huang <[email protected]>

* Hash the username and add audit log

* review comments

* remove audit

---------

Co-authored-by: Joao Ubaldo <[email protected]>
greedy52 added a commit that referenced this pull request Aug 21, 2024
* 44833 Truncate AssumeRole session name to API limits

* Link reference

Co-authored-by: STeve (Xin) Huang <[email protected]>

* Hash the username and add audit log

* review comments

* remove audit

---------

Co-authored-by: Joao Ubaldo <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Aug 21, 2024
* [buddy] Truncate AssumeRole session name to API limits (#45202)

* 44833 Truncate AssumeRole session name to API limits

* Link reference

Co-authored-by: STeve (Xin) Huang <[email protected]>

* Hash the username and add audit log

* review comments

* remove audit

---------

Co-authored-by: Joao Ubaldo <[email protected]>

* reintroduce logrus

---------

Co-authored-by: Joao Ubaldo <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Aug 21, 2024
* 44833 Truncate AssumeRole session name to API limits

* Link reference



* Hash the username and add audit log

* review comments

* remove audit

---------

Co-authored-by: Joao Ubaldo <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Aug 21, 2024
* 44833 Truncate AssumeRole session name to API limits

* Link reference



* Hash the username and add audit log

* review comments

* remove audit

---------

Co-authored-by: Joao Ubaldo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal server error due to long AWS AssumeRole session name
5 participants