Skip to content

Commit 34c7ca5

Browse files
authored
SPEC-1544 AWS Auth support for AWS Lambda (#744)
1 parent edc8370 commit 34c7ca5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

source/auth/auth.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,18 @@ mechanism_properties
898898

899899
Obtaining Credentials
900900
`````````````````````
901-
Drivers will need AWS IAM credentials (an access key and a secret access key) to complete the steps in the `Signature Version 4 Signing Process
901+
Drivers will need AWS IAM credentials (an access key, a secret access key and optionally a session token) to complete the steps in the `Signature Version 4 Signing Process
902902
<https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html?shortFooter=true>`_. If a username and password are provided drivers
903-
MUST use these for the AWS IAM access key and AWS IAM secret key, respectively. If a username is provided without a password (or vice-versa) drivers
904-
MUST raise an error. An example URI for authentication with MONGODB-AWS using AWS IAM credentials is as follows:
903+
MUST use these for the AWS IAM access key and AWS IAM secret key, respectively. If, additionally, a session token is provided Drivers MUST use it as well. If a username is provided without a password (or vice-versa) or if *only* a session token is provided Drivers MUST raise an error. In other words, regardless of how Drivers obtain credentials the only valid combination of credentials is an access key ID and a secret access key or an access key ID, a secret access key and a session token.
904+
905+
The order in which Drivers MUST search for credentials is:
906+
907+
#. Credentials passed through the URI
908+
#. Environment variables
909+
#. ECS endpoint if and only if ``AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`` is set.
910+
#. EC2 endpoint
911+
912+
An example URI for authentication with MONGODB-AWS using AWS IAM credentials passed through the URI is as follows:
905913

906914
.. code:: javascript
907915
@@ -914,7 +922,9 @@ request. If so, then in addition to a username and password, users MAY also prov
914922
915923
"mongodb://<access_key>:<secret_key>@mongodb.example.com/?authMechanism=MONGODB-AWS&authMechanismProperties=AWS_SESSION_TOKEN:<security_token>"
916924
|
917-
If a username and password are not provided, drivers MUST query a link-local AWS address for temporary credentials.
925+
AWS Lambda runtimes set several `environment variables <https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime>`_ during initialization. To support AWS Lambda runtimes Drivers MUST check a subset of these variables, i.e., ``AWS_ACCESS_KEY_ID``, ``AWS_SECRET_ACCESS_KEY``, and ``AWS_SESSION_TOKEN``, for the access key ID, secret access key and session token, respectively if AWS credentials are not explicitly provided in the URI. The ``AWS_SESSION_TOKEN`` may or may not be set. However, if ``AWS_SESSION_TOKEN`` is set Drivers MUST use its value as the session token.
926+
927+
If a username and password are not provided and the aforementioned enviornment variables are not set, drivers MUST query a link-local AWS address for temporary credentials.
918928
If temporary credentials cannot be obtained then drivers MUST fail authentication and raise an error. Drivers SHOULD
919929
enforce a 10 second read timeout while waiting for incoming content from both the ECS and EC2 endpoints. If the
920930
environment variable ``AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`` is set then drivers MUST assume that it was set by an

0 commit comments

Comments
 (0)