proxy

package
v1.50.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 14 Imported by: 13

Documentation

Overview

Package proxy implements a programmable proxy for rclone serve

Index

Constants

This section is empty.

Variables

View Source
var DefaultOpt = Options{
	AuthProxy: "",
}

DefaultOpt is the default values uses for Opt

View Source
var Help = strings.Replace(`
### 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 protocl with input on STDIN and output on STDOUT.

There is an example program
[bin/test_proxy.py](https://github.com/rclone/rclone/blob/master/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

For example the program might take this on STDIN

|||
{
	"user": "me",
	"pass": "mypassword"
}
|||

And return this on STDOUT

|||
{
	"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| 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 progam 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.

Note that an internal cache is keyed on |user| so only use that for
configuration, don't use |pass|.  This also means that if a user's
password is changed the cache will need to expire (which takes 5 mins)
before it takes effect.

This can be used to build general purpose proxies to any kind of
backend that rclone supports.  
`, "|", "`", -1)

Help contains text describing how to use the proxy

Functions

This section is empty.

Types

type Options

type Options struct {
	AuthProxy string
}

Options is options for creating the proxy

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

func New(opt *Options) *Proxy

New creates a new proxy with the Options passed in

func (*Proxy) Call

func (p *Proxy) Call(user, pass string) (VFS *vfs.VFS, vfsKey string, err error)

Call runs the auth proxy with the given input, returning a *vfs.VFS and the key used in the VFS cache.

func (*Proxy) Get

func (p *Proxy) Get(key string) *vfs.VFS

Get VFS from the cache using key - returns nil if not found

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL