Commit Graph

48 Commits

Author SHA1 Message Date
Brad Fitzpatrick 43f34e5cc5 auth, webserver, serverinit: add Tailscale tsnet support
Updates #1668

Co-authored-by: Will Norris <will@willnorris.com>
Signed-off-by: Brad Fitzpatrick <brad@danga.com>
2024-01-02 12:58:44 -08:00
mpl 8130bd61ef server/perkeepd/ui/goui: suppress basic auth on OmitAuthToken
The javascript code was taking into account the OmitAuthToken signal
that there should be no auth, but it hadn't been done in the gopherjs
code yet as well.

Fixes #1221

Change-Id: I3eda0cc12c99664739d6073cc1aeba1aeed8a88a
2018-09-26 20:00:36 +02:00
Philip Silva 457a636722 pkg/auth: userpass: compare strings in constant time
Makes the http auth more secure against timing attacks.

Resolves #1205

Change-Id: I6069331d9a6da454a2e664a57cb425f53dea0016
2018-08-09 15:48:42 +02:00
mpl 2bb666ccf6 all: rename remaining occurrences of camput
Also removed misc/buildbot while at it (which contained camput
references) since we don't use it anymore at all.

TODO: the OSX app seems to be relying on finding a binary in ../bin,
which we do not use anymore. This will probably need fixing.

Updates #981

Change-Id: I14220fbad2e81181330fca4bb2d2e5fe170e1bd6
2018-04-21 16:20:24 -07:00
Brad Fitzpatrick 57648c6b83 all: update copyright holder from Google Inc to The Perkeep Authors
The AUTHORS file is the list of copyright holders.
2018-01-03 16:52:49 -08:00
Brad Fitzpatrick c3d05cdce9 Move more packages out of pkg/ and into internal/
Moved hashutil, httputil, osutil, netutil,
images, media, magic, video, and rollsum.
2018-01-02 21:03:30 -08:00
Brad Fitzpatrick d6a0b05df0 Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.

After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.

This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.

Also, this only moves the lru package to internal. More will move to
internal later.

Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.

This updates some docs, but not all.

devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).

Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 16:03:34 -08:00
Paul Lindner fa46c3935d Correct various misspelled words
Change-Id: I236e880526e4c2b0bd318da041983d557e0aa885
2017-09-11 08:33:31 -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@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
Tamás Gulácsi 8d6b156a0b Misc syntax cleanup found by gosimple.
https://github.com/dominikh/go-simple

Thanks to Dominik Honnef for this great little tool!

Change-Id: I789b3a37e18f535df1ff0da47c0366ed01b2429e
2016-04-04 17:19:57 +02: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 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
David Jack 3eb87b9c2d pkg/auth: change VivifyPass to *string to reflect the fact that it's
optional.

Previously, omitting the vivify option from the auth config would
result in VivifyPass being set to empty string (which is a valid
password for HTTP Basic authentication).

Change-Id: I51f441705af4b850ad2bdf27ac3b5a4a9dc83721
2015-12-09 22:57:18 -05:00
mpl e13dc9a0ce pkg/auth: send empty realm for basic auth
Fixes #595

Change-Id: I6fcc1123ce119b4071103c5427de6b8440305cea
2015-05-13 01:28:06 +02:00
mpl 3c6daa2197 auth: allow for multiple modes
context: http://camlistore.org/issue/439

Change-Id: Ie52aa6eea797c37ca178c222a476626e9f30ec42
2014-05-21 18:43:41 +02:00
mpl cb648792cd auth: fix test from 21dda2b4ef
Change-Id: I3f22a1eb181ffccce2a1377ff0a780a9e07a7ce9
2014-05-09 00:49:38 +02:00
mpl 21dda2b4ef app/hello: dummy server application (hello world)
Change-Id: I6690b9459325af5a76d1de679d56701eefdd195e
2014-05-08 22:15:01 +02:00
mpl e8f99a9832 auth: fix OpUpload bitmask check
Change-Id: I7cc3487637c657762a28cb5aeb4abb253bbd1149
2014-04-15 01:40:52 +02:00
Brad Fitzpatrick bfaf77e766 auth: don't use untagged struct literals for structs with type fields of the same type
Change-Id: I677b0e6bbdabc6aa9ff3d9f874fee18257ecf234
2014-04-05 20:19:32 -07:00
Brad Fitzpatrick 91f8b2ad49 Change the upload protocol.
No more dynamic upload URL, which trips up half our new users behind
reverse proxies when the camlistored process doesn't know its
forward-facing URL.

The original camlistore stat + upload protocol was influenced by App
Engine's limitations at the time, and some of our indecision about
where the Camlistore design is going. We understand the Camlistore
design now, and App Engine's former limitations are gone. Time to
clean things up.

More REST-y now too.

See http://camlistore.org/issue/123

Change-Id: I92c6552f830b925cef379c204a982a2213bf2f4b
2014-01-04 20:24:58 -08:00
Brad Fitzpatrick 60685a1194 auth: warn when local connection uid doesn't match
Change-Id: Icdcef55c4831b4f77f7df34e58c87a6985401a04
2013-12-16 17:19:31 -08:00
Brad Fitzpatrick 61deeffef5 Make WebSockets work over https/wss, and make Auth work with WebSockets too.
Change-Id: I321f9d7fe80bf4c88771cbb925f3712229cc09ee
2013-12-12 15:13:44 +04:00
Bill Thiede 738783ebf4 buildbot/master: add Basic Auth support.
Moved BasicAuth parsing and localhost detection code from pkg/auth ->
pkg/httputil for use by buildbot master.

Added user config file for remote access.  The file's name is
"masterbot-config.json" and is located in osutil.CamliConfigDir(),
which on Unix will resolve to $XDG_CONFIG_HOME/camlistore/, if
XDG_CONFIG_HOME set, or ~/.config/camlistore/.  On Windows it will be
under %APPDATA%\Camlistore\.  The expected format is a json object
with usernames as the keys and sha1 sums of the password as the
values, i.e.:

    {
        "user1": "1234567890abcdef12341234567890abcdef1234",
        "user2": "1234abcdef12345678901234abcdef1234567890"
    }

This file is polled at a 1 minute interval and reparsed if the file's
modification time is more recent then the previous parse attempt.  It
is ok for the file to go missing, it will zero out the remote user
list. A malformed file will result in the master exiting.

New commandline flags, -tlsCertFile & -tlsKeyFile, added.  Specifying
both will enable TLS on the listener specified by -host.  The go
source contains generate_cert.go in crypto/tls that can be used to
generate self-signed cert.pem and key.pem for testing.

Added -skiptlscheck commandline option to builder.  This allows the
builder to report to https:// addresses with self-signed certs as we
don't currently have a way to specify the cert chains to be used
for TLS verification.  This is a stop-gap solution.

When launching a master that listens for secure connections, we
currently need tell the builders to skip certificate validation. Add
'-builderopts="-skiptlscheck"' to the master's commandline to skip
cerfication verification.

Change-Id: I0750b5c9fa8f4def67fc05a841087b50abded2f7
2013-11-21 21:22:12 -08:00
Salman Aljammaz 5ee71afca3 auth: don't fail IPv6 test if host can't resolve localhost to [::1]
Change-Id: I3eade17e593da67d33be86563fe179ac6464c561
2013-10-21 21:20:43 +01:00
Brad Fitzpatrick e31a8531fb auth: maybe fix IPv6 test on IPv6-less Linux
Change-Id: I438388420854014e862587960bc549fbcc8f3f2d
2013-10-21 10:16:01 -07:00
Salman Aljammaz 10d67c6d20 localhost auth: resolve localhost to [::1] if using ipv6
http://camlistore.org/issue/238

Change-Id: Icab7d87fe651365fb44db4c2874d4976fa631ad6
2013-10-21 17:02:03 +01:00
Brad Fitzpatrick e20c7f44a8 auth: fix security problem where 'localhost' allowed all access.
Also, add tests. And remove CAMLI_ADVERTISED_PASSWORD, replacing it with explicit devauth mode.

Change-Id: I9cdfe2d537ecefcf75df0b9fb8538258703b1eb7
2013-08-31 13:44:44 -07:00
Bill Thiede 8152d513d9 auth: Fixed regression introduced with a4d187f
Tested with:

(shell1) host1$ devcam server -all
(shell2) host1$  curl -i http://localhost:3179/ui/
HTTP/1.1 200 OK
...

(shell1) host2$  wget -qS http://sagan:3179/ui/ -O -
  HTTP/1.1 401 Unauthorized
  Www-Authenticate: Basic realm="Any username, password is: pass3179"
  Content-Type: text/html; charset=utf-8
  Content-Length: 33
  Date: Wed, 21 Aug 2013 03:07:50 GMT

(shell1) host2$ wget -qS http://user:pass3179@sagan:3179/ui/ -O -
  HTTP/1.1 401 Unauthorized
  Www-Authenticate: Basic realm="Any username, password is: pass3179"
  Content-Type: text/html; charset=utf-8
  Content-Length: 33
  Date: Wed, 21 Aug 2013 03:06:54 GMT
  HTTP/1.1 200 OK
  Accept-Ranges: bytes
  Content-Length: 1213
  Content-Type: text/html; charset=utf-8
  Last-Modified: Thu, 04 Jul 2013 02:08:28 GMT
  Vary: Accept
  Date: Wed, 21 Aug 2013 03:06:54 GMT
<!doctype html>
...

This should resolve https://code.google.com/p/camlistore/issues/detail?id=204

Change-Id: I68ef2a0d93df56172033c2cbac4170e54d6452be
2013-08-20 20:02:16 -07:00
Bill Thiede a4d187f7ee perf: perform password auth before checking UID.
On FreeBSD DevAuth was showing up as consuming ~10% of the time when doing big
camputs.  It disappears with this change. FreeBSD and Mac exec external
programs for localhost auth, so I imagine they'll both benefit.
On linux, checking the password in memory is (probably) still faster than
reading from /proc (which I'm assuming turns into a roundtrip
userland->kernel->userland which is nice to avoid).

Making the change to UserPass under the assumption the performance improvement
would be similar.  Untested/unprofiled though.

Change-Id: Idb7e888df6e9a36db0be671a44911e018eb7986e
2013-08-19 21:46:01 -07:00
Brad Fitzpatrick 62ad21ff2e Docs and minor cleanups
Change-Id: Ibf1d69c21f53cf4b5b576a0dfefa5d0e7b26264d
2013-07-07 16:09:17 -07:00
Brad Fitzpatrick 7c4380eebe auth: add ErrNoAuth, use it pkg/client log warning.
Change-Id: If657da28bc9888941400c263be61809ead5cef12
2013-01-26 11:23:39 -08:00
mpl 1248dfd4da auth: added OpDiscovery
Change-Id: I71ce44732206f5ec84cc2c1db4457d49eb906b0e
2013-01-15 15:02:51 +01:00
Brad Fitzpatrick d80cad8e2d auth stuff: clean up, allow scheme registration, integrate App Engine auth.
Change-Id: Idc7ac3782d3669a8f68255bd54d03f583814d5e2
2013-01-10 23:04:24 -08:00
mpl 2a961cfc75 auth: add OpSign operation, and fix sigserver with it
Change-Id: Ie1f2b15ee72cf571684d12d8c8743a7164d1d80d
2013-01-04 23:09:55 +01:00
mpl 12213c058e Changed auth to take into account not only the credentials,
but the requested operation/action too.

This allows to restrict vivify credentials to only upload
(as well as get and stat, because they're needed) to the
blobserver.

Change-Id: Idaed60d1f0d679cb9795ba9a11f094f964774335
2013-01-04 22:17:12 +01:00
Brad Fitzpatrick 2f072dfc20 auth: fix nil dereference crash
Change-Id: I4552829da795236b9c875a753b6f1d710066d89a
2012-12-01 10:54:14 -08:00
Brad Fitzpatrick 306b58afd6 Merge "Modifications allowing /setup to be view on Windows" 2012-11-19 01:16:23 +00:00
Maxime Lavigne 3ec58472db Modifications allowing /setup to be view on Windows
When you go to /setup on Windows, it currently checks
the "localhostAuthorized" function that checks your
UserID with os.Getuid() and than check with the local
and remote address to see if you are allow. In Windows
os.Getuid will always equals -1 and the function default
to unallowed. On darwin, it does check for uid but
afterward only cares if the local and remote addresses
are loopback addresses.

So, I changed this function so that when the os.Getuid
is not avalaible on the platform and returns -1, it does
the same check as in darwin.

I also modified the "isLocalhost" function to use the
helper function "net.IsLoopback" instead of string matching.

Since, I already had parsed addresses and had to call
AddPairUserId, I checked if it wouldn't be simpler to
pass net.Addr directly instead of strings and reconvert
them afterward. It seemed after looking at all the code
that called this function that it simplified calls quite
a bit to do so.

Finally, I modified "netutil.Localhost" for it to return
the first IP it finds instead of the string representation
of the first IP enclosed in square brackets. Since the square
brackets around the IP are only necessary in a TCPAddr, it
would be simplier and more robust for the user to directly
print TCPAddr instead of appending this string to a post.

Change-Id: Id79de6bebd6380f877074211c0d260782058765f
2012-11-18 20:20:25 -05:00
mpl 3117265b61 bugfix in auth; mode was not set by config in localhost case
Change-Id: I5349af00d7629ca77de73dd886ba44d6bbc56da0
2012-11-16 18:12:41 +01:00
Brad Fitzpatrick 89eeb6e3d5 auth: remove import
Change-Id: Ic31bc3ce05caee2b41aad127ed807be8c057f3d2
2012-04-27 18:57:24 -07:00
Brad Fitzpatrick 8bcae0d59b auth: work around darwin lameness
Change-Id: I5899bffd9383dd22cac3f4fe5e4cd4da11b3a167
2012-04-27 18:49:42 -07:00
mpl f7448ec758 restrict setup access to localhost
Change-Id: I889b9debfc65e25084c1e9715e7d14621f009039
2012-04-15 20:09:51 +02:00
Brad Fitzpatrick 93af191e77 auth: add some more auth modes
Change-Id: I1674f5fff8a8ea3490f315844df68a474f8c6d5e
2012-04-12 16:54:25 -07:00
Brad Fitzpatrick 029d66fa9e In default config, allow localhost access for auth also.
Change-Id: Ie3fc2f3c44d7fc17a367f6a456c6db6511d08f33
2012-04-07 19:02:31 -07:00
Brad Fitzpatrick 40712671ee pkg/auth and pkg/schema: fix tests.
Change-Id: I54f391241c77902ad301edea92d39660f7cf0008
2012-03-29 16:15:59 -07:00
Brad Fitzpatrick 6c6dcdc8a1 auth: in dev mode, use localhost TCP port owners before http basic auth
Change-Id: I6a45518811fd8726233171d5436c625c645b4037
2012-03-27 17:57:13 -07:00
Brad Fitzpatrick 0714a463c9 Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.

The directory tree has been rearranged now too.  Go libraries are now
under "pkg".  Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".

The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.

For now, put the camlistore root under $GOPATH/src.  Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.

Then you can:

$ go build ./server/camlistored

... etc

The build.pl script is currently disabled.  It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).

Many things are certainly broken.

Many things are disabled.  (MySQL, all indexing, etc).

Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.

The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.

Help wanted.

Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-18 21:53:06 -08:00