【发布时间】:2018-03-13 03:52:09
【问题描述】:
我在客户端(离子/角度)上使用 Firebase 身份验证,现在正在尝试保护我的 .NET Core API。
我让它在 localhost 上运行,但是当我将 API 部署到 Azure 时,它给了我 401。
我使用来自https://blog.markvincze.com/secure-an-asp-net-core-api-with-firebase/的这段代码在本地主机上工作
services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = "https://securetoken.google.com/my-firebase-project";
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = "https://securetoken.google.com/my-firebase-project",
ValidateAudience = true,
ValidAudience = "my-firebase-project",
ValidateLifetime = true
};
});
然后在配置中:
app.UseAuthentication();
有人知道为什么我将它发布到 Azure 后会失败吗?客户端工作正常,这意味着我可以使用 facebook 登录并取回正确的显示名称。但是对服务器的授权请求失败。
**编辑:如果我在上面的代码中设置了 ValidateIssuer=false,那么它可以工作......但我猜这是一个很大的安全漏洞?
感谢您的帮助!
【问题讨论】:
标签: azure firebase-authentication asp.net-core-webapi