Skip to content

Commit

Permalink
Merge pull request #668 from asfadmin/rew/pr-3696-camel-case-s3creden…
Browse files Browse the repository at this point in the history
…tials

PR-3696 Change s3credential response to use camelCase keys
  • Loading branch information
reweeden authored Dec 13, 2022
2 parents 1128305 + e789ef1 commit bbe1b2e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
14 changes: 7 additions & 7 deletions docs/s3access.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ The response is your temporary credentials as returned by Amazon STS. See the
**Example:**
```json
{
"AccessKeyId": "AKIAIOSFODNN7EXAMPLE",
"SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"SessionToken": "LONGSTRINGOFCHARACTERS.../HJLgV91QJFCMlmY8slIEOjrOChLQYmzAqrb5U1ekoQAK6f86HKJFTT2dONzPgmJN9ZvW5DBwt6XUxC9HAQ0LDPEYEwbjGVKkzSNQh/",
"Expiration": "2021-01-27 00:50:09+00:00"
"accessKeyId": "AKIAIOSFODNN7EXAMPLE",
"secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"sessionToken": "LONGSTRINGOFCHARACTERS.../HJLgV91QJFCMlmY8slIEOjrOChLQYmzAqrb5U1ekoQAK6f86HKJFTT2dONzPgmJN9ZvW5DBwt6XUxC9HAQ0LDPEYEwbjGVKkzSNQh/",
"expiration": "2021-01-27 00:50:09+00:00"
}
```

Expand Down Expand Up @@ -94,9 +94,9 @@ def lambda_handler(event, context):
# Set up separate boto3 clients for download and upload
download_client = boto3.client(
"s3",
aws_access_key_id=creds["AccessKeyId"],
aws_secret_access_key=creds["SecretAccessKey"],
aws_session_token=creds["SessionToken"]
aws_access_key_id=creds["accessKeyId"],
aws_secret_access_key=creds["secretAccessKey"],
aws_session_token=creds["sessionToken"]
)
# Lambda needs to have permission to upload to destination bucket
upload_client = boto3.client("s3")
Expand Down
7 changes: 7 additions & 0 deletions lambda/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,13 @@ def s3credentials():
creds = get_s3_credentials(user_profile.user_id, role_session_name, policy)
timer.mark()

creds = {
"accessKeyId": creds["AccessKeyId"],
"secretAccessKey": creds["SecretAccessKey"],
"sessionToken": creds["SessionToken"],
"expiration": creds["Expiration"]
}

log.debug("timing for s3credentials()")
timer.log_all(log)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,10 +1430,10 @@ def test_s3credentials(
response = client.http.get("/s3credentials")

assert response.json_body == {
"AccessKeyId": "access_key",
"SecretAccessKey": "secret_access_key",
"SessionToken": "session_token",
"Expiration": "expiration"
"accessKeyId": "access_key",
"secretAccessKey": "secret_access_key",
"sessionToken": "session_token",
"expiration": "expiration"
}
assert response.status_code == 200

Expand Down
8 changes: 4 additions & 4 deletions tests_e2e/test_s3credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def test_authenticated_user_can_get_creds(urls, auth_cookies):

assert r.status_code == 200
assert list(data.keys()) == [
"AccessKeyId",
"SecretAccessKey",
"SessionToken",
"Expiration"
"accessKeyId",
"secretAccessKey",
"sessionToken",
"expiration"
]

0 comments on commit bbe1b2e

Please sign in to comment.