Class: Example::Driver
- Inherits:
-
Object
- Object
- Example::Driver
- Defined in:
- examples/example.rb
Overview
The FTP server requires and instance of a driver which can authenticate users and create a file system drivers for a given user. You can use this as a template for creating your own driver.
Instance Method Summary collapse
-
#authenticate(user, password, account) ⇒ Boolean
Return true if the user should be allowed to log in.
-
#file_system(user) ⇒ Object
Return the file system to use for a user.
-
#initialize(user, password, account, data_dir, read_only) ⇒ Driver
constructor
Your driver’s initialize method can be anything you need.
Constructor Details
#initialize(user, password, account, data_dir, read_only) ⇒ Driver
Your driver’s initialize method can be anything you need. Ftpd does not create an instance of your driver.
125 126 127 128 129 130 131 |
# File 'examples/example.rb', line 125 def initialize(user, password, account, data_dir, read_only) @user = user @password = password @account = account @data_dir = data_dir @read_only = read_only end |
Instance Method Details
#authenticate(user, password, account) ⇒ Boolean
Return true if the user should be allowed to log in. Depending upon the server’s auth_level, some of these parameters may be nil. A parameter with a nil value is not required for authentication. Here are the parameters that are non-nil for each auth_level:
-
:user (user)
-
:password (user, password)
-
:account (user, password, account)
147 148 149 150 151 |
# File 'examples/example.rb', line 147 def authenticate(user, password, account) user == @user && (password.nil? || password == @password) && (account.nil? || account == @account) end |
#file_system(user) ⇒ Object
Return the file system to use for a user.
157 158 159 160 161 162 163 |
# File 'examples/example.rb', line 157 def file_system(user) if @read_only Ftpd::ReadOnlyDiskFileSystem else Ftpd::DiskFileSystem end.new(@data_dir) end |