简体   繁体   English

WebAssembly Blazor 在 IIS 上部署时不使用令牌

[英]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.

相关问题 在 IIS 上运行已发布版本时出现 Blazor WebAssembly InvalidCastException - Blazor WebAssembly InvalidCastException when running Published version on IIS 从 Blazor Webassembly 应用程序调用服务时 IIS 中的 Grpc.Core.ClientBase 错误 - Grpc.Core.ClientBase Error in IIS when service invoked from Blazor Webassembly app Blazor Webassembly EditForm 在 IISExpress 上工作,但在 IIS 上有问题 - Blazor Webassembly EditForm works on IISExpress but has Problem on IIS 在具有 .NET 核心的 Blazor WebAssembly 中使用 Windows 身份验证 - Using Windows Authentication in Blazor WebAssembly with .NET Core 在 .net 5 的 Blazor 客户端 WebAssembly 上使用 InputFile - Using InputFile on Blazor client WebAssembly with .net 5 如何使用 SignInManager 为 Blazor WebAssembly 实现模拟? - How to implement impersonation using SignInManager for Blazor WebAssembly? 将 Xamarin 与 blazor (webassembly) 一起使用有哪些选项? - What are the options for using Xamarin with blazor (webassembly)? Blazor WebAssembly 调用受保护的 WebAPI 方法并中继不记名令牌 - Blazor WebAssembly invoking protected WebAPI methods and relaying bearer token Duende BFF Yarn 在使用来自 Blazor WebAssembly 应用程序的 gRpc Web 客户端时不传递令牌 - Duende BFF Yarn does not pass tokens when using gRpc Web Client from Blazor WebAssembly app 当项目部署在 IIS 8.5 上时,无法使用 EntityFramework 6 创建数据库 - Cannot create DB using EntityFramework 6 when the project is deployed on an IIS 8.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM