Skip to content

Commit

Permalink
refactor!: moving to axum (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
mundo-68 authored Jan 22, 2024
1 parent 8f0846b commit 2aba503
Show file tree
Hide file tree
Showing 46 changed files with 3,022 additions and 753 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# Test data created may accidentally be included
/tests/test_data/test_repos/repo_remove_me
/tests/test_data/test_repos/repo_remove_me_2
/tmp_test_data
28 changes: 21 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ All notable changes to this project will be documented in this file.

- Nightly builds, exclude arm64 darwin build until issue Publishing
aarch64-apple-darwin failed #6 is fixed
- Update rust crate toml to 0.8
- Deserialization with newest toml
- Clippy

### Documentation

- Update readme, fix manifest
- Add continous deployment badge to readme
- Add continuous deployment badge to readme
- Fix typo in html element
- Add link to nightly
- Add link to nightly downloads in documentation
Expand Down Expand Up @@ -41,15 +44,26 @@ All notable changes to this project will be documented in this file.
- Put action version to follow main branch while action is still in development
- Switch ci to rustic-rs/create-binary-artifact action
- Switch rest of ci to rustic-rs/create-binary-artifact action
- Change license
- Fix workflow name for create-binary-artifact action, and check breaking
changes package dependent
- Decrease build times on windows
- Fix github refs
- Set right package
- Use bash substring comparison to determine package name from branch
- Fix woggly github action comparison
- Add changelog generation
- Initialize cargo release, update changelog
- Add dev tooling
- Run git-cliff with latest tag during release
- Remove comment from cargo manifest
- Change workflow extensions to yml
- Add triaging of issues
- Run release checks also on release subbranches
- Add maskfile

### Refactor

- Refactor to library and server binary
- Begin refactor to axum

### Styling

- Fmt
- Dprint fmt

<!-- generated by git-cliff -->
79 changes: 72 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rustic_server"
version = "0.1.0"
version = "0.1.1-dev"
authors = ["Alexander Weiss <[email protected]>"]
categories = ["command-line-utilities"]
edition = "2021"
Expand All @@ -11,26 +11,91 @@ repository = "https://github.com/rustic-rs/rustic_server"
description = """
rustic server - a REST server built in rust to use with rustic and restic.
"""
# cargo-binstall support
# https://github.com/cargo-bins/cargo-binstall/blob/HEAD/SUPPORT.md
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/v{ version }/{ repo }-v{ version }-{ target }{ archive-suffix }"
bin-dir = "{ bin }-{ target }/{ bin }{ binary-ext }"
pkg-fmt = "tar.gz"

[package.metadata.binstall.signing]
algorithm = "minisign"
pubkey = "RWSWSCEJEEacVeCy0va71hlrVtiW8YzMzOyJeso0Bfy/ZXq5OryWi/8T"

[dependencies]
anyhow = "1.0.75"
async-trait = "0.1"
# FIXME: Add "headers" feature to Axum?
axum = { version = "0.7.3", features = ["tracing", "multipart", "http2"] }
axum-auth = "0.7.0"
axum-extra = { version = "0.9.1", features = ["typed-header", "query", "async-read-body"] }
axum-extra = { version = "0.9.1", features = ["typed-header", "query", "async-read-body", "typed-routing"] }
axum-macros = "0.4.0"
axum-range = "0.4"
axum-server = { version = "0.6.0", features = ["tls-rustls"] }
clap = { version = "4.4.2", features = ["derive"] }
enum_dispatch = "0.3.12"
futures-util = "0.3.28"
clap = { version = "4.4", features = ["derive"] }
# enum_dispatch = "0.3.12"
futures = "0.3"
futures-util = "0.3"
htpasswd-verify = "0.3"
http-body-util = "0.1.0"
http-range = "0.1"
serde = "1"
once_cell = "1.17"
pin-project = "1.1"
rand = "0.8.5"
serde = { version = "1", default-features = false, features = ["derive"] }
serde_derive = "1"
thiserror = "1.0.48"
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7.8", features = ["io-util"] }
tokio-util = { version = "0.7.8", features = ["io", "io-util"] }
toml = "0.8.8"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
walkdir = "2"

# see: https://nnethercote.github.io/perf-book/build-configuration.html
[profile.dev]
opt-level = 0
debug = true
rpath = false
lto = false
debug-assertions = true
codegen-units = 4

# compile dependencies with optimizations in dev mode
# see: https://doc.rust-lang.org/stable/cargo/reference/profiles.html#overrides
[profile.dev.package."*"]
opt-level = 3
debug = true

[profile.release]
opt-level = 3
debug = false # true for profiling
rpath = false
lto = "fat"
debug-assertions = false
codegen-units = 1
strip = true
panic = "abort"

[profile.test]
opt-level = 1
debug = true
rpath = false
lto = false
debug-assertions = true
codegen-units = 4

[profile.bench]
opt-level = 3
debug = true # true for profiling
rpath = false
lto = true
debug-assertions = false
codegen-units = 1

[dev-dependencies]
base64 = "0.21.2"
# reqwest = "0.11.18"
# serial_test = "*"
serde_json = "*"
tower = "*"
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://media.githubusercontent.com/media/rustic-rs/assets/main/logos/readme_header_server.png" height="400" />
<img src="https://raw.githubusercontent.com/rustic-rs/assets/main/logos/readme_header_server.png" height="400" />
</p>
<p align="center"><b>REST server for rustic</b></p>

Expand Down Expand Up @@ -30,6 +30,12 @@ Most features are already implemented.
| Discord | [![Discord](https://dcbadge.vercel.app/api/server/WRUWENZnzQ)](https://discord.gg/WRUWENZnzQ) |
| Discussions | [GitHub Discussions](https://github.com/rustic-rs/rustic/discussions) |

## Dependencies

Is built using [tide](https://github.com/http-rs/tide),
[tide-rustls](https://github.com/http-rs/tide-rustls) and
[tide-http-auth](https://github.com/chrisdickinson/tide-http-auth).

## Are binaries available?

Yes, you can find them [here](https://rustic.cli.rs/docs/nightly_builds.html).
Expand All @@ -52,6 +58,22 @@ alex = "Modify"
bob = "Append"
```

## Contributing

Tried rustic-server and not satisfied? Don't just walk away! You can help:

- You can report issues or suggest new features on our
[Discord server](https://discord.gg/WRUWENZnzQ) or using
[Github Issues](https://github.com/rustic-rs/rustic_server/issues/new/choose)!

Do you know how to code or got an idea for an improvement? Don't keep it to
yourself!

- Contribute fixes or new features via a pull requests!

Please make sure, that you read the
[contribution guide](https://rustic.cli.rs/docs/contributing-to-rustic.html).

# License

`rustic-server` is open-sourced software licensed under the
Expand Down
4 changes: 2 additions & 2 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ commit_parsers = [
{ message = "^doc", group = "Documentation" },
{ message = "^perf", group = "Performance" },
{ message = "^refactor", group = "Refactor" },
{ message = "^style", group = "Styling" },
{ message = "^style", group = "Styling", skip = true }, # we ignore styling in the changelog
{ message = "^test", group = "Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps\\)", skip = true },
Expand All @@ -69,7 +69,7 @@ protect_breaking_commits = false
# filter out the commits that are not matched by commit parsers
filter_commits = false
# glob pattern for matching git tags
tag_pattern = "v[0-9]*"
tag_pattern = "[0-9]*"
# regex for skipping tags
skip_tags = "v0.1.0-beta.1"
# regex for ignoring tags
Expand Down
76 changes: 76 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# `rustic_server` configuration

This folder contains a few configuration files as an example.

`rustic_server` has a few configuration files:

- access control list (acl.toml)
- server configuration (rustic_server.toml)
- basic http credential authentication (.htaccess)

See also the rustic configuration, described in:
https://github.com/rustic-rs/rustic/tree/main/config

## `acl.toml`

This file may have any name, but requires valid toml formatting.

Format:

```
[<repository_name>]
<user> <access_type>
... more users
... more repositories
```

The `access_type` can have values:

- "Read" --> allows read only access
- "Append" --> allows addition of new files, including initializing a new repo
- "Modify" --> allows write-access, including delete of a repo

Todo: Describe "default" tag in the file.

## `rustic_server.toml`

This file may have any name, but requires valid toml formatting.

File format:

```
[server]
host_dns_name = <ip_address> | <dns hostname>
port = <port number>
[repos]
storage_path = <local file system path containing repos>
[authorization]
auth_path = <path to .htaccdss file, including filename>
use_auth = <skip authorization if false>
[accesscontrol]
acl_path = <path to the acl file, including filename>
private_repo = <skip access control if false>
append_only = <limit to append, regardless of the ACL file content>
```

On top of some additional configuration items, the content of this file points
to the `acl.toml`, and `.htaccess` files.

## `.htaccess`

This is a vanilla `Apache` `.htacces` file.

# Configure `rustic_server` from the command line

It is also possible to configure the server from the command line, and skip the
configuration file.

To see all options, use:

```
rustic_server --help
```
14 changes: 14 additions & 0 deletions config/rustic_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Adapt to your own configuration
[global]
log-level = "Info"
log-file = "~/rustic.log"

[repository]
repository = "rest:http://test:test_pw@localhost:8000/test_repo"
password = "test_pw"

[backup]

[[backup.sources]]
source = "~/your_path/rustic_server/test_data"
# git-ignore = true
15 changes: 15 additions & 0 deletions config/rustic_server.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[server]
host_dns_name = "127.0.0.1"
port = 8000

[repos]
storage_path = "./test_data/test_repos/"

[authorization]
auth_path = "/test_data/test_repo/htaccess"
use_auth = true

[accesscontrol]
acl_path = "/test_data/test_repo/acl.toml"
private_repo = true
append_only = false
Loading

0 comments on commit 2aba503

Please sign in to comment.