amazon-web-services - 我可以允许匿名访问 AWS API Gateway 文档吗?
问题描述
我有一个 CloudFormation 模板,其中包含使用 OpenAPI 3.0 主体配置的 API 网关。我想让我的 API 的用户可以使用 OpenAPI 规范。理想情况下,在一个不错的 GUI 中,但这个答案表明这是不可能的。我不想设置开发者门户。
我的 CFT 包含为 API 创建文档的 DocumentationVersion 元素。
https://apigateway.[my_aws_region].amazonaws.com/restapis/[my_api_id]/stages/[my_api_stage]/exports/oas30
事实上,当我访问这个 URL 时,我会得到类似的东西
{"logref":"56f5173b-a329-11e9-a8d5-e97c525eb634","message":"Missing Authentication Token"}
这表明这将使用正确的令牌。
此页面显示您可以使用策略控制对 API 文档的访问。(虽然奇怪的是它说要使用的 account_id 是您要授予访问权限的用户之一 - 对吗?)
所以我尝试将以下资源添加到我的 CFT:
"ApiDocumentationAccessPolicy": {
"Type": "AWS::IAM::ManagedPolicy",
"Properties": {
"Description": "Read access to API documentation restricted by IP",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"apigateway:GET"
],
"Resource": {
"Fn::Join": [
"",
[
"arn:aws:apigateway::",
{ "Ref": "AWS::AccountId" },
":/restapis/",
"*/documentation/*"
]
]
},
"Condition" : {
"IpAddress": {
"aws:SourceIp": ["xxx.xxx.xxx.xxx" ]
}
}
}
]
}
}
},
但是,我仍然收到“缺少身份验证令牌”。我相信“条件”部分是正确的,因为它在 CFT 的其他地方使用。
我想做的事情是否可能,如果是,我哪里错了?
编辑添加"Principal": "*"
到上面的政策声明并将其直接移动到 APIGateway 的政策似乎也没有帮助。
解决方案
推荐阅读
- optimization - 支持复杂变量的优化建模语言
- c# - 如何在 Unity UI 设计中查找脚本使用情况
- firebase - Firestore 集合查询作为颤动中的流
- selenium - 如何使用TestNG处理黄瓜4并行执行中的依赖场景
- php - 获取响应发送邮件的消息 ID - SendGrid API v3
- python - 如何使用python自动链接链表的值
- python - 使用 python 的 HP ALM 结果附件和状态更新
- c# - 创建一个从 A 点到 B 点的速度线渲染器?
- android - 地理位置问题
- android - 在 Room 生成的类上发布构建失败:javax.annotation 不存在