Amazon web services 是否可以自定义API网关自定义授权人响应消息和未授权服务器上的状态代码?
如何将状态代码设置为429并从API网关自定义授权人返回自定义消息?我也在搜索此解决方案。我收到了来自我们的自定义授权人的自定义消息和状态代码之类的消息,但未启用。 请参阅此处- 但在为自定义授权人编码时发现,您可以发送401或403Amazon web services 是否可以自定义API网关自定义授权人响应消息和未授权服务器上的状态代码?,amazon-web-services,aws-api-gateway,Amazon Web Services,Aws Api Gateway,如何将状态代码设置为429并从API网关自定义授权人返回自定义消息?我也在搜索此解决方案。我收到了来自我们的自定义授权人的自定义消息和状态代码之类的消息,但未启用。 请参阅此处- 但在为自定义授权人编码时发现,您可以发送401或403 //this will send status - 401 , body - {"message":"unauthorized"} context.fail('Unauthorized') /*this will send status 403 , bo
//this will send status - 401 , body - {"message":"unauthorized"}
context.fail('Unauthorized')
/*this will send status 403 , body - {
"Message": "User is not authorized to access this resource with an explicit deny"
}*/
context.succeed({
"policyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "execute-api:Invoke",
"Effect": "Deny",
"Resource": [
"arn:aws:execute-api:ap-south-1:************/Development/*/*"
]
}
]
}
})
note : like allow you have to create deny policy
我也在寻找这个解决方案。我收到了来自我们的自定义授权人的自定义消息和状态代码之类的消息,但未启用。 请参阅此处- 但在为自定义授权人编码时发现,您可以发送401或403
//this will send status - 401 , body - {"message":"unauthorized"}
context.fail('Unauthorized')
/*this will send status 403 , body - {
"Message": "User is not authorized to access this resource with an explicit deny"
}*/
context.succeed({
"policyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "execute-api:Invoke",
"Effect": "Deny",
"Resource": [
"arn:aws:execute-api:ap-south-1:************/Development/*/*"
]
}
]
}
})
note : like allow you have to create deny policy
这里的功能有点有限。但我发现,通过编辑403和401状态代码的
网关响应
。我的自定义消息将显示给用户
例如,通过保存以下内容并重新部署API。现在,当lambda授权者返回拒绝策略时,我会收到自定义消息
这里的功能有点有限。但我发现,通过编辑403和401状态代码的
网关响应
。我的自定义消息将显示给用户
例如,通过保存以下内容并重新部署API。现在,当lambda授权者返回拒绝策略时,我会收到自定义消息