Documentation
¶
Overview ¶
Package proxy implements a programmable proxy for rclone serve
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Help = strings.ReplaceAll(`### Auth Proxy
If you supply the parameter |--auth-proxy /path/to/program| then
rclone will use that program to generate backends on the fly which
then are used to authenticate incoming requests. This uses a simple
JSON based protocol with input on STDIN and output on STDOUT.
**PLEASE NOTE:** |--auth-proxy| and |--authorized-keys| cannot be used
together, if |--auth-proxy| is set the authorized keys option will be
ignored.
There is an example program
[bin/test_proxy.py](https://github.com/rclone/rclone/blob/master/bin/test_proxy.py)
in the rclone source code.
The program's job is to take a |user| and |pass| on the input and turn
those into the config for a backend on STDOUT in JSON format. This
config will have any default parameters for the backend added, but it
won't use configuration from environment variables or command line
options - it is the job of the proxy program to make a complete
config.
This config generated must have this extra parameter
- |_root| - root to use for the backend
And it may have this parameter
- |_obscure| - comma separated strings for parameters to obscure
If password authentication was used by the client, input to the proxy
process (on STDIN) would look similar to this:
|||json
{
"user": "me",
"pass": "mypassword"
}
|||
If public-key authentication was used by the client, input to the
proxy process (on STDIN) would look similar to this:
|||json
{
"user": "me",
"public_key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDuwESFdAe14hVS6omeyX7edc...JQdf"
}
|||
And as an example return this on STDOUT
|||json
{
"type": "sftp",
"_root": "",
"_obscure": "pass",
"user": "me",
"pass": "mypassword",
"host": "sftp.example.com"
}
|||
This would mean that an SFTP backend would be created on the fly for
the |user| and |pass|/|public_key| returned in the output to the host given. Note
that since |_obscure| is set to |pass|, rclone will obscure the |pass|
parameter before creating the backend (which is required for sftp
backends).
The program can manipulate the supplied |user| in any way, for example
to make proxy to many different sftp backends, you could make the
|user| be |user@example.com| and then set the |host| to |example.com|
in the output and the user to |user|. For security you'd probably want
to restrict the |host| to a limited list.
An internal cache of backends is keyed on the |user| and a hash of the
|pass| or |public_key|. This means that if a user's password or
public-key changes, or the proxy returns different config parameters
(eg a rotated |api_key|), a fresh backend will be created on the next
request rather than the cached one being reused.
This can be used to build general purpose proxies to any kind of
backend that rclone supports.
`, "|", "`")
Help contains text describing how to use the proxy
View Source
var OptionsInfo = fs.Options{{ Name: "auth_proxy", Default: "", Help: "A program to use to create the backend from the auth", }}
OptionsInfo descripts the Options in use
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
AuthProxy string `config:"auth_proxy"`
}
Options is options for creating the proxy
var Opt Options
Opt is the default options
type Proxy ¶
type Proxy struct {
Opt Options
// contains filtered or unexported fields
}
Proxy represents a proxy to turn auth requests into a VFS
func New ¶
New creates a new proxy with the Options passed in
Any VFS are created with the vfsOpt passed in.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package proxyflags implements command line flags to set up a proxy
|
Package proxyflags implements command line flags to set up a proxy |
Click to show internal directories.
Click to hide internal directories.