Fix: IoT does not work in server mode (#3644)

Closes #1631
This commit is contained in:
Brian Pandola 2021-02-01 05:15:57 -08:00 committed by GitHub
commit c9dd9cc7f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 120 additions and 13 deletions

View file

@ -34,6 +34,13 @@ UNSIGNED_REQUESTS = {
}
UNSIGNED_ACTIONS = {"AssumeRoleWithSAML": ("sts", "us-east-1")}
# Some services have v4 signing names that differ from the backend service name/id.
SIGNING_ALIASES = {
"eventbridge": "events",
"execute-api": "iot",
"iotdata": "data.iot",
}
class DomainDispatcherApplication(object):
"""
@ -74,6 +81,7 @@ class DomainDispatcherApplication(object):
try:
credential_scope = auth.split(",")[0].split()[1]
_, _, region, service, _ = credential_scope.split("/")
service = SIGNING_ALIASES.get(service.lower(), service)
except ValueError:
# Signature format does not match, this is exceptional and we can't
# infer a service-region. A reduced set of services still use
@ -94,11 +102,6 @@ class DomainDispatcherApplication(object):
# S3 is the last resort when the target is also unknown
service, region = DEFAULT_SERVICE_REGION
if service == "EventBridge":
# Go SDK uses 'EventBridge' in the SigV4 request instead of 'events'
# see https://github.com/spulec/moto/issues/3494
service = "events"
if service == "dynamodb":
if environ["HTTP_X_AMZ_TARGET"].startswith("DynamoDBStreams"):
host = "dynamodbstreams"