You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Credentials fetched by the driver using AWS endpoints MUST be cached and reused
1104
+
to avoid hitting AWS rate limitations. AWS recommends using a suitable
1105
+
Software Development Kit (SDK) for your langauge. If that SDK supports
1106
+
credential fetch and automatic refresh/caching, then that mechanism can
1107
+
be used in lieu of manual caching.
1108
+
1109
+
If using manual caching, the "Expiration" field MUST be stored
1110
+
and used to determine when to clear the cache. Credentials are considered
1111
+
valid if they are more than five minutes away from expiring; to the reduce the
1112
+
chance of expiration before they are validated by the server.
1113
+
1114
+
If there are no current valid cached credentials, the driver MUST initiate a
1115
+
credential request. To avoid adding a bottleneck that would override the
1116
+
``maxConnecting`` setting, the driver MUST not place a lock on making a
1117
+
request. The cache MUST be written atomically.
1118
+
1119
+
If AWS authentication fails for any reason, the cache MUST be cleared.
1120
+
1121
+
.. note::
1122
+
Five minutes was chosen based on the AWS documentation for `IAM roles for EC2 <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html>`_ : "We make new credentials available at least five minutes before the expiration of the old credentials". The intent is to have some buffer between when the driver fetches the credentials and when the server verifies them.
1123
+
1101
1124
-------------------------
1102
1125
Connection String Options
1103
1126
-------------------------
@@ -1334,6 +1357,7 @@ Q: Should drivers support accessing Amazon EC2 instance metadata in Amazon ECS?
1334
1357
Changelog
1335
1358
=========
1336
1359
1360
+
:2022-10-07: Require caching of AWS credentials fetched by the driver.
1337
1361
:2022-10-05: Remove spec front matter and convert version history to changelog.
1338
1362
:2022-09-07: Add support for AWS AssumeRoleWithWebIdentity.
1339
1363
:2022-01-20: Require that timeouts be applied per the client-side operations timeout spec.
Copy file name to clipboardExpand all lines: source/auth/tests/mongodb-aws.rst
+24
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ There are 6 scenarios drivers MUST test:
10
10
#. ``Assume Role``: Auth via temporary credentials obtained from an STS AssumeRole request
11
11
#. ``Assume Role with Web Identity``: Auth via temporary credentials obtained from an STS AssumeRoleWithWebIdentity request
12
12
#. ``AWS Lambda``: Auth via environment variables ``AWS_ACCESS_KEY_ID``, ``AWS_SECRET_ACCESS_KEY``, and ``AWS_SESSION_TOKEN``.
13
+
#. Caching of AWS credentials fetched by the driver.
13
14
14
15
For brevity, this section gives the values ``<AccessKeyId>``, ``<SecretAccessKey>`` and ``<Token>`` in place of a valid access key ID, secret access key and session token (also known as a security token). Note that if these values are passed into the URI they MUST be URL encoded. Sample values are below.
15
16
@@ -115,3 +116,26 @@ Sample URIs both with and without optional session tokens set are shown below. D
.. note:: No username, password or session token is passed into the URI. Drivers MUST check the environment variables listed above for these values. If the session token is set Drivers MUST use it.
119
+
120
+
121
+
Cached Credentials
122
+
==================
123
+
124
+
Drivers MUST ensure that they are testing the ability to cache credentials.
125
+
Drivers will need to be able to query and override the cached credentials to
126
+
verify usage. To determine whether to run the cache tests, the driver can
127
+
check for the absence of the AWS_ACCESS_KEY_ID and of credentials in the URI.
128
+
129
+
#. Clear the cache.
130
+
#. Create a new client.
131
+
#. Ensure that a ``find`` operation adds credentials to the cache.
132
+
#. Override the cached credentials with an "Expiration" that is within one
133
+
minute of the current UTC time.
134
+
#. Create a new client.
135
+
#. Ensure that a ``find`` operation updates the credentials in the cache.
136
+
#. Poison the cache with an invalid access key id.
137
+
#. Create a new client.
138
+
#. Ensure that a ``find`` operation results in an error.
139
+
#. Ensure that the cache has been cleared.
140
+
#. Ensure that a subsequent ``find`` operation succeeds.
0 commit comments