Hi,
I have setup a custom authorizer to return the following policy:
{
"Effect": "Deny",
"Action": [
"execute-api:Invoke"
],
"Resource": [
"arn:aws:execute-api:{{region}}:{{account-id}}:{{api-id}}/{{stage}}/GET/petstore/v1/pets"
]
},
{
"Effect": "Allow",
"Action": [
"execute-api:Invoke"
],
"Resource": [
"arn:aws:execute-api:{{region}}:{{account-id}}:{{api-id}}/{{stage}}/GET/petstore/v2/pets"
]
}
but I always end up with an exception:
[ asgi_gw_4] l.s.apigateway.authorizers : Unexpected Effect=Deny (expected: "Allow") in Lambda authorizer response
localstack_main | 2023-09-01T15:20:43.323 DEBUG --- [ asgi_gw_4] l.s.apigateway.authorizers : Authorization denied: {"message":"Forbidden"} - Traceback (most recent call last):
localstack_main | File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack_ext/services/apigateway/authorizers.py.enc", line 339, in is_request_authorized
localstack_main | try:AuthorizerService().check_request_authorization(invocation_context)
localstack_main | File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack_ext/services/apigateway/authorizers.py.enc", line 334, in check_request_authorization
localstack_main | D=E.authorize(A)
localstack_main | File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack_ext/services/apigateway/authorizers.py.enc", line 184, in authorize
localstack_main | def authorize(B,invocation_context):C=invocation_context;D=B._get_authorizer_lambda_arn();E=connect_to(region_name=extract_region_from_arn(D)).awslambda;F=B._create_authorizer_event(C);G=E.invoke(FunctionName=D,Payload=to_bytes(json.dumps(F)));A=G.get(_b);A=to_str(A.read())if A else'';LOG.info('Received authorizer result: %s',A);return B.verify_response_policy(A,C)
localstack_main | File "/opt/code/localstack/.venv/lib/python3.10/site-packages/localstack_ext/services/apigateway/authorizers.py.enc", line 169, in verify_response_policy
localstack_main | if D.lower()!='allow':LOG.debug(f'Unexpected Effect={D} (expected: "Allow") in Lambda authorizer response');K={_P:H}if invocation_context.is_v1()else{_B:G};raise DeniedAuthorization(json.dumps(K,separators=(_C,_F)))
localstack_main | localstack_ext.services.apigateway.authorizers.DeniedAuthorization: {"message":"Forbidden"}
I have looked around for similar issues but can’t find anything on this, surely, gateway needs to evaluate a ‘Deny’ effect too but it seems like that isn’t allowed ?
I simply want to allow/disallow calling certain end points like mentioned here.
Runtime version │ 2.1.1.dev | localstack-pro │
│ Docker image │ tag: latest, id: 9cf5d6c2cb02 │
Would appreciate some feedback please.