Commit graph

307 commits

Author SHA1 Message Date
Konrad Wojas
63c8797ba3 Fix tests, add PanicOnError option
- Helper method for internal server errors with consistent logging.
- Add PanicOnError option to panic on internal server errors. This
  makes it easier to traces where the condition was hit in testing.
2021-08-09 10:49:41 +02:00
Konrad Wojas
d4cd47e503 Minor cleanup and fixes
- Do not allow '.' as path component, because it undermines depth
  checks, and add tests
- Fix GiB reporting
- Fix metrics label
- Helper function for http errors
2021-08-09 10:49:41 +02:00
Konrad Wojas
1f593fafaf Make Server use the new repo.Handler
This contains all the glue to make Server use the new repo.Handler:

- Remove all old handlers
- Add ServeHTTP to make Server a single http.Handler
- Remove Goji routing and replace by net/http and custom routing logic

Additionally, this implements two-level backup repositories.
2021-08-09 10:49:41 +02:00
Konrad Wojas
55e549e92c Move maxsizewriter to quota package 2021-08-09 10:49:41 +02:00
Konrad Wojas
79a8785e26 Implement repo.Handler
Refactor the old HTTP handlers to fit the purpose of the new
http.Handler:

- repo.New function to instantiate a handler for a single repo (can be done
  dynamically for every request)
- Single ServeHTTP entrypoint
- Move quota management to two methods that will be implemented later
  (stubs for now)
- Move metrics update to an external function (BlobMetricFunc type)
- Use constants and options for file modes
2021-08-09 10:49:41 +02:00
Konrad Wojas
7f14414363 Add repo package with copy of old handlers.go
Copy the old handlers.go without changes for cleaer diff of
changes later.
2021-08-09 10:49:41 +02:00
Alexander Neumann
bcbfff7b62 Update Go and golangci-lint version 2021-08-09 10:48:58 +02:00
MichaelEischer
c36ae5fe03
Merge pull request #149 from tim-seoss/systemd-unit-file-enhancement
Improve security of example systemd unit file
2021-06-05 14:37:42 +02:00
Tim Small
2bf01df6bf Fixup changelog entry based on feedback. 2021-05-31 11:46:31 +01:00
Tim Small
d1e56e80ee Remove ProcSubset=pid to allow access to /proc/stat etc. 2021-05-31 11:46:31 +01:00
Tim Small
4967dcbf74 Document and sign-post additional systemd resource control options.
The systemd administrator may wish to use additional resource control
facilities which systemd provides. Document the existence of these, and
provide some example options in commented form.
2021-05-31 11:46:31 +01:00
Tim Small
8a1535ba0c Improve commenting of systemd unit file based on review. 2021-05-31 11:46:06 +01:00
MichaelEischer
1ca9ca7e50
Merge pull request #124 from lwis/update-docker
Fix Docker configuration for DISABLE_AUTHENTICATION
2021-05-15 18:39:42 +02:00
Michael Eischer
766f1e0c00 Revert dockerfile changes and cleanup changelog 2021-05-15 18:31:01 +02:00
Lewis Juggins
cec241e5e1 Fix Docker configuration for authentication 2021-05-15 18:28:31 +02:00
MichaelEischer
a44c025cd3
Merge pull request #145 from jinnko/master
Build restic at container build time
2021-05-13 20:00:20 +02:00
Michael Eischer
73fb6419ff Tweak changelog 2021-05-13 19:49:25 +02:00
Tim Small
05a5d1f94e Improve security of example systemd unit file
The supplied systemd unit file places some basic security restrictions
on the rest service.  This patch enhances those, and improves the
overall security assessment score given by `systemd-analyze security`
from "8.3 EXPOSED" to "1.3 OK".

Closes #148
2021-04-03 08:18:45 +01:00
Jinn Koriech
3a4d901f6d
Docker: build rest-server at container build time
Using docker's multi-stage builds we can build the restic/rest-server
within a golang build environment then create a container for use
(without the build environment) in a second build stage.

The advantages are:

1. Building the rest-server is predictable in a pristine environment
   each time.
2. Container builds ensure we get the latest rest-server every time.

Updated README with details of new docker build approach, and added
changelog for unreleased changes.
2021-03-28 12:52:33 +01:00
Alexander Neumann
10dc7a4a86 Fix link to status badge 2021-01-31 13:19:40 +01:00
Alexander Neumann
e3aad65559 Rework CI tests 2021-01-31 13:15:59 +01:00
Alexander Neumann
980bff189e Add config for golangci-lint 2021-01-31 13:15:53 +01:00
Alexander Neumann
a659f3d879
Merge pull request #137 from wojas/htpasswd-numbers
Allow numbers in htpasswd usernames
2021-01-04 17:11:02 +01:00
Konrad Wojas
83e78c6cd7 Allow numbers in htpasswd usernames 2021-01-05 00:08:26 +08:00
Alexander Neumann
4c5077769c
Merge pull request #132 from juergenhoetzel/blacklist-slash
Security: Prevent loading of usernames containing a slash
2020-12-28 16:52:43 +01:00
Juergen Hoetzel
33c41b55bb Security: Prevent loading of usernames containing a slash
"/" is valid char in HTTP authorization headers, but is also used in
rest-server to map usernames to private repos.

