【发布时间】:2019-01-31 16:33:27
【问题描述】:
我在 Azure 上托管了一个受 B2C 保护的 Web API。 我需要创建一个需要从 Web Api 消耗资源的计划任务(或 Web 服务)。 让计划任务通过 Web Api 进行身份验证的推荐方法是什么?
我认为我不能在这种情况下使用 B2C。我正在考虑使用密钥,但我不太清楚如何在 Azure 中进行设置,以及如何更新 Web Api OWIN 中间件以处理 B2C 和密钥身份验证。
这是我当前的 Startup.Auth:
public void ConfigureAuth(IAppBuilder app)
{
TokenValidationParameters tvps = new TokenValidationParameters
{
// Accept only those tokens where the audience of the token is equal to the client ID of this app
ValidAudience = ClientId,
AuthenticationType = Startup.DefaultPolicy
};
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
{
// This SecurityTokenProvider fetches the Azure AD B2C metadata & signing keys from the OpenIDConnect metadata endpoint
AccessTokenFormat = new JwtFormat(tvps, new OpenIdConnectCachingSecurityTokenProvider(String.Format(AadInstance, Tenant, DefaultPolicy)))
});
}
干杯!
【问题讨论】:
标签: authorization scheduled-tasks azure-ad-b2c