如何防止有人覆盖获取Windows身份验证并使用用户名进行WCF调用的代码?

发布于 2024-12-15 05:35:20 字数 261 浏览 4 评论 0原文

基本上,如果您使用 WindowsAuthentication 获取用户名,存储在变量中,然后将其传递给您使用的任何服务,那么如何阻止某人破解您的代码并传递另一个用户名呢?

在客户端,您可以检查 IsAuthenticated,但之后它只允许您获取 Windows 用户名,而不是 Windows 密码。

有没有什么方法可以只传递身份验证对象本身而不让它被黑客攻击?否则,我可能必须切换回不使用 Windows 身份验证作为我的身份验证,并使用数据库表自定义滚动用户/通行证。

Basically, if you use WindowsAuthentication to grab the username, store in a variable and then pass that to any services you use, what's to stop someone from hacking your code and passing in another username?

On the client end you can check the IsAuthenticated, but then after that it only lets you grab the Windows Username, not the Windows password.

Is there some way to just pass that authentication object itself without letting it be hacked? Otherwise, I might have to switch back to not using Windows Authentication as my Authentication and custom rolling a user/pass with a db table.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

究竟谁懂我的在乎 2024-12-22 05:35:20

由于“NTLM 一跳”行为,您无法将用户的凭据传递到服务器之外。您可以配置 Kerberos 身份验证来处理需要用户凭据在前端和后端服务器之间流动的情况。

另一种选择是在服务器之间建立信任(即带有客户端证书的 HTTPS),以便后端服务器能够信任来自您的服务器的用户名(因为它将是唯一具有正确客户端证书的用户名)。您将无法在后端服务器上模拟用户,因为您只有一个名称。

You can't pass user's credentials outside of your server due to "NTLM one hop" behavior. You may be able to configure Kerberos authentication to handle cases when you need user's credentials flow between front end and backend servers.

The other option is to establish trust between servers (i.e. HTTPS with client certificate) so backend server is able to trust user name coming from your server (as it would be the only one with correct client certificate). You will not be able to impersonate the user on backend server as you will on ly have a name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文