Conversation
release-notes/6.0/known-issues.md
Outdated
|
|
||
| ### SPA template issues with Individual authentication when running in production | ||
|
|
||
| <!-- Statement of problem here. Initially you say but then say Tested with `Always on = true` for Azure App Service and the error actually occurred more frequently. So if it's not the app shutting down and restarting, what causes the error? Something like SPA apps on Azure that (conditions that cause the problem) return the following error `WWW-Authenticate: Bearer error="invalid_token", error_description="The issuer 'https://MyDomain.com' is invalid"`. If the app is accessed from the Azure DNS (MyDomain.azurewebsites.net), authenticaion is successful. Subsequent requests to `https://MyDomain.com` succeed until (??? the app is restarted??? but not according to always on = true). After stopping and starting the app, authenticaion succeeds. |
There was a problem hiding this comment.
SPA template issues with Individual authentication when running in production
Applications based on SPA template with Individual authentication that requires login for every page and is hosted as an Azure App Service on your own domain like https://MyDomain.com can receive the following error:
WWW-Authenticate: Bearer error="invalid_token", error_description="The issuer 'https://MyDomain.com' is invalid"
Probably related to Azure DNS (MyDomain.azurewebsites.net) but this has not been verified. It will probably occur more frequently with Always on set to true for the Azure App Service but it can happen with Always on set to false as well.
To prevent this problem without having to stop and restart the app when the error occurs:
- Add a new app setting which contains the target DNS address. For example, create
IdentityServer:IssuerUriwith valuehttps://MyDomain.com/ - Add the following code to the app (settings is a class mapped to app setting):
if (!string.IsNullOrEmpty(settings.IdentityServer.IssuerUri))
{
builder.Services.Configure<JwtBearerOptions>(IdentityServerJwtConstants.IdentityServerJwtBearerScheme, o => o.Authority = settings.IdentityServer.IssuerUri);
}
below this code:
builder.Services.AddAuthentication()
.AddIdentityServerJwt();
Then modify AddIdentityServer like this:
builder.Services.AddIdentityServer(options =>
{
//Used until https://github.com/dotnet/aspnetcore/issues/42072 is fixed
if (!string.IsNullOrEmpty(settings.IdentityServer.IssuerUri))
{
options.IssuerUri = settings.IdentityServer.IssuerUri;
}
})
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>();
For more information, see this GitHub issue
Fixes dotnet/aspnetcore#42072
@Ogglas can you help me document this problem. Please review what I have and suggest new text.