Skip to content

S3: implements support for session token - #156

Open
ahouene wants to merge 5 commits into
PowerDNS:mainfrom
ahouene:s3-session-token
Open

S3: implements support for session token#156
ahouene wants to merge 5 commits into
PowerDNS:mainfrom
ahouene:s3-session-token

Conversation

@ahouene

@ahouene ahouene commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This PR adds support for session tokens to be used along the access key id and the secret access key in the S3 backend, directly or through a file.
It also adds support for trailing newlines in those files.

The tests have been updated to take these additions into account. The test against the full test suite in case credential files are used is being removed because it doesn't bring much and just makes the tests longer. Instead, we test that the S3 Backend is correctly created and can (or cannot) perform a write operation with various file contents.

@ahouene
ahouene requested a review from neilcook August 11, 2026 15:40
@ahouene ahouene self-assigned this Aug 11, 2026
@ahouene
ahouene requested a review from Luit August 11, 2026 15:46
Comment thread backends/s3/s3.go
Comment on lines +526 to +532
creds := credentials.NewStaticV4(opt.AccessKey, opt.SecretKey, opt.SessionToken)
if opt.AccessKeyFile != "" {
creds = credentials.New(&FileSecretsCredentials{
AccessKeyFile: opt.AccessKeyFile,
SecretKeyFile: opt.SecretKeyFile,
RefreshInterval: opt.SecretsRefreshInterval,
AccessKeyFile: opt.AccessKeyFile,
SecretKeyFile: opt.SecretKeyFile,
SessionTokenFile: opt.SessionTokenFile,
RefreshInterval: opt.SecretsRefreshInterval,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there should be stronger checking of valid configurations. I think that you only want either static credentials, or file based credentials, but the current code allows for example opt.SessionTokenFile to be defined, along with opt.AccessKey and opt.SecretKey, but the session token file will be ignored.

// https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure
// and https://docs.docker.com/engine/swarm/secrets.
//
// It supports an empty or deleted SessionTokenFile.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

// It supports an empty or deleted SessionTokenFile. is stated here, but see comment in RetrieveWithCredContext


var sessionToken []byte
if c.SessionTokenFile != "" {
sessionToken, err = os.ReadFile(c.SessionTokenFile)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the file was deleted, this will return an error, which contradicts what the comment above states about empty or deleted files.

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.

2 participants