Rails 3.1 应用程序集成了 webdav 和身份验证?

发布于 2024-12-14 13:06:09 字数 285 浏览 5 评论 0原文

我想为 Rails 3.1 应用程序启用 WebDav,其中我使用 Devise 进行身份验证,使用 CanCan 进行授权。

到目前为止,我打开了 WebDav 并且工作正常。是否可以使用 Devise 登录名/用户和 dav4rack 来启用/限制对 WebDav 上某些文件/目录的访问?也许已经有相关的说明或维基页面了?任何帮助将不胜感激。

附言。这是解决此类问题的正确方法吗?也许我应该切换回 apache mod_dav 并将 apache 的 dav 用户/组与我的 Rails 应用程序中定义的用户/组同步?

I would like to enable WebDav for Rails 3.1 application, where I use Devise for authentication and CanCan for authorization.

So far I turned on WebDav and works fine. Is it possible to use Devise logins/users with dav4rack to enable/restrict access to certain files/directories on WebDav? Maybe there is already a howto or wiki page about that? Any help will be appreciated.

PS. is this the right way of solving this kind of problem? maybe i should switch back to apache mod_dav and synchronise apache's dav users/groups with users/groups defined in my Rails application?

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

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

发布评论

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

评论(1

很酷不放纵 2024-12-21 13:06:09

我在这里找到了一个带有 Dav4Rack 资源的 Devise 示例
https://github.com/bryanrite /dav4rack-example-devise-subdirectories/blob/master/app/models/my_resource.rb

class MyResource < DAV4Rack::FileResource

  def root
    File.join(options[:root].to_s, user.id.to_s)
  end

  private

  def authenticate(username, password)
    self.user = User.find_by_username(username)
    user.try(:valid_password?, password)
  end  

end

在我的例子中,我使用电子邮件而不是用户名。

I found an example of Devise w/ a Dav4Rack resource here
https://github.com/bryanrite/dav4rack-example-devise-subdirectories/blob/master/app/models/my_resource.rb

class MyResource < DAV4Rack::FileResource

  def root
    File.join(options[:root].to_s, user.id.to_s)
  end

  private

  def authenticate(username, password)
    self.user = User.find_by_username(username)
    user.try(:valid_password?, password)
  end  

end

In my case, I used email instead of username.

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