Rails 3.1 application with built-in webdav and authentication?

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

So far I have included WebDav and worked fine. Can I use Devise logins / users with dav4rack to enable / restrict access to certain files / directories in WebDav? Maybe you already have a howto or wiki page? Any help would be appreciated.

PS. Is this the right way to solve these kinds of problems? maybe I should go back to apache mod_dav and synchronize apache dav users / groups with the users / groups defined in my Rails application?

+3
source share
1 answer

I found a Devise w / Dav4Rack resource example 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 an email address instead of a username.

0
source

Source: https://habr.com/ru/post/1345153/


All Articles