-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MsalGuard on Redirect URI - getting into redirect loop #4614
Comments
@santhosh1248 If you removed the MsalGuard from the default landing page, and directly navigate to the profile path, do you still see this issue? |
@jo-arroyo I don't see an issue after removing MsalGuard from the landing page and directly navigate to profile path. |
@santhosh1248 Having MsalGuard on the landing page is triggering the redirect loops. Is there a reason you chose to use msal-angular v1 and Angular 7? Our recommendation would be to upgrade to msal-angular v2 and follow the instructions here in order to guard the landing page as well. |
@jo-arroyo angular version upgrade is scoped for our future releases and for now, our application should be on angular-7 version. is there any way, I could solve this in msal-v1 version? |
@santhosh1248 Can you try registering another redirectUri in the Azure Portal (e.g. 'auth-redirect'), setting that as the redirectUri in your app, and creating a new route with that redirectUri? const routes: Routes = [
{
path: '',
component: HomeComponent,
canActivate: [
MsalGuard
]
},
{
path: 'auth-redirect',
component: HomeComponent
},
{
path: 'profile',
component: ProfileComponent,
canActivate: [
MsalGuard
]
}
]; |
@jo-arroyo it is working fine now, but when authenticating from path other than home page, I see a small UI glitch of home page as the |
@santhosh1248 We generally do not recommend setting the MsalGuard on the home page/all paths as looping is an issue. This has been specifically addressed in msal-angular v2 (see the FAQ here), but we are no longer making changes to msal-angular v1. Having another path ( |
@santhosh1248 This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale. |
Core Library
MSAL.js v1 (@azure/msal or msal)
Core Library Version
1.4.4
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
1.1.2
Description
Hello, I'm implementing msal in my angular application and I'm using msal-v1 library.
I have taken angular-7 sample from the documented samples and tried implementing the below code in my enterprise application.
I have added
popup as false
in app.module.tsand on
app-routing.module.ts
, I have addedMsalGuard on the empty route
as my application wont have any login button and the default landing page also needs authentication.By doing this, if I directly hit the domain URL(i.e. redirect URI) with out any route, I was able to authorize and get token properly in the localstorage, but if we clear local storage and then directly navigate to profile path, I was not able to get the token as it is entering a continuously redirect loop.
the application is redirecting to
/#id_token=eyJ
and then to/profile/#id_token=eyJ
and so on.please guide me on how to guard all routes in my angular application and not enter the redirect loop.
Error Message
No response
Msal Logs
No response
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Expected Behavior
get authorized on all routes and get access token without entering the redirect loop.
Identity Provider
Azure AD / MSA
Browsers Affected (Select all that apply)
Chrome
Regression
No response
Source
External (Customer)
The text was updated successfully, but these errors were encountered: