[英]WebAssembly Blazor not using token when deployed on IIS
I'm currently developing a WebAssembly Blazor application which uses Identity Server 4. As described here https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-identity-server?view=aspnetcore-3.1&tabs=visual-studio我目前正在开发一个使用 Identity Server 4 的 WebAssembly Blazor 应用程序。如此处所述https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-identity-server? view=aspnetcore-3.1&tabs=visual-studio
When I'm debugging locally or deploy to Azure everything works fine.当我在本地调试或部署到 Azure 时,一切正常。 I can login and the WebAssembly Client uses the token for all future requests.
我可以登录,并且 WebAssembly 客户端将令牌用于所有未来的请求。 However when I deploy my application to IIS I get stuck in a login loop.
但是,当我将应用程序部署到 IIS 时,我陷入了登录循环。 On the server no errors are logged and the login is successful.
在服务器上没有记录错误并且登录成功。 On the client I see that the POST to /connect/token has a valid token as response (which I checked by using the token with Postman).
在客户端上,我看到 POST 到 /connect/token 有一个有效的令牌作为响应(我通过 Postman 使用令牌进行了检查)。 However it looks like the client ignores the the token cause after that I see it logs to the console:
但是,在我看到它记录到控制台之后,客户端似乎忽略了令牌原因:
Info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
Authorization failed.
And then it redirects me to login again.然后它重定向我再次登录。 Even stranger for me is that also locally on the IIS server this doesn't happen.
对我来说更奇怪的是,在 IIS 服务器上本地也不会发生这种情况。 I'm really confused on why only this happens for remote use on IIS and not on Azure.
我真的很困惑为什么只在 IIS 上远程使用而不是在 Azure 上发生这种情况。 Hope someone can point me in the right direction.
希望有人能指出我正确的方向。
The problem was that the IIS server time wasn't in sync.问题是 IIS 服务器时间不同步。 So on the localhost it worked flawless, but connecting remotely was returning a token that was already expired.
所以在本地主机上它工作得很好,但远程连接返回了一个已经过期的令牌。 The logging of the Authorization Service of Blazor is minimal and doesn't show it discards the token because its expired.
Blazor 的授权服务的日志记录很少,并且没有显示它因为令牌过期而丢弃令牌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.