8784: Fix test for latest firefox.
[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 // See http://doc.arvados.org/install/install-keep-web.html.
8 //
9 // Configuration
10 //
11 // The default configuration file location is
12 // /etc/arvados/keep-web/keep-web.yml.
13 //
14 // Example configuration file
15 //
16 //     Client:
17 //       APIHost: "zzzzz.arvadosapi.com:443"
18 //       AuthToken: ""
19 //       Insecure: false
20 //     Listen: :1234
21 //     AnonymousTokens:
22 //       - xxxxxxxxxxxxxxxxxxxx
23 //     AttachmentOnlyHost: ""
24 //     TrustAllContent: false
25 //
26 // Starting the server
27 //
28 // Start a server using the default config file
29 // /etc/arvados/keep-web/keep-web.yml:
30 //
31 //   keep-web
32 //
33 // Start a server using the config file /path/to/keep-web.yml:
34 //
35 //   keep-web -config /path/to/keep-web.yml
36 //
37 // Proxy configuration
38 //
39 // Keep-web does not support SSL natively. Typically, it is installed
40 // behind a proxy like nginx.
41 //
42 // Here is an example nginx configuration.
43 //
44 //      http {
45 //        upstream keep-web {
46 //          server localhost:1234;
47 //        }
48 //        server {
49 //          listen *:443 ssl;
50 //          server_name collections.example.com *.collections.example.com ~.*--collections.example.com;
51 //          ssl_certificate /root/wildcard.example.com.crt;
52 //          ssl_certificate_key /root/wildcard.example.com.key;
53 //          location  / {
54 //            proxy_pass http://keep-web;
55 //            proxy_set_header Host $host;
56 //            proxy_set_header X-Forwarded-For $remote_addr;
57 //          }
58 //        }
59 //      }
60 //
61 // It is not necessary to run keep-web on the same host as the nginx
62 // proxy. However, TLS is not used between nginx and keep-web, so
63 // intervening networks must be secured by other means.
64 //
65 // Anonymous downloads
66 //
67 // The "AnonymousTokens" configuration entry is an array of tokens to
68 // use when processing anonymous requests, i.e., whenever a web client
69 // does not supply its own Arvados API token via path, query string,
70 // cookie, or request header.
71 //
72 //   "AnonymousTokens":["xxxxxxxxxxxxxxxxxxxxxxx"]
73 //
74 // See http://doc.arvados.org/install/install-keep-web.html for examples.
75 //
76 // Download URLs
77 //
78 // The following "same origin" URL patterns are supported for public
79 // collections and collections shared anonymously via secret links
80 // (i.e., collections which can be served by keep-web without making
81 // use of any implicit credentials like cookies). See "Same-origin
82 // URLs" below.
83 //
84 //   http://collections.example.com/c=uuid_or_pdh/path/file.txt
85 //   http://collections.example.com/c=uuid_or_pdh/t=TOKEN/path/file.txt
86 //
87 // The following "multiple origin" URL patterns are supported for all
88 // collections:
89 //
90 //   http://uuid_or_pdh--collections.example.com/path/file.txt
91 //   http://uuid_or_pdh--collections.example.com/t=TOKEN/path/file.txt
92 //
93 // In the "multiple origin" form, the string "--" can be replaced with
94 // "." with identical results (assuming the downstream proxy is
95 // configured accordingly). These two are equivalent:
96 //
97 //   http://uuid_or_pdh--collections.example.com/path/file.txt
98 //   http://uuid_or_pdh.collections.example.com/path/file.txt
99 //
100 // The first form (with "--" instead of ".") avoids the cost and
101 // effort of deploying a wildcard TLS certificate for
102 // *.collections.example.com at sites that already have a wildcard
103 // certificate for *.example.com. The second form is likely to be
104 // easier to configure, and more efficient to run, on a downstream
105 // proxy.
106 //
107 // In all of the above forms, the "collections.example.com" part can
108 // be anything at all: keep-web itself ignores everything after the
109 // first "." or "--". (Of course, in order for clients to connect at
110 // all, DNS and any relevant proxies must be configured accordingly.)
111 //
112 // In all of the above forms, the "uuid_or_pdh" part can be either a
113 // collection UUID or a portable data hash with the "+" character
114 // optionally replaced by "-". (When "uuid_or_pdh" appears in the
115 // domain name, replacing "+" with "-" is mandatory, because "+" is
116 // not a valid character in a domain name.)
117 //
118 // In all of the above forms, a top level directory called "_" is
119 // skipped. In cases where the "path/file.txt" part might start with
120 // "t=" or "c=" or "_/", links should be constructed with a leading
121 // "_/" to ensure the top level directory is not interpreted as a
122 // token or collection ID.
123 //
124 // Assuming there is a collection with UUID
125 // zzzzz-4zz18-znfnqtbbv4spc3w and portable data hash
126 // 1f4b0bc7583c2a7f9102c395f4ffc5e3+45, the following URLs are
127 // interchangeable:
128 //
129 //   http://zzzzz-4zz18-znfnqtbbv4spc3w.collections.example.com/foo/bar.txt
130 //   http://zzzzz-4zz18-znfnqtbbv4spc3w.collections.example.com/_/foo/bar.txt
131 //   http://zzzzz-4zz18-znfnqtbbv4spc3w--collections.example.com/_/foo/bar.txt
132 //   http://1f4b0bc7583c2a7f9102c395f4ffc5e3-45--foo.example.com/foo/bar.txt
133 //   http://1f4b0bc7583c2a7f9102c395f4ffc5e3-45--.invalid/foo/bar.txt
134 //
135 // An additional form is supported specifically to make it more
136 // convenient to maintain support for existing Workbench download
137 // links:
138 //
139 //   http://collections.example.com/collections/download/uuid_or_pdh/TOKEN/foo/bar.txt
140 //
141 // A regular Workbench "download" link is also accepted, but
142 // credentials passed via cookie, header, etc. are ignored. Only
143 // public data can be served this way:
144 //
145 //   http://collections.example.com/collections/uuid_or_pdh/foo/bar.txt
146 //
147 // Authorization mechanisms
148 //
149 // A token can be provided in an Authorization header:
150 //
151 //   Authorization: OAuth2 o07j4px7RlJK4CuMYp7C0LDT4CzR1J1qBE5Avo7eCcUjOTikxK
152 //
153 // A base64-encoded token can be provided in a cookie named "api_token":
154 //
155 //   Cookie: api_token=bzA3ajRweDdSbEpLNEN1TVlwN0MwTERUNEN6UjFKMXFCRTVBdm83ZUNjVWpPVGlreEs=
156 //
157 // A token can be provided in an URL-encoded query string:
158 //
159 //   GET /foo/bar.txt?api_token=o07j4px7RlJK4CuMYp7C0LDT4CzR1J1qBE5Avo7eCcUjOTikxK
160 //
161 // A suitably encoded token can be provided in a POST body if the
162 // request has a content type of application/x-www-form-urlencoded or
163 // multipart/form-data:
164 //
165 //   POST /foo/bar.txt
166 //   Content-Type: application/x-www-form-urlencoded
167 //   [...]
168 //   api_token=o07j4px7RlJK4CuMYp7C0LDT4CzR1J1qBE5Avo7eCcUjOTikxK
169 //
170 // If a token is provided in a query string or in a POST request, the
171 // response is an HTTP 303 redirect to an equivalent GET request, with
172 // the token stripped from the query string and added to a cookie
173 // instead.
174 //
175 // Indexes
176 //
177 // Currently, keep-web does not generate HTML index listings, nor does
178 // it serve a default file like "index.html" when a directory is
179 // requested. These features are likely to be added in future
180 // versions. Until then, keep-web responds with 404 if a directory
181 // name (or any path ending with "/") is requested.
182 //
183 // Compatibility
184 //
185 // Client-provided authorization tokens are ignored if the client does
186 // not provide a Host header.
187 //
188 // In order to use the query string or a POST form authorization
189 // mechanisms, the client must follow 303 redirects; the client must
190 // accept cookies with a 303 response and send those cookies when
191 // performing the redirect; and either the client or an intervening
192 // proxy must resolve a relative URL ("//host/path") if given in a
193 // response Location header.
194 //
195 // Intranet mode
196 //
197 // Normally, Keep-web accepts requests for multiple collections using
198 // the same host name, provided the client's credentials are not being
199 // used. This provides insufficient XSS protection in an installation
200 // where the "anonymously accessible" data is not truly public, but
201 // merely protected by network topology.
202 //
203 // In such cases -- for example, a site which is not reachable from
204 // the internet, where some data is world-readable from Arvados's
205 // perspective but is intended to be available only to users within
206 // the local network -- the downstream proxy should configured to
207 // return 401 for all paths beginning with "/c=".
208 //
209 // Same-origin URLs
210 //
211 // Without the same-origin protection outlined above, a web page
212 // stored in collection X could execute JavaScript code that uses the
213 // current viewer's credentials to download additional data from
214 // collection Y -- data which is accessible to the current viewer, but
215 // not to the author of collection X -- from the same origin
216 // (``https://collections.example.com/'') and upload it to some other
217 // site chosen by the author of collection X.
218 //
219 // Attachment-Only host
220 //
221 // It is possible to serve untrusted content and accept user
222 // credentials at the same origin as long as the content is only
223 // downloaded, never executed by browsers. A single origin (hostname
224 // and port) can be designated as an "attachment-only" origin: cookies
225 // will be accepted and all responses will have a
226 // "Content-Disposition: attachment" header. This behavior is invoked
227 // only when the designated origin matches exactly the Host header
228 // provided by the client or downstream proxy.
229 //
230 //   "AttachmentOnlyHost":"domain.example:9999"
231 //
232 // Trust All Content mode
233 //
234 // In TrustAllContent mode, Keep-web will accept credentials (API
235 // tokens) and serve any collection X at
236 // "https://collections.example.com/c=X/path/file.ext".  This is
237 // UNSAFE except in the special case where everyone who is able write
238 // ANY data to Keep, and every JavaScript and HTML file written to
239 // Keep, is also trusted to read ALL of the data in Keep.
240 //
241 // In such cases you can enable trust-all-content mode.
242 //
243 //   "TrustAllContent":true
244 //
245 // When TrustAllContent is enabled, the only effect of the
246 // AttachmentOnlyHost flag is to add a "Content-Disposition:
247 // attachment" header.
248 //
249 //   "AttachmentOnlyHost":"domain.example:9999",
250 //   "TrustAllContent":true
251 //
252 // Depending on your site configuration, you might also want to enable
253 // the "trust all content" setting in Workbench. Normally, Workbench
254 // avoids redirecting requests to keep-web if they depend on
255 // TrustAllContent being enabled.
256 //
257 package main