Which version of Microsoft Identity Web are you using?
Microsoft.Identity.Web 1.8.2
Where is the issue?
- Web app
- Web API
- Token cache serialization
- Other (please describe)
Is this a new or an existing app?
The app is in production and I have upgraded to a new version of Microsoft Identity Web
Repro
// Startup.ConfigureServices
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"));
services.AddAuthentication()
.AddMicrosoftIdentityWebApi(Configuration.GetSection("AzureAd"), JwtBearerDefaults.AuthenticationScheme)
.EnableTokenAcquisitionToCallDownstreamApi()
.AddInMemoryTokenCaches();
services.AddRazorPages()
.AddMicrosoftIdentityUI();
// _LoginPartial.cshtml
@if (User.Identity.IsAuthenticated)
{
<div class="navbar-nav">
<span class="navbar-text">@User.FindFirst(ClaimTypes.Surname)?.Value</span>
<a class="nav-item nav-link" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Logout</a>
</div>
}
else
{
<div class="navbar-nav">
<a class="nav-item nav-link" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Login</a>
</div>
}
Expected behavior
After login page is displayed I waited 15 min or so, then started login by
clicking my previous account shown on the login page.
After successful login I expected that home page be shown.
Actual behavior
Login seemed to proceed fine, but then my app is redirected to /Account/AccessDenied page.
There were 2 issues:
- /Account/AccessDenied page doesn't exist, so 404 is returned. Correct path is MicrosoftIdentity/Account/AccessDenied.
- If I manually browse to MicrosoftIdentity/Account/AccessDenied page, then I clearly see that I'm authenticated, because instead of login button I see logout button. My app is ASP.NET Core 3.1 razor pages app, and in _LoginPartial.cshtml I check
for authentication with User.Identity.IsAuthenticated property.
Possible solution
Additional context / logs / screenshots
Which version of Microsoft Identity Web are you using?
Microsoft.Identity.Web 1.8.2
Where is the issue?
Is this a new or an existing app?
The app is in production and I have upgraded to a new version of Microsoft Identity Web
Repro
Expected behavior
After login page is displayed I waited 15 min or so, then started login by
clicking my previous account shown on the login page.
After successful login I expected that home page be shown.
Actual behavior
Login seemed to proceed fine, but then my app is redirected to /Account/AccessDenied page.
There were 2 issues:
for authentication with User.Identity.IsAuthenticated property.
Possible solution
Additional context / logs / screenshots