【发布时间】:2019-11-16 00:28:23
【问题描述】:
我正在开发一个 .netcore 2.1 api 应用程序,它尝试使用 On Behalf Of Flow 访问 Graph api。
我对下面的代码有一个大致的了解,就像它用于代表用户身份验证一样。 但是有人可以逐行解释它的含义或任何有助于我理解授权和身份验证选项的文档吗?
services.AddMvc(o =>
{
o.Filters.Add(new AuthorizeFilter("default"));
});
services.AddAuthorization(o =>
{
o.AddPolicy("default", builder =>
{
builder
.RequireAuthenticatedUser()
.RequireClaim(AzureAdClaimTypes.Scope,
"user_impersonation");
});
});
services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(o =>
{
AuthenticationOptions authSettings = Configuration.GetSection("Authentication").Get<AuthenticationOptions>();
o.Authority = authSettings.Authority;
o.SaveToken = true;
o.TokenValidationParameters = new TokenValidationParameters
{
ValidAudiences = new List<string> { authSettings.ClientId, authSettings.AppIdUri }
};
});
【问题讨论】:
标签: .net-core oauth-2.0 azure-active-directory