Skip to content

Commit a13c3e4

Browse files
feat: update token to strip newline if found
1 parent ee212da commit a13c3e4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/credproviders/assume_role_provider.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"encoding/json"
1212
"errors"
1313
"fmt"
14-
"io/ioutil"
1514
"net/http"
15+
"os"
1616
"time"
1717

1818
"go.mongodb.org/mongo-driver/v2/internal/aws/credentials"
@@ -74,10 +74,13 @@ func (a *AssumeRoleProvider) RetrieveWithContext(ctx context.Context) (credentia
7474
if tokenFile == "" && roleArn != "" {
7575
return v, errors.New("AWS_ROLE_ARN is set, but AWS_WEB_IDENTITY_TOKEN_FILE is missing")
7676
}
77-
token, err := ioutil.ReadFile(tokenFile)
77+
token, err := os.ReadFile(tokenFile)
7878
if err != nil {
7979
return v, err
8080
}
81+
if token[len(token)-1] == '\n' {
82+
token = token[:len(token)-1]
83+
}
8184

8285
sessionName := a.AwsRoleSessionNameEnv.Get()
8386
if sessionName == "" {

0 commit comments

Comments
 (0)