我有一个带有自定义属性Organisation_id的Cognito用户池。一个组织可以有多个用户。可以有多个组织。另一个Dynamodb表用于维护类别,该类别具有_id和Organisation_id作为分区键。类别可以归组织所有,以便属于该特定组织的用户只能在这些类别中执行某些操作。
现在,我该如何创建IAM策略,以使其采用Organisation_id而不是sub / user_id,如此处所解释的那样:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/specifying-conditions.html
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAccessToOnlyItemsMatchingUserID",
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:BatchGetItem",
"dynamodb:Query",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:BatchWriteItem"
],
"Resource": [
"arn:aws:dynamodb:us-west-2:123456789012:table/GameScores"
],
"Condition": {
"ForAllValues:StringEquals": {
"dynamodb:LeadingKeys": [
"${cognito:organisation_id(?)}"
],
"dynamodb:Attributes": [
"UserId",
"GameTitle",
"Wins",
"Losses",
"TopScore",
"TopScoreDateTime"
]
},
"StringEqualsIfExists": {
"dynamodb:Select": "SPECIFIC_ATTRIBUTES"
}
}
}
]}
Run Code Online (Sandbox Code Playgroud)
因此,我的主要要求是通过cognito在IAM策略中获取自定义用户池属性。那怎么可能?
amazon-web-services amazon-dynamodb amazon-iam amazon-cognito
我有一个架构,其中我将 API 网关与 Cognito 用户池授权程序一起使用,并且我从客户端 ReST 调用传递授权标头中的 IdToken。
它运行良好。
我需要 Lambda 中的 cognitoIdentityId。
在 API 网关的集成请求中尝试了正文模板映射
内容类型 - application/json
{
"cognito-identity" : "$context.identity.cognitoIdentityId"
}
Run Code Online (Sandbox Code Playgroud)
它不会发送identityid(在事件中或上下文中),而且它仅将我的有效负载转换为这个json。
在这种情况下,如何在 Lambda 中获取 IdentityID 并保持我的有效负载完好无损?
lambda amazon-cognito aws-api-gateway serverless-architecture
我正在使用 KOA 2.0 并开始测试 asp.net 核心。但是找不到处理请求/网址特定中间件的方法
在 Koa 中说,使用路由器我可以实现以下目标:
.post("/api/v1/user", Middleware1, Middleware2, RequestValidationMiddleware, SpecificAction);
.get("/api/v1/user", Middleware1, Middleware2, RequestValidationMiddleware, SpecificAction1);
.post("/api/v1/role", Middleware1, Middleware4, RequestValidationMiddleware2, SpecificAction2);
Run Code Online (Sandbox Code Playgroud)
如何用asp.net核心实现它?
尝试了以下内容:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
//app.UseApiLog();
app.Map("/api", ApiLogApps);
app.Map("/exlog", ExceptionLogApps);
//app.UseMvc(routes =>
//{
// routes.MapRoute(
// name: "default",
// template: "apilog/{controller}/{action}");
// routes.MapRoute(
// name: "default2",
// template: "exlog/{controller=Home}/{action=Index}/{id:int}");
//});
}
private static void ApiLogApps(IApplicationBuilder app)
{
//app.Run(() => )
app.UseApiLog();
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
在控制器中我有
[Route("api/[controller]")]
public class …Run Code Online (Sandbox Code Playgroud)