Skip to content

Bug: "IdentitySource must be defined only for OAuth2 Authorizer." #3817

@amidabucu

Description

@amidabucu

Description

I am not able to set IdentitySource for REQUEST Authorizer in SAM.

Auth:
        Authorizers:
          MyAuthorizer:
            AuthorizerPayloadFormatVersion: "2.0"
            EnableSimpleResponses: true
            AuthorizerResultTtlInSeconds: 300
            AuthorizerType: REQUEST
            IdentitySource:
              - $request.header.someheader
            FunctionArn: ...

I get the following error: "IdentitySource must be defined only for OAuth2 Authorizer."

What is odd to me that when I set the field in AWS Dashboard and pull the configuration, the property is there:

"Items": [
        {
            "AuthorizerId": ...
            "AuthorizerPayloadFormatVersion": "2.0",
            "AuthorizerType": "REQUEST",
            "AuthorizerUri": ...,
            "EnableSimpleResponses": true,
            "IdentitySource": [
                "$request.header.someheader"
            ],
            "Name": ...
        }
    ]

Could this check be removed?

if self.id_source is not None and not authorizer_type == "JWT":
            raise InvalidResourceException(
                self.api_logical_id, "IdentitySource must be defined only for OAuth2 Authorizer."
            )

Steps to reproduce

Create a REQUEST authorizer with explicitly set identity source as explained above.

Observed result

It will fail with "IdentitySource must be defined only for OAuth2 Authorizer."

Expected result

It accepts the IdentitySource property and applies it in the cloud.

Additional environment details

  1. OS: Ubtuntu
  2. If using the SAM CLI, sam --version:
  3. AWS region: us-east-1

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions