Commit Graph

335 Commits

Author SHA1 Message Date
Filippo Valsorda 915bb70c57 sync: add option to hourly fetch and check random blobs from dest
Services often have a free download quota, which we can use to fetch
some random blobs, to compare with the source.

Change-Id: I526e62580af4cae7004d756721336d01c2f020c4
2017-04-01 16:18:24 +01:00
mpl 1d32408503 pkg/server: make share handler support share deletions
Since we don't actually ever remove blobs (until we add garbage
collection, and even then), if a share claim gets deleted (with a delete
claim), the only knowledge of the deletion resides in the Index.

So when the share handler verifies the sharing chain, there is nothing
preventing it from reading a supposedly deleted share claim (from the
blobserver), and concluding that the share chain is valid.

This change adds the index handler to the share handler, so it can check
the deletion status of a share claim, and hence support "share
cancellation".

Fixes #914

Change-Id: I572fdddee30e745aa2d2a6720c83c8e8c916515d
2017-03-24 22:33:50 +01:00
Mathieu Lonjaret 75424def01 Merge "pkg/server: add files "zipper" to DownloadHandler" 2017-03-17 13:36:40 +00:00
mpl 71090f7c80 pkg/server: add files "zipper" to DownloadHandler
We want to add a feature for clients (the web UI), where they can select
a bunch of files and ask the server for a zip archive of all these files.

This CL modifies the DownloadHandler so it does exactly that upon
reception of a POST request with a query parameter of the form
files=sha1-foo,sha1-bar,sha1-baz

This CL also adds a new button to the contextual sidebar of the web UI,
that takes care of sending the download request to the server.

known limitations: only permanodes with file as camliContent are
accepted as a valid selection (i.e. no sets, or static-dirs, etc) for
now.

Implementation detail:
We're creating an ephemeral DOM form on the fly to send the request.
The reason is: if we sent it as a Go http request, we'd have to read
the response manually and then we'd have no way of writing it to disk.
If we did it with an xhr, we could write the response to disk by
creating a File or Blob and then using URL.createObjectURL(), but we'd
have to keep the response in memory while doing so, which is
unacceptable for large enough archives.

Fixes #899

Change-Id: I104f7c5bd10ab3369e28d33752380dd12b5b3e6b
2017-03-17 00:59:19 +01:00
Steve Armstrong 79f832a1d5 server/app: app param defaults
Minimizing redundant info when setting up an app:

* prefix - Now optional and defaults to the handler prefix the whole app is attached to
* serverListen - Defaults to the host part of serverBaseURL

Change-Id: I395e71c54b9e81849681fe406ff1b5f412e92c9c
2017-03-13 22:16:29 -07:00
mpl ceb5ea5b10 web UI: add "About" menu entry and dialog
This change adds an "About" entry to the header menu, that pops up an
"About" dialog when clicked on.

But, under this innocent sounding feature is actually a more important
change: this feature is partly added through the use of gopherjs
generated code. In addition, the element added (a menu item) is
integrated
seamlessly into the menu as a React element, thanks to the use of
github.com/myitcv/gopherjs/react.

pkg/env had to be broken with build tags, because importing
"cloud.google.com/go/compute/metadata" (or one of its deps) seems to be
breaking the generated javascript.
https://github.com/camlistore/camlistore/issues/904

github.com/myitcv/gopherjs/react at rev
c04b811da4a086defd882a94cc1901da2d2158b0

honnef.co/go/js/dom at rev 24aa052bc5c63cfb9383bf59493ee48621ca788c

Issue #904
Fixes #798

Change-Id: Ic09b94014d520277f8178727293787ece468babd
2017-03-07 00:24:07 +01:00
mpl 5a24ffd854 new app: scanning cabinet
WARNING: this app is still experimental, and even its data schema might
change. Do not use in production.

This change adds a Camlistore-based port of the scanning cabinet app
originally created by Brad Fitzpatrick:
https://github.com/bradfitz/scanningcabinet

Some of it is inspired from the App Engine Go port of Patrick Borgeest:
https://bitbucket.org/pborgeest/nometicland

The data schema is roughly as follows:

-a scan is a permanode, with the node type: "scanningcabinet:scan".
-a scan's camliContent attribute is set to the actual image file.
-a scan also holds the "dateCreated" attribute, as well as the
"document" attribute, which references the document this scan is a part
of (if any).

-a document is a permanode, with the node type: "scanningcabinet:doc".
-a document page, is modeled by the "camliPath:sha1-xxx" = "pageNumber"
relation, where sha1-xxx is the blobRef of a scan.
-a document can also hold the following attributes: "dateCreated",
"tag", "locationText", "title", "startDate", and "paymentDueDate".

Known caveats, in decreasing order of concern:
-the data schema might still change.
-the scancab tool, to actually create and upload the files from physical
documents, is practically untested (since I do not own a scanner).
-some parts, in particular related to searches, are probably
sub-optimized.
-the usual unavoidable bugs.

Change-Id: If6afc509e13f7c21164a3abd276fec075a3813bb
2017-02-15 17:14:45 +01:00
Filippo Valsorda 2cf30f3042 sync: allow running validation multiple times
Also, count errored shards as done.

Change-Id: I09a06ecb793ace4737d2b3d87fc308c7c74c5d21
2017-02-05 11:40:57 +00:00
Filippo Valsorda f52f3424a0 sync: fix recent errors logging
It used to shift right and then slice the end.

Change-Id: I469e7ca191889e5e92811bb2094f24044a4e963d
2017-02-04 23:13:06 +00:00
Eric Drechsel 2b093f38c8 vendor: update react to 15.4.2
The main motivation is that we want to use gopherjs +
github.com/myitcv/gopherjs/react , which requires a recent react.

This CL also fully switches to only using minified js files.

The changes in server/camlistored/ui are the result of some react
API changes, such as:

 - wraps component instantiation in React.createElement
 - React.classSet -> classNames
 - Need tbody between table and tr in a couple places
 - component array elts need unique keys (longstanding warning)
 - change root elt from body to a child div (to fix warning)
 - don't check isMounted in container render function
 - fix a bunch of style keys using kebab-case instead of camelCase

Change-Id: Idc22d07704688ccde3e4f67d4f188a5ad32b6e32
2017-01-25 19:11:58 +01:00
Mathieu Lonjaret 8a17e7252b Merge "pkg/sorted/mysql: drop tables on reindex" 2017-01-18 18:14:06 +00:00
mpl 2b7a14d835 server: add missing defer in sync handler
Change-Id: I69a74f62d171dc413bb08065ea73af2c694cebcc
2017-01-16 22:07:17 +01:00
mpl af77128123 pkg/sorted/mysql: drop tables on reindex
When reindexing on a (My)SQL based sorted.KeyValue, we should recreate
the database schema from scratch, which means dropping the tables.

However, index.Reindex just calls Wipe on the newly created
sorted.KeyValue, which only deletes the rows, and does not drop the
tables.

Therefore, this CL changes the implementation of Wipe in the MySQL case,
so that it takes care of dropping the tables, and doing everything that
needs to be done afterwards to set up the sorted.KeyValue.

In addition, with the introduction of the sorted.NeedWipeError, we detect
upon initialization of a sorted.KeyValue if it failed because it needed
a schema update. If that is the case, and we're in reindex mode, we can
fix the sorted.KeyValue with a Wipe and carry on.

Finally, we introduce the new sorted.NewKeyValueMaybeWipe function that
automatically wipes a KeyValue when a NeedWipeError was returned upon
its creation.

Next, do the same with other sorted SQLs.

Fixes #806

Change-Id: I2032781cbf453a364880bd3e2e8b3c09aac7aed9
2017-01-16 19:10:05 +01:00
mpl 7291617da7 pkg/server: add share handler prefix to discovery
Change-Id: I5354e3ea375d73d837b5432b63c78a78d1a5bc10
2016-11-10 00:59:19 +01:00
mpl ab06dbd80d vendor: rename google.golang.org/cloud to cloud.google.com/go
rm google.golang.org/cloud
add cloud.google.com/go at a47b182e769f5e75f5fc927ff6ee2678f7f552cf
update google.golang.org/api to 63cb68f1e3834e44683ca062ddf06cb9a889380a
update google.golang.org/grpc to
0e6ec3a4501ee9ee2d023abe92e436fd04ed4081
update go4.org to f5283521d7365fb2875408726e9cbf349f173767

fix in cmd/ pkg/ server/

TODO(mpl): fix misc/docker tools as well. next CL.

Fixes #832

Change-Id: I842b968a0afea8a5822913bd614d67cdbe50ee63
2016-09-08 15:14:12 +02:00
mpl 4fc061e8a2 pkg/server/app: refresh cached domain blobs on 403
To decide whether a search submitted to the app search proxy is allowed,
we compare its results to the domain blobs, result of the master query,
that we cache when the master query is set.

However, since the results of the master query are liable to change when
new blobs arrive (e.g. a new camliMember is added to the set that is
published), that cache may need to be invalidated. Otherwise, we might
reply with a 403 to search query that is actually allowed.

Therefore, this CL adds a refresh of the cache on two instances:

-When the app handler gets a search query that seems to be forbidden.
Before replying with a 403, we refresh the cache with the master query,
and recheck whether the search query is allowed.

-When the publisher gets a request for a "members" page, or the "file"
page, it preemptively asks the app handler to refresh. Now that a lot of
the client workflow has been moved to javascript/the browser, these
kinds of requests should not happen too often, so it seems a reasonable
place to ask for a refresh. But this might change, so we should of
course be careful not to flood the app handler with refresh requests in
the future.

In any case, the app handler is suppressing the refresh requests, so
that it does not perform refreshes at more that one per minute.

As a smarter approach, we could later imagine a way for the app handler
to be aware of when new blobs get to the blobserver (akin to the blob
hub that the sync handler uses?), so that it only ever refreshes when
needed.

Fixes #851

Change-Id: Idc14cce5018053deac01ec454e5c936ed93e5a05
2016-09-02 18:40:42 +02:00
mpl 64ca2c47d0 pkg/server/app: do not mutate r.URL.Path
Since the app handler should not trim the r.URL.Path of the handler's
prefix, it is now the responsibility of the app to cope with that
prefix.

Fixes #833

Change-Id: Ie1fa9801b26767c3e3b6612498380261e22cdf07
2016-08-30 01:39:16 +02:00
mpl 3df678b010 pkg/server/app: proxy search requests for publisher
Some of the publisher features have moved from the server-side app to
the client-side app (the browser) thanks to gopherjs. Some of these
features imply doing some search queries against Camlistore, which
requires authentication. The server-side app receives the necessary
credentials on creation, from Camlistore. However, we can't just
communicate them to the client-side (as we do with the web UI) since the
publisher app itself does not require any auth and is supposed to be
exposed to the world.

Therefore, we need to allow some search queries to be done without
authentication.

To this end, the app handler on Camlistore now assumes a new role: it is
also a search proxy for the app. The app sends an unauthenticated search
query to the app handler (instead of directly to the search handler),
and it is the role of the app handler to verify that this query is
allowed for the app, and if yes, to forward the search to the Camlistore's
search handler.

We introduce a new mechanism to filter the search queries in the form of
a master query. Upon startup, the publisher registers, using the new
CAMLI_APP_MASTERQUERY_URL env var, a *search.SearchQuery with the app
handler. The app handler runs that query and caches all the blob refs
included in the response to that query. In the following, all incoming
search queries are run by the app handler, which checks that none of the
response blobs are out of the set defined by the aforementioned cached
blob refs. If that check fails, the search response is not forwarded to
the app/client.

The process can be improved in a subsequent CL (or patchset), with finer
grained domains, i.e. a master search query per published camliPath,
instead of one for the whole app handler.

Change-Id: I00d91ff73e0cbe78744bfae9878077dc3a8521f4
2016-08-29 19:14:19 +02:00
mpl 73d4d49d55 pkg/server: instruction for updating on GCE
Fixes #825

Change-Id: I07dd2502816b6351b6ae71be84e98952cda5056c
2016-07-20 02:37:56 +02:00
mpl 65343d114d pkg/server/app: improve app handling
These improvements on the server app handler should help writing
and running stand-alone apps.

The two main goals are:
1) "simple" configurations should work automatically; the parameters for
the app are derived from the Listen and BaseURL of the Camlistore
server.
2) More advanced configurations, such as being behind a proxy, should be
easily configurable through the app's Listen, BackendURL, and ApiHost
parameters.

I had worked on them while doing the scanning cabinet app, and I am
backporting them now since we haven't landed the scanning cabinet yet,
and people have been having trouble setting up the publisher.

pkg/app/app_test.go is gone because app.ListenAddress is now dumb. The
hard work is done in pkg/server/app instead.

Fixes #818

Change-Id: Ice2610d6bac611b209cc3a928e67fa6093a41d3e
2016-07-04 22:21:16 +02:00
mpl@serenity 5522ebbeb1 webUI: disable tokenAuth when auth is None
This allows deferring HTTP authentication and authorization to a proxy
(such as nginx) between Camlistore and the rest of the world, without
breaking the web UI.

Fixes #816

Change-Id: Ia4b5be8f2236ddac68dc0d3a09f0f24e588c4995
2016-06-28 01:56:08 +02:00
mpl 46cf811f43 pkg/server: update home page and doc about /setup
wizard under /setup is gone, we should not advertize it anymore.

Change-Id: I7c5384481db9b3f37f1c8b0a6f5a8fe482c4d99b
2016-06-09 17:50:03 +02:00
mpl ac4f053414 pkg/server: fix sharing, add tests
There were basically two bugs in bytesHaveSchemaLink:

-typo "blob" vs "bytes" camliType. this wouldn't happen if we used
constants from a pkg for camliTypes, instead of hardcoding them..
-returning early instead of checking all the parts of a file.

Added a test for each of those bugs. They look like they could be
refactored but they're subtly different enough that it might not be
worth it.

Context: working on issue #527

Change-Id: Ifd0bd311ae8a115de2a56994b89127db6f315a75
2016-05-11 23:58:37 +02:00
Mathieu Lonjaret cf85c385f9 Merge "pkg/osutil: add arguments to RestartProcess" 2016-05-09 21:16:35 +00:00
mpl af3d0dc1f2 pkg/osutil: add arguments to RestartProcess
use it to restart server with -reindex

Fixes #753

Change-Id: Iff4a8c725820f8204d9539b9bafe5f4d3b65780c
2016-05-09 16:18:39 +02:00
Brad Fitzpatrick d0be85b4b2 server: fall back to serving UI resources from GOPATH as last resort
This lets the UI work (and lets people hack on the UI) by installing
camlistored the normal Go way (go install) and just running
camlistored, without using devcam server.

Change-Id: I45779640c5b2286ca7061a626c07b3edcdc9c4ad
2016-05-06 16:05:22 -07:00
Will Norris 7ec2b0ac2e website: update doc URLs
s/docs/doc/ and s/http/https/ for camlistore.org doc URLs in website and
code.

Change-Id: I875e2acece1f594a304f2bdb63f756fcb315abc8
2016-04-27 08:48:50 -07:00
Will Norris 29dcc70f3c website: restore search-ui.txt with link to new page
The help page in the camlistore binary has a direct link for "Search bar
predicates" that links to this search-ui.txt on gerrit.  Restore this
file so that these links will still resolve, but with a pointer to the
new docs on camlistore.org.

