5824: Use vhosts in curl integration tests. Add large file test.
[arvados.git] / services / keep-web / doc.go
1 // Keep-web provides read-only HTTP access to files stored in Keep. It
2 // serves public data to anonymous and unauthenticated clients, and
3 // serves private data to clients that supply Arvados API tokens. It
4 // can be installed anywhere with access to Keep services, typically
5 // behind a web proxy that supports TLS.
6 //
7 // Starting the server
8 //
9 // Serve HTTP requests at port 1234 on all interfaces:
10 //
11 //   keep-web -address=:1234
12 //
13 // Serve HTTP requests at port 1234 on the interface with IP address 1.2.3.4:
14 //
15 //   keep-web -address=1.2.3.4:1234
16 //
17 // Proxy configuration
18 //
19 // Keep-web does not support SSL natively. Typically, it is installed
20 // behind a proxy like nginx.
21 //
22 // Here is an example nginx configuration.
23 //
24 //      http {
25 //        upstream keep-web {
26 //          server localhost:1234;
27 //        }
28 //        server {
29 //          listen *:443 ssl;
30 //          server_name dl.example.com *.dl.example.com ~.*--dl.example.com;
31 //          ssl_certificate /root/wildcard.example.com.crt;
32 //          ssl_certificate_key /root/wildcard.example.com.key;
33 //          location  / {
34 //            proxy_pass http://keep-web;
35 //            proxy_set_header Host $host;
36 //            proxy_set_header X-Forwarded-For $remote_addr;
37 //          }
38 //        }
39 //      }
40 //
41 // It is not necessary to run keep-web on the same host as the nginx
42 // proxy. However, TLS is not used between nginx and keep-web, so
43 // intervening networks must be secured by other means.
44 //
45 // Download URLs
46 //
47 // The following "same origin" URL patterns are supported for public
48 // collections (i.e., collections which can be served by keep-web
49 // without making use of any credentials supplied by the client). See
50 // "Same-origin mode" below.
51 //
52 //   http://dl.example.com/c=uuid_or_pdh/path/file.txt
53 //   http://dl.example.com/c=uuid_or_pdh/path/t=TOKEN/file.txt
54 //
55 // The following "multiple origin" URL patterns are supported for all
56 // collections:
57 //
58 //   http://uuid_or_pdh--dl.example.com/path/file.txt
59 //   http://uuid_or_pdh--dl.example.com/t=/path/file.txt
60 //   http://uuid_or_pdh--dl.example.com/t=TOKEN/path/file.txt
61 //
62 // In the "multiple origin" form, the string "--" can be replaced with
63 // "." with identical results (assuming the upstream proxy is
64 // configured accordingly). These two are equivalent:
65 //
66 //   http://uuid_or_pdh--dl.example.com/path/file.txt
67 //   http://uuid_or_pdh.dl.example.com/path/file.txt
68 //
69 // The first form minimizes the cost and effort of deploying a
70 // wildcard TLS certificate for *.dl.example.com. The second form is
71 // likely to be easier to configure, and more efficient to run, on an
72 // upstream proxy.
73 //
74 // In all of the above forms, the "dl.example.com" part can be
75 // anything at all.
76 //
77 // In all of the above forms, the "uuid_or_pdh" part can be either a
78 // collection UUID or a portable data hash with the "+" character
79 // replaced by "-".
80 //
81 // Assuming there is a collection with UUID
82 // zzzzz-4zz18-znfnqtbbv4spc3w and portable data hash
83 // 1f4b0bc7583c2a7f9102c395f4ffc5e3+45, the following URLs are
84 // interchangeable:
85 //
86 //   http://zzzzz-4zz18-znfnqtbbv4spc3w.dl.example.com/foo
87 //   http://zzzzz-4zz18-znfnqtbbv4spc3w.dl.example.com/t=/foo
88 //   http://zzzzz-4zz18-znfnqtbbv4spc3w--dl.example.com/t=/foo
89 //   http://1f4b0bc7583c2a7f9102c395f4ffc5e3-45--foo.example.com/foo
90 //   http://1f4b0bc7583c2a7f9102c395f4ffc5e3-45--.invalid/foo
91 //
92 // Authorization mechanisms
93 //
94 // A token can be provided in an Authorization header:
95 //
96 //   Authorization: OAuth2 o07j4px7RlJK4CuMYp7C0LDT4CzR1J1qBE5Avo7eCcUjOTikxK
97 //
98 // A base64-encoded token can be provided in a cookie named "api_token":
99 //
100 //   Cookie: api_token=bzA3ajRweDdSbEpLNEN1TVlwN0MwTERUNEN6UjFKMXFCRTVBdm83ZUNjVWpPVGlreEs=
101 //
102 // A token can be provided in an URL-encoded query string:
103 //
104 //   GET /foo.txt?api_token=o07j4px7RlJK4CuMYp7C0LDT4CzR1J1qBE5Avo7eCcUjOTikxK
105 //
106 // A suitably encoded token can be provided in a POST body if the
107 // request has a content type of application/x-www-form-urlencoded or
108 // multipart/form-data:
109 //
110 //   POST /foo.txt
111 //   Content-Type: application/x-www-form-urlencoded
112 //   [...]
113 //   api_token=o07j4px7RlJK4CuMYp7C0LDT4CzR1J1qBE5Avo7eCcUjOTikxK
114 //
115 // If a token is provided in a query string or in a POST request, the
116 // response is an HTTP 303 redirect to an equivalent GET request, with
117 // the token stripped from the query string and added to a cookie
118 // instead.
119 //
120 // Compatibility
121 //
122 // Client-provided authorization tokens are ignored if the client does
123 // not provide a Host header.
124 //
125 // In order to use the query string or a POST form authorization
126 // mechanisms, the client must follow 303 redirects; the client must
127 // accept cookies with a 303 response and send those cookies when
128 // performing the redirect; and either the client or an intervening
129 // proxy must resolve a relative URL ("//host/path") if given in a
130 // response Location header.
131 //
132 // Intranet mode
133 //
134 // Normally, Keep-web accepts requests for multiple collections using
135 // the same host name, provided the client's credentials are not being
136 // used. This provides insufficient XSS protection in an installation
137 // where the "anonymously accessible" data is not truly public, but
138 // merely protected by network topology.
139 //
140 // In such cases -- for example, a site which is not reachable from
141 // the internet, where some data is world-readable from Arvados's
142 // perspective but is intended to be available only to users within
143 // the local network -- the upstream proxy should configured to return
144 // 401 for all paths beginning with "/c=".
145 //
146 // Same-origin mode
147 //
148 // Without the same-origin protection outlined above, a web page
149 // stored in collection X could execute JavaScript code that uses the
150 // current viewer's credentials to download additional data from
151 // collection Y -- data which is accessible to the current viewer, but
152 // not to the author of collection X -- from the same origin
153 // (``https://dl.example.com/'') and upload it to some other site
154 // chosen by the author of collection X.
155 //
156 package main
157
158 // TODO(TC): Implement
159 //
160 // Trusted content
161 //
162 // Normally, Keep-web is installed using a wildcard DNS entry and a
163 // wildcard HTTPS certificate, serving data from collection X at
164 // ``https://X--dl.example.com/path/file.ext''.
165 //
166 // It will also serve publicly accessible data at
167 // ``https://dl.example.com/collections/X/path/file.txt'', but it does not
168 // accept any kind of credentials at paths like these.
169 //
170 // In "trust all content" mode, Keep-web will accept credentials (API
171 // tokens) and serve any collection X at
172 // "https://dl.example.com/collections/X/path/file.ext".  This is
173 // UNSAFE except in the special case where everyone who is able write
174 // ANY data to Keep, and every JavaScript and HTML file written to
175 // Keep, is also trusted to read ALL of the data in Keep.
176 //
177 // In such cases you can enable trust-all-content mode.
178 //
179 //   keep-web -trust-all-content [...]
180 //
181 // In the general case, this should not be enabled: