![](/img/trans.png)
[英]ASP.NET Core react.js Azure Ad authentication before server serves js files
[英]Integrating Azure AD authentication in ASP.NET Core boilerplate
我從https://aspnetboilerplate.com/Templates (帶有 Angular SPA 的 ASP.NET Core)下載了免費模板,現在正在嘗試集成 Azure AD 身份驗證。 我已經嘗試了 Microsoft 提供的一些示例,這些示例都可以正常工作,但是,我無法使用此模板進行操作。
誰能指導我如何使用 ABPAuthorize 屬性進行設置? 我目前正在從登錄服務獲取有效的 JWT 令牌,但是在使用此令牌時,我收到了 403 禁止錯誤。
提前致謝!
我正在努力解決同樣的問題。 我想出了這個主意,但它只解決了部分問題。 在您應該能夠通過 Azure AD 連接控制器之后
"Authentication": {
"AzureAd": {
"IsEnabled": "true",
"Instance": "https://login.microsoftonline.com/",
"Domain": "myDomain.onmicrosoft.com",
"TenantId": "57****t6",
"ClientId": "8a***44",
"CallbackPath": "/signin-oidc"
}
app.UseAuthorization();
例如:public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
...
app.UseAuthentication();
app.UseAuthorization();
...
}
public static void Configure(IServiceCollection services, IConfiguration configuration)
{
if (bool.Parse(configuration["Authentication:AzureAd:IsEnabled"]))
{
services.AddAuthentication(AzureADDefaults.BearerAuthenticationScheme)
.AddAzureADBearer(options => configuration.Bind("Authentication:AzureAd", options));
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
{
options.Authority = options.Authority + "/v2.0/";
options.TokenValidationParameters.ValidateIssuer = false;
});
} ...
}
[Authorize(AuthenticationSchemes = AzureADDefaults.BearerAuthenticationScheme)]
[Authorize(AuthenticationSchemes = AzureADDefaults.BearerAuthenticationScheme)]
[Route("api/[controller]/[action]")]
[ApiController]
public class HelloController : LouncherPadControllerBase
{
[HttpGet]
public string Get()
{
return "Hello, this controller works!";
}
}
在 ABP 框架中驗證或注冊用戶
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.