Skip to content

feat: AWS Iam auth for databases - #23231

Open
bbernays wants to merge 8 commits into
mainfrom
rds-iam-auth
Open

feat: AWS Iam auth for databases#23231
bbernays wants to merge 8 commits into
mainfrom
rds-iam-auth

Conversation

@bbernays

@bbernays bbernays commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

This allows the plugin to handle short lived auth tokens

@bbernays
bbernays requested a review from a team as a code owner August 6, 2026 15:19
@bbernays
bbernays requested a review from disq August 6, 2026 15:19
@bbernays bbernays added the no automerge Block automatic merging label Aug 6, 2026
Comment on lines +377 to +405
// withTokenPathSeparator only exists because `rdsauth.BuildAuthToken` signs a URL with
// an empty path and so omits the `/` that RDS requires. This pins that upstream
// behaviour: it fails when a dependency bump makes the SDK emit the separator itself,
// which is the signal to delete withTokenPathSeparator (and this test) rather than keep
// patching a token that no longer needs it.
func TestRDSAuthTokenStillOmitsPathSeparator(t *testing.T) {
setStaticAWSCredentials(t)

awsCfg, err := loadAWSIAMAuthConfig(context.Background(), &spec.AWSIAMAuthSpec{Region: "us-east-1"})
if err != nil {
t.Fatalf("failed to load aws config: %v", err)
}

const endpoint = "mydb.123456789012.us-east-1.rds.amazonaws.com:5432"
token, err := rdsauth.BuildAuthToken(context.Background(), endpoint, "us-east-1", "cq_user", awsCfg.Credentials)
if err != nil {
t.Fatalf("BuildAuthToken returned error: %v", err)
}

switch {
case strings.HasPrefix(token, endpoint+"/?"):
t.Fatalf("aws-sdk-go-v2 feature/rds/auth now emits the `/` path separator itself: "+
"delete withTokenPathSeparator, stop calling it from signRDSAuthToken, and delete this test "+
"along with TestWithTokenPathSeparator (token = %q)", token)
case !strings.HasPrefix(token, endpoint+"?"):
t.Fatalf("BuildAuthToken returned an unrecognised token shape %q: withTokenPathSeparator "+
"assumes `%s[/]?<query>` and needs to be revisited", token, endpoint)
}
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This can all be removed in the future when aws/aws-sdk-go-v2#3365 is resolved

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.

2 participants