Rebex.net 认证调试

Rebex.net authentication debugging

我目前正在开发使用 SFTP 的应用程序。我们的用户使用 FileZilla 客户端上传存储在 Azure 存储中的文件,然后这些文件由我们的 api 处理。目前我们发现了一个错误,当用户 A 的文件保存在用户 B 的目录中时(它不应该在那里)。我想在我的本地环境中模拟用户通过filezilla认证然后上传文件的过程。当我调试代码时,它总是出现在下面这一点,但我无法进入代码。我假设如果我登录到 filezilla 并单击 quickconnect,它应该会自动命中用户身份验证的断点,但我无法这样做。你如何在你的本地环境中调试它。将其视为 Web 开发中的本地主机,我如何实现相同的功能,我只想登录并查看该代码中的内容。

server = new FileServer();

//我想进入这个,看看里面有什么如何触发这个事件???

server.Authentication += (sender, e) =>
{
    MyDbUser myUser;

    // try authenticating the user against a custom user database
    if (MyUserDatabase.TryAuthenticate(
        e.UserName, e.Password, out myUser))
    {
        // construct a user object
        var user = new FileServerUser(myUser.UserName, null, myUser.VirtualRoot);

        // accept authentication attempt with this user object
        e.Accept(user);
    }
    else
    {
        // reject authentication attempt
        e.Reject();
    }
};

好的,所以为了进入那个事件,你必须 运行 本地环境中的应用程序,当你启动服务器时选择 sftp 和目标端口 22。然后你必须允许入站防火墙规则端口(不要忘记在停止调试会话后将其关闭)。在 filezilla 中,您必须使用 127.0.0.1 作为主机,然后只需输入您的用户名和密码,这将根据您的自定义身份验证进行验证。这样您就可以在本地环境中 运行 它。只要你点击 quickconnect,它就会在 server.Authentication

内命中断点