我正在尝试验证Azure Functions v2。我正在进入error Microsoft.AspNetCore.Authentication.Core: No authentication handler is registered for the scheme 'WebJobsAuthLevel'. The registered schemes are: Bearer. Did you forget to call AddAuthentication().Add[SomeAuthHandler]("WebJobsAuthLevel",...)?.
下方
下面是我在Startup.cs中使用的代码
public class Startup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
builder.Services.AddAuthentication()
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme,o =>
{
o.Audience = "https://*******************.azurewebsites.net/";
o.Authority = "http://localhost:****";
o.RequireHttpsMetadata = false;
o.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
{
RequireSignedTokens = true,
ValidAudience = "https://***************.azurewebsites.net/",
ValidateAudience = true,
ValidIssuer = "https://sts.windows.net/***************-5********2**/",
ValidateIssuer = true,
ValidateIssuerSigningKey = true,
ValidateLifetime = true
};
});
}
}
更改了代码,但仍收到相同的给定错误。我漏掉了哪一个?
发布于 2019-06-06 05:29:53
考虑使用Azure App Service Authentication/Authorization feature (也被非正式地称为EasyAuth)。如果你遵循Azure门户中的快速流程,它将为你的功能应用程序创建一个AAD V1应用程序注册,并自动配置你的应用程序以允许使用AAD进行身份验证。如果您随后将Action to take when request is not authenticated
设置为Login with Azure Active Directory
,则只有经过身份验证的请求才有权向您的应用程序发出任何请求。
EasyAuth内置了支持为你的AAD应用程序注册接受无记名令牌,以及其他一些用于AAD和我们支持的身份提供商(Facebook,Google,Twitter)的OAuth2/OIDC流程。通过此功能,您应该不需要在您的端添加任何代码,所有这些都将由Azure平台处理。
https://stackoverflow.com/questions/56463935
复制相似问题