This commit prevents loading maliciously composed usernames like
"/foo/config" by restricting the allowed characters to the unicode
character class, numbers, "-", "." and "@".

Closes #131
2020-12-28 11:30:00 +01:00
Alexander Neumann
ba581f22ed
Merge pull request #120 from andreaso/prefer-https-links
Prefer https:// links in the documentation
2020-09-14 16:32:12 +02:00
Andreas Olsson
0155ba8a1b
Prefer https:// links in the documentation 2020-09-13 17:09:47 +02:00
Alexander Neumann
037fe06973
Merge pull request #118 from andreaso/restrict-systemd-service
Make example systemd service more restrictive
2020-09-13 16:13:37 +02:00
Andreas Olsson
a994d347ca
Make example systemd service more restrictive
In addition to any existing filesystem restrictions on the (www-data)
backup user these config options uses namespaces and other kernel
features to further restrict what the _rest-server_ is allowed to do.

* `ProtectSystem=strict` and `ReadWritePaths=/path/to/backups` ensures
  that the _rest-server_ is only allowed to write to its data directory.

* `ProtectHome=yes` and `PrivateTmp=yes` limits what the _rest-server_
  gets (read) access to.

* `NoNewPrivileges=yes` prevents the _rest-server_ from using setuid
  binaries, etc to escalate its privileges.

See https://www.freedesktop.org/software/systemd/man/systemd.exec.html
for further details

While at I also replaced the _/tmp/restic_ path with a more explicit
placeholder path. Given that one rarely wants to backup to _/tmp_ I
figured it better to force a choice of path rather than to have
someone accidentally end up using _/tmp/restic_ for their backups.
2020-09-13 14:21:32 +02:00
Alexander Neumann
14bbb9c18a Fix URLs 2020-09-13 12:14:14 +02:00
Alexander Neumann
53576a1454 Update changelog template for rest-server 2020-09-13 12:12:58 +02:00
Alexander Neumann
4b8ef2cbd7 Fix tests 2020-09-13 12:08:46 +02:00
Alexander Neumann
65fb54cbca Update version for development 2020-09-13 11:45:09 +02:00
Alexander Neumann
9313f19441 Generate CHANGELOG.md for 0.10.0 2020-09-13 11:24:29 +02:00
Alexander Neumann
d4b929ef35 Move changelog files for 0.10.0 2020-09-13 11:24:26 +02:00
Alexander Neumann
13f56bbb3c Update VERSION files for 0.10.0 2020-09-13 11:24:22 +02:00
Alexander Neumann
ecfa514256 Fix goreleaser config for version 2020-09-13 11:22:59 +02:00
Alexander Neumann
c7a44dd1a2 Fix release documentation 2020-09-13 11:22:59 +02:00
Alexander Neumann
4171164a39 Write version into main.go 2020-09-13 11:19:30 +02:00
Alexander Neumann
fa516da2c4 Reformat Release.md 2020-09-13 11:19:30 +02:00
Alexander Neumann
6e44dd8eae Add config for goreleaser, document release process 2020-09-13 11:19:30 +02:00
Alexander Neumann
20603b1622 Remove old changelog
We've had an intermediate release (0.9.8) not covered by the changelog,
so let's start properly in 0.10.0.
2020-09-13 11:19:30 +02:00
Alexander Neumann
1488830de1 Add entry to changelog 2020-09-13 11:19:26 +02:00
Alexander Neumann
723f29e594 Cleanup path before auth check 2020-09-13 11:19:26 +02:00
Konrad Wojas
f8e774393c Stricter path sanitization
Goji routes incoming requests without first URL decoding the path, so
'%2F' in a URL will not be decoded to a '/' before routing. But by the
time that we perform the path checks for private urls on r.URL.Path,
these characters have been decoded.

As a consequence, a user 'foo' could use 'foo%2Fbar' as the repo name.
The private repo check would see that the path starts with 'foo/' and
allow it, and rest-server would happily create a 'foo/bar' repo. Other
more harmful variants are possible.

To resolve this issue, we now reject any name part that contains a '/'.

Additionally, we immediately reject a few other characters that are
disallowed under some operating systems or filesystems.
2020-09-13 11:19:26 +02:00
Alexander Neumann
6367043b2c Also run linters and tests on PRs 2020-09-13 11:16:17 +02:00
Alexander Neumann
6e44ec0763 Replace Travis with GitHub Actions 2020-09-13 11:13:35 +02:00
Alexander Neumann
06f8484400 Docker: Don't delete htpasswd file 2020-09-12 17:28:18 +02:00
Alexander Neumann
1629c824c9 Add config for GitHub 2020-09-12 17:02:11 +02:00