Also update the help link for future builds of camlistore to point to
the correct URL.

Change-Id: Ib81ff820869d86e6e6f664e8b52c5f20d4eed4d3
2016-04-26 22:28:05 -07:00
Brad Fitzpatrick 03253d1d3c Merge "Fix deadlock in search/index." 2016-04-22 22:01:45 +00:00
Brad Fitzpatrick e93e4f3822 Fix deadlock in search/index.
The describe requests were launching a storm of RLocks which weren't
safe in the presence of goroutines trying to acquire write locks.

Instead, make the corpus locking the responsibility of the caller and
add Lock/Unlock/RLock/RUnlock methods to the index and move locking up
a level.

This also adds a fair bit of context.Context plumbing which was used
in earlier debugging.

Fixes camlistore/camlistore#709

Change-Id: I8d7254d1e1da541f8c080d62f5408aac807fd3b1
2016-04-22 14:57:10 -07:00
mpl 63d6e384bb path fixes for third_party move
A few more left in in misc/docker that I'll do separately

Related: 75d60962f6

Change-Id: Id5f6a3729e33aca97f8664ca8ef91afc64461891
2016-04-21 12:25:17 -07:00
Brad Fitzpatrick 75d60962f6 Move remaining stuff in third_party/* to vendor/*
Change-Id: Ifbcc02817083cba68d8c1acec3e6ec50e8f61149
2016-04-20 16:49:15 -07:00
Tamás Gulácsi 7402cc0efd Delete misc unused objects
Using honnef.co/go/unused/cmd/unused

Change-Id: I672b3cb77f09e9bd80dcdc149cde4f7f2939e451
2016-04-06 17:59:51 +02:00
mpl 4e4f045c29 web UI: port Directory view to React
Side-effects:

Fixes issue #694

And we can now remove filetree.* and cache_buster_iframe.js

Change-Id: Id2d72054366be820771e8b342bb84c4da07a0abf
2016-03-17 00:29:26 +01:00
Will Norris 77ed42edf8 add canonical import paths
The import path was added to the go file that included the package
documentation if one existed.  Otherwise, I used what seemed to be the
primary file for the package.

Fixes #689

Change-Id: If51be0e86529fd6f179e80af6781e639f8550fd2
2016-03-13 19:57:14 -07:00
mpl 8d5d761ff5 vendor/future/mime/multipart: remove
revert changes afe28ebf90 and
666d525530 because Go 1.6 is out.

Issues #642 and #644

Change-Id: Ide422b5164576c77d72061bb05ea0984c68d55e4
2016-02-24 18:11:20 +01:00
Brad Fitzpatrick d16ac53ffd server: HTML escape each sync validation error, put on their own lines
Updates camlistore/camlistore#683

Change-Id: I239bb2441b8b23aebb43e77d7e61c7ccdf708754
2016-02-13 13:22:06 -08:00
Mathieu Lonjaret 2c20c02597 Merge "ui: use authentication token instead of Basic Auth" 2016-02-10 16:00:44 +00:00
mpl e03d0af04f ui: use authentication token instead of Basic Auth
Since issue #660 showed that we could not rely on Basic Auth for some
very particular cases (of POST requests), we wanted to replace Basic
Auth with a pre-generated token based authentication mechanism for these
cases.

However, as there already is such a mechanism used to authenticate
websocket connections, we simply extended the use of that mechanism.
Therefore, the token that is initially generated for websocket
connections is also now a valid token to authenticate any other
connection. The relevant types and method names have been changed to
reflect that. The javascript code pertaining to the sensitive cases
mentioned above has been changed to use that token.

Some doc has been added to point out how security-sensitive the
OpDiscovery permission is, since it gives access to the auth token.

Fixes issue #660

Change-Id: Iafed3b6e4804364ca2559414c8d87dc4a30f6637
2016-02-10 16:58:34 +01:00
mpl e0d719ba21 pkg/types: remove
Most of it replaced with vendor/go4.org/types and
vendor/go4.org/readerutil

u32 went where needed in pkg/blobserver/*
invertedBool went in pkg/types/serverconfig
atomics64 went in pkg/fs

Change-Id: I230426cda35be4b45ed67e869f14e6fdae89be22
2016-02-05 18:28:47 +01:00
Mathieu Lonjaret d20ad1570e Merge "server/synchandler: add exported constructor and IdleWait method" 2016-01-28 00:57:56 +00:00
mpl 1773eb0859 server/synchandler: add exported constructor and IdleWait method
This change allows (for example) to hook a blobserver and an indexer
together in a way similar as they would be in a default Camlistore setup.
This is particularly useful to setup tests that require a realistic
indexer, without having to create a heavier test with e.g. test.World.

This actual goal of this change is described below. I kept these changes
together because the one described below illustrates the need for the
synchandler changes.

pkg/index/stress/: stress test the indexer with more data

The goal of these benchmkarks is to help us compare the various sorted
implementations, so we can pick the most efficient one as a default.

A second, harder, goal would be to add tests that help us estimate the
reliability of the various kv stores, again so we can rule out the buggy
ones, or help fix them.

Change-Id: I8a1fe50398a4ba09c03786502b68b6c2599e5984
2016-01-28 01:56:00 +01:00
Stephen Searles 23457fb56a adding keys to fields to make go vet happy
Change-Id: I28e38da6f5499c3284e647b1c123bcfc882120f7
2016-01-09 00:34:55 -08:00
Brad Fitzpatrick 7b78c50007 Update help handler's text, especially for GCE users.
Fixes camlistore/camlistore#666

Change-Id: Ifb2868a16d3adc425e42cf1d6d3184f31114fa19
2015-12-30 10:33:25 -08:00
Brad Fitzpatrick 383f118ccf pkg/server: validate that share hops are only in expected places in schema blobs
Fixes camlistore/camlistore#228
2015-12-28 13:56:47 -08:00
Mathieu Lonjaret 4e8d27d81e Merge "pkg/server/help: link to binary releases for CLI tools" 2015-12-24 19:54:22 +00:00
mpl 077a74c78b pkg/server/help: link to binary releases for CLI tools
Fixes #536

Change-Id: Icfe22694548e72138510b917be1a6fbc66d5fed2
2015-12-24 20:39:50 +01:00
mpl 6af01f6c71 vendor: move pkg/images dependencies from third_party
This change is in anticipation of moving pkg/images to go4.org, where it
should not depend on packages in third_party.

So:
third_party/github.com/nf/cr2 -> vendor/github.com/nf/cr2
third_party/github.com/rwcarlsen/goexif -> vendor/github.com/rwcarlsen/goexif
third_party/golang.org/x/image/tiff -> vendor/golang.org/x/image/tiff

Note that third_party/go/pkg/image/jpeg was also a dependency of
pkg/images. We had vendored image/jpeg from tip at the time because it
offered advantages over the version from Go1.3
(https://github.com/camlistore/camlistore/issues/463).
Since we now depend on Go1.5, we can go back to depend on the stdlib
version, so we simply remove third_party/go/pkg/image/jpeg and adjust
the imports accordingly.

Change-Id: Ifc8ffae0551102e644a0a0c67f3ff89e04df15c7
2015-12-18 22:15:33 +01:00
Tamás Gulácsi 9f7e1df32b Remove pkg/context
Use golang.org/x/net/context instead.

Fixes #648.

Change-Id: I676a2f25458be97610a49d6f954f2102cbd373fa
2015-12-12 23:09:02 +01:00
mpl 40be4d8da2 vendor: go4.org/jsonconfig (and errorutil)
Previously pkg/jsonconfig and pkg/errorutil

Copied from go4.org at rev d1b8a2fb2de6160036e4801aa5e4d855571078b8

Change-Id: I673ed55b0825baa2607289b6082f205100261d7a
2015-12-01 17:21:49 +01:00