angular - 使用 unprotectedResources 与 Angular 集成的 MSAL
问题描述
我目前正在将 azure AD 集成到我的 Angular 应用程序中......到目前为止,除了它如何处理 HTTP 之外,一切都运行良好。
所以我在应用程序中附加了一个典型的 http 拦截器:
{
provide: HTTP_INTERCEPTORS,
useClass: MsalInterceptor,
multi: true
},
和一些这样的配置......
MsalModule.forRoot({
auth: {
clientId: id,
authority: auth,
validateAuthority: true,
redirectUri: "http://localhost/",
postLogoutRedirectUri: "http://localhost/dashboard",
navigateToLoginRequestUrl: true
},
framework: {
unprotectedResources: ["http://localhost/dashboard"]
},
}, {
popUp: true
})
因此,当我输入unprotectedResources时,我希望对http://localhost/dashboard的所有 http 请求都无需任何身份验证即可通过。
但是......当我没有登录时,我得到“core.js:7187 ERROR ClientAuthError: User login is required”。在控制台中。
有什么帮助吗?
解决方案
根据他们的文档,截至@azure/msal-angular@1.1.0,protectedResourceMap 支持 minimatch 支持的通配符模式,而 unprotectedResources 已被弃用和忽略。
而是把 protectedResourceMap: null 应该工作
参考:https ://github.com/AzureAD/microsoft-authentication-library-for-js/issues/2217
推荐阅读
- dbt - 运行 dbt 时出现“目标未定义”错误
- javascript - Redux 仅在 Refresh 后无法在特定 Route 中工作
- r - 如何参数化分段回归系数以表示以下间隔的斜率(而不是斜率的变化)
- c++ - 检测特定的 C++ 类型是否有成员,不包括继承的成员
- python - 从 Python 中的抓取数据中删除 '\n'
- java - 条件不适用于相关实体
- python - Jupyter Notebook 命令提示符中 Ctrl + C 的对面
- javascript - 使用 node/js/MySQL 工作台将变量传递给查询字符串
- c# - 使用 Bot Framework v4 代码时无法映射 LUIS 意图
- json - 如何使用查找和替换在 VS Code 中用引号和逗号将文档中的每一行包装起来