You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AccountController implementing MicrosoftIdentity/Account/xxx endpoints does not honour redirectUrlΒ #760
Expected behavior
Clicking on the link should take me to the page at yyy
Actual behavior
Takes me to the route of the application, /
Possible solution
Set the redirectUrl property of AuthenticationProperties to the incoming query value
[HttpGet("{scheme?}/{redirectUrl?}")]publicIActionResultSignIn([FromRoute]stringscheme,[FromQuery]stringredirectUrl){scheme??=OpenIdConnectDefaults.AuthenticationScheme;// var redirectUrl = Url.Content("~/");returnChallenge(newAuthenticationProperties{RedirectUrl=redirectUrl??Url.Content("~/")},scheme);}
All endpoints should honour redirectUrl
Additional context / logs / screenshots
This will allow clients to use MicrosoftIdentity/Account/xxx endpoints and land the user on desired page.
AuthentcationProperties provides the mechanism to specify such a location using the RedirectUri property. It would be helpful if the /MicrosoftIdentity/Account/ controller would support that.
The alternative is for me to implement my own endpoints. I would have to reroute those that are hard coded into the AzureADB2COpenIdConnectEventHandlers to my implementations. This is totally doable; it just seems better to use the built-in ones.
Jean-Marc Prieur (@jmprieur) Just tried to use hardcoded link <a href="/MicrosoftIdentity/Account/SignIn?redirectUri=/TodoList">Sign In</a>
and it still not working. Do I have to enable something in Startup.cs configuration or somewhere else to make it working?
Activity
jmprieur commentedon Nov 12, 2020
Thanks for the heads-up rollandjb
rollandjb commentedon Nov 13, 2020
My pleasure Jean-Marc Prieur (@jmprieur)
jmprieur commentedon Nov 13, 2020
rollandjb I tried to repro this bug, but cannot.
Using https://github.com/AzureAD/microsoft-identity-web/tree/master/tests/B2CWebAppCallsWebApi, and signing out each time, I'm always redirected to the page where the sign-in was triggered.
Do you have repro steps? Do you want to force another redirect URL?
rollandjb commentedon Nov 14, 2020
Jean-Marc Prieur (@jmprieur)
I don't know ASP.NET Core web apps well enough to know how the page url is being remembered.
In the case of a SPA hosted on the web app, one would need to specify the
redirectUrlas a query parameter:AuthentcationPropertiesprovides the mechanism to specify such a location using theRedirectUriproperty. It would be helpful if the/MicrosoftIdentity/Account/controller would support that.The alternative is for me to implement my own endpoints. I would have to reroute those that are hard coded into the
AzureADB2COpenIdConnectEventHandlersto my implementations. This is totally doable; it just seems better to use the built-in ones.What do you think?
6 remaining items
jennyf19 commentedon May 26, 2021
Darragh Jones (@darraghjones) rollandjb fix has been merged into master. will be in next release.
jmprieur commentedon Jun 2, 2021
Darragh Jones (@darraghjones) rollandjb: released in 1.12.0
AndreyZ1 commentedon Jun 9, 2021
Jean-Marc Prieur (@jmprieur) hey here, could you help me, please, I just updated version but seems it's not working, am I doing something wrong?
<a asp-area="MicrosoftIdentity" asp-route-redirectUri="@Model.ReturnUrl" asp-controller="Account" asp-action="SignIn">Sign in with Microsoft</a>jmprieur commentedon Jun 9, 2021
AndreyZ1 : I'm not sure about the asp-route-redirectUri notation (I'm not familiar with it). Where is it documented?
We used:
Maybe make sure that
@Model.ReturnUrlstarts by a / ?AndreyZ1 commentedon Jun 9, 2021
Jean-Marc Prieur (@jmprieur) Just tried to use hardcoded link
<a href="/MicrosoftIdentity/Account/SignIn?redirectUri=/TodoList">Sign In</a>and it still not working. Do I have to enable something in Startup.cs configuration or somewhere else to make it working?
jmprieur commentedon Jun 9, 2021
No AndreyZ1
The devapp with which this was tested is here:
microsoft-identity-web/tests/WebAppCallsWebApiCallsGraph/Client/Views/Shared/_LoginPartial.cshtml
Line 12 in b348c48
just update Microsoft.Identity.Web and Microsoft.Identity.Web.UI
AndreyZ1 commentedon Jun 9, 2021
Jean-Marc Prieur (@jmprieur) thank you a lot for help, I updated only Microsoft.Identity.Web and forgot about Microsoft.Identity.Web.UI.
jmprieur commentedon Jun 9, 2021
Thanks for the update, AndreyZ1
Does it work with the
asp-route-redirectUri="@Model.ReturnUrl"form?AndreyZ1 commentedon Jun 9, 2021
Jean-Marc Prieur (@jmprieur) yes, without any problems.
jeevanthespark commentedon Jul 26, 2022
I am not sure what was fixed in earlier builds but I still can't make it work. The code is very simple as given below.
Can anyone please help to fix the issue?
jmprieur commentedon Jul 27, 2022
Jeevan K R (@jeevanthespark) : did you try with:
jeevanthespark commentedon Jul 27, 2022
Yes, I did. It is now redirecting but there are other issues. Initially, there were a couple of issues identified on my code.
OpenIdConnectAuthenticationHandler: message.State is null or empty.