[英]msal angular - continuous reloading while authentication using MsalGuard on routing
I'm trying to implement msal-v1
in my angular application to authenticate my enterprise application.我正在尝试在我的 angular 应用程序中实施msal-v1
以验证我的企业应用程序。
There are few routes in my application like below我的应用程序中有几条路线如下
const routes: Routes = [
{ path: '', component: HomeComponent, canActivate: [MsalGuard] },
{ path: 'profile', component: ProfileComponent, canActivate: [MsalGuard] },
{ path: 'search', component: SearchComponent, canActivate: [MsalGuard] }
];
and my MSAL config is like below我的 MSAL 配置如下所示
MsalModule.forRoot(
{
auth: {
clientId: environment.clientId,
authority: "https://login.microsoftonline.com/tenant.onmicrosoft.com/",
validateAuthority: true,
redirectUri: "https://example.com/",
postLogoutRedirectUri:
"https://example.com/",
navigateToLoginRequestUrl: true,
},
cache: {
cacheLocation: "localStorage",
storeAuthStateInCookie: isIE, // set to true for IE 11
},
system: {
logger: new Logger(loggerCallback, {
level: LogLevel.Verbose,
piiLoggingEnabled: true,
}),
}
},
{
popUp: false,
consentScopes: ["user.read", "openid", "profile"],
unprotectedResources: ["https://www.microsoft.com/en-us/"],
protectedResourceMap,
extraQueryParameters: {},
}
)
The issue I'm facing here is, when I try to run the domain with empty route
, then authentication is working fine and then redirecting to home Component
/page.我在这里面临的问题是,当我尝试使用empty route
运行域时,身份验证工作正常,然后重定向到home Component
/页面。 From then on, I was able to redirect to all pages with out any issues.从那时起,我能够毫无问题地重定向到所有页面。
But when I'm trying to directly open Profile/Search
routes, after the authorize call, the url is entering a loop
by redirecting first to https://example.com/#id_token=eyJ0eXAiOi.. .但是当我试图直接打开Profile/Search
路由时,在授权调用之后,url 通过首先重定向到https://example.com/#id_token=eyJ0eXAiOi..进入loop
。 and then to https://example.com/search#id_token=eyJ0eXAiOi.. .然后到https://example.com/search#id_token=eyJ0eXAiOi.. and then entering to https://example.com/#id_token=eyJ0eXAiOi.. .然后输入https://example.com/#id_token=eyJ0eXAiOi..。 again and so on.再次等等。
I have also observed a console issue saying clientautherror: login_in_progress: error during login call - login is already in progress.
我还观察到一个控制台问题,上面写着clientautherror: login_in_progress: error during login call - login is already in progress.
can anyone let me know what I might be doing wrong?任何人都可以让我知道我可能做错了什么吗?
I have discussed the same issue in the github forum and have found a alternate solution by setting a new route without the MsalGuard
but to the same HomeComponent
.我在 github 论坛中讨论了相同的问题,并通过设置一条没有MsalGuard
但指向相同HomeComponent
的新路由找到了替代解决方案。
const routes: Routes = [
{
path: '',
component: HomeComponent,
canActivate: [
MsalGuard
]
},
{
path: 'auth-redirect',
component: HomeComponent
},
{
path: 'profile',
component: ProfileComponent,
canActivate: [
MsalGuard
]
}
];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.