Asp.net core Net核心中的AWS Cognito JWT-如何验证每个用户对AWS服务的调用
我有一个AWS Amplify前端,它从Cognito生成JWT令牌,我用它在Asp.net核心Web Api中对用户进行身份验证。我现在希望使用用户的凭据来调用AWS服务,以便使用Cloudtrail进行审计 我通常使用AWSSDK.Extensions.NetCore.SetupAsp.net core Net核心中的AWS Cognito JWT-如何验证每个用户对AWS服务的调用,asp.net-core,.net-core,jwt,asp.net-core-webapi,amazon-cognito,Asp.net Core,.net Core,Jwt,Asp.net Core Webapi,Amazon Cognito,我有一个AWS Amplify前端,它从Cognito生成JWT令牌,我用它在Asp.net核心Web Api中对用户进行身份验证。我现在希望使用用户的凭据来调用AWS服务,以便使用Cloudtrail进行审计 我通常使用AWSSDK.Extensions.NetCore.Setup services.AddDefaultAWSOptions(Configuration.GetAWSOptions()) 我如何做到这一点 下面是Startup.cs中的ConfigureServices和Conf
services.AddDefaultAWSOptions(Configuration.GetAWSOptions())代码>
我如何做到这一点
下面是Startup.cs中的ConfigureServices和Configure方法
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddAuthentication(options => options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Audience = "xxxxxxxxxxxxxxxx";
options.Authority = "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxxx";
options.RequireHttpsMetadata = false; //set this to true for prod environments!
options.SaveToken = true;
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}