Skip to content

Commit d46ebd0

Browse files
committed
fix(identity-vault): return nextPage tokens which are API Gateway friendly
> The plain text pipe character (|) and the curly brace character ({ or }) are > not supported for any request URL query string and must be URL-encoded. via [Amazon API Gateway important notes][important-notes] Jira: IAM-1793 [important-notes]: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html#api-gateway-known-issues-rest-apis
1 parent f149c55 commit d46ebd0

File tree

2 files changed

+6
-5
lines changed
  • python-modules
    • cis_identity_vault/cis_identity_vault/models
    • cis_profile_retrieval_service/cis_profile_retrieval_service

2 files changed

+6
-5
lines changed

python-modules/cis_identity_vault/cis_identity_vault/models/user.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import json
1313
import logging
1414
import uuid
15+
import urllib.parse
1516
from boto3.dynamodb.conditions import Attr
1617
from boto3.dynamodb.conditions import Key
1718
from boto3.dynamodb.types import TypeDeserializer
@@ -348,11 +349,12 @@ def _last_evaluated_to_friendly(self, last_evaluated_keys):
348349
next_page.append(id)
349350
# If there are at all any segments left with work, then continue.
350351
if any(next_page):
351-
return ",".join(next_page)
352+
next_page_raw = ",".join(next_page)
353+
return urllib.parse.quote(next_page_raw)
352354
else:
353355
return None
354356

355-
def _next_page_to_dynamodb(self, next_page):
357+
def _next_page_to_dynamodb(self, next_page_raw):
356358
"""
357359
Received from _clients_, and deserialized into something our parallel
358360
Dynamo code understands.
@@ -366,8 +368,9 @@ def _next_page_to_dynamodb(self, next_page):
366368
returns a `list[Optional[Any]]`, that means that we can still make
367369
progress on some segments.
368370
"""
369-
if not next_page:
371+
if not next_page_raw:
370372
return None
373+
next_page = urllib.parse.unquote(next_page_raw)
371374
exclusive_start_keys = []
372375
for last_evaluated_key in next_page.split(","):
373376
if last_evaluated_key == "":

python-modules/cis_profile_retrieval_service/cis_profile_retrieval_service/v2_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ def get(self):
158158

159159
logger.info("Attempting to get all users for connection method: {}".format(args.get("connectionMethod")))
160160
next_page = args.get("nextPage")
161-
if next_page is not None:
162-
next_page = urllib.parse.unquote(next_page)
163161

164162
identity_vault = user.Profile(dynamodb_table, dynamodb_client, transactions=transactions)
165163

0 commit comments

Comments
 (0)