CORS Anyorigin是否被允许安全?

时间:2020-07-28 10:23:26

标签: c# asp.net-core cors core

我只是查看了我们新的网站后端代码,发现了这一点:

services.AddCors(o => o.AddDefaultPolicy(builder =>
           {
               builder.AllowAnyOrigin()
                   .AllowAnyMethod()
                   .AllowAnyHeader();
           }));


services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
{
    options.TokenValidationParameters = new TokenValidationParameters
    {
        ValidateIssuer = true,
        ValidateAudience = true,
        ValidateLifetime = true,
        ValidateIssuerSigningKey = true,
        ValidIssuer = Configuration["Jwt:Issuer"], //--> AppSetting.Json
                    ValidAudience = Configuration["Jwt:Issuer"], //--> AppSetting.Json
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"]))
    };
});

是否安全? 如果允许任何来源,则用户身份验证是否足够?

1 个答案:

答案 0 :(得分:3)