From 1c8d856d1ebec9950355fc53379c1f2920e4265c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 30 Nov 2019 06:35:58 +0000 Subject: [PATCH 1/4] README.md: Add missing requirements --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f98ee191..2985fa7c 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,9 @@ Mozilla Sync Storage built with [Rust](https://rust-lang.org). - MySQL 5.7 (or compatible) -\* libmysqlclient (`brew install mysql` on macOS, `apt-get install libmysqlclient-dev` on Ubuntu) - [Go](https://golang.org/doc/install) +- Cmake +- Pkg-config +- Openssl Depending on your OS, you may also need to install `libgrpcdev`, and `protobuf-compiler-grpc`. From 1d28560a1293ca92d108284d9729f881bc40acde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 30 Nov 2019 06:52:19 +0000 Subject: [PATCH 2/4] provide shell.nix Nix is a distribution independent package manager. By providing this file user of nix get automatically all required build dependencies by sourcing default.nix via a tool called nix-shell. This should lower the entry barrier when setting up a build environment. Nix is also used in other places in Mozilla: https://github.com/mozilla/nixpkgs-mozilla --- shell.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..219e655a --- /dev/null +++ b/shell.nix @@ -0,0 +1,20 @@ +# Nix is a powerful package manager for Linux and other Unix systems that makes +# package management reliable and reproducible: https://nixos.org/nix/. +# This file is intended to be used with `nix-shell` +# (https://nixos.org/nix/manual/#sec-nix-shell) to setup a fully-functional +# syncstorage-rs build environment by installing all required dependencies. +with import {}; +stdenv.mkDerivation { + name = "syncstorage-rs"; + buildInputs = [ + rustc + cargo + libmysqlclient + pkgconfig + openssl + cmake + protobuf + go + ]; + NIX_LDFLAGS = "-L${libmysqlclient}/lib/mysql"; +} From 80b0c591f321bbfc5073f0de833ddc03d7819a20 Mon Sep 17 00:00:00 2001 From: Rachel Tublitz Date: Thu, 5 Dec 2019 17:04:46 -0500 Subject: [PATCH 3/4] chore: adjust sample script so it works and adding docs to link to it --- .gitignore | 1 + Makefile | 2 +- README.md | 2 +- config/local.example.toml | 2 +- tools/examples/README.md | 3 +++ tools/{poster/post.bash => examples/put.bash} | 4 +++- tools/hawk/README.md | 7 ++++++- tools/poster/README.md | 4 ---- 8 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 tools/examples/README.md rename tools/{poster/post.bash => examples/put.bash} (74%) mode change 100644 => 100755 delete mode 100644 tools/poster/README.md diff --git a/.gitignore b/.gitignore index dbc044dc..8668c15e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ service-account.json config/local.toml +venv diff --git a/Makefile b/Makefile index 4ddf03cb..9bd8bac8 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ -run-local: +run_local: RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --config config/local.toml diff --git a/README.md b/README.md index 53e1606b..ba61a0fd 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Depending on your OS, you may also need to install `libgrpcdev`, and `protobuf-c 1. Follow the instructions below to use either MySQL or Spanner as your DB. 2. Now `cp config/local.example.toml config/local.toml`. Open `config/local.toml` and make sure you have the desired settings configured. For a complete list of available configuration options, check out [docs/config.md](docs/config.md). -3. `make run-local` starts the server in debug mode, using your new `local.toml` file for config options. Or, simply `cargo run` with your own config options provided as env vars. +3. `make run_local` starts the server in debug mode, using your new `local.toml` file for config options. Or, simply `cargo run` with your own config options provided as env vars. 4. Visit `http://localhost:8000/__heartbeat__` to make sure the server is running. ### MySQL diff --git a/config/local.example.toml b/config/local.example.toml index 24338b82..cdc48320 100644 --- a/config/local.example.toml +++ b/config/local.example.toml @@ -1,4 +1,4 @@ database_url = "mysql://sample_user:sample_password@localhost/syncstorage_rs" -master_secret = "some_secret_here" +master_secret = "INSERT_SECRET_KEY_HERE" # removing this line will default to moz_json formatted logs (which is preferred for production envs) human_logs = 1 diff --git a/tools/examples/README.md b/tools/examples/README.md new file mode 100644 index 00000000..6ed7a906 --- /dev/null +++ b/tools/examples/README.md @@ -0,0 +1,3 @@ +# Example scripts for working with syncstorage-rs + +* `put.bash` - First `chmod +x put.bash` then `./put.bash` to simulate a PUT. diff --git a/tools/poster/post.bash b/tools/examples/put.bash old mode 100644 new mode 100755 similarity index 74% rename from tools/poster/post.bash rename to tools/examples/put.bash index fa4a56f4..88369b6e --- a/tools/poster/post.bash +++ b/tools/examples/put.bash @@ -1,7 +1,9 @@ #!/bin/bash NODE="http://localhost:8000" URI="/1.5/1/storage/col2/DEADBEEF" -AUTH=`../hawk/venv/bin/python ../hawk/make_hawk_token.py --node $NODE --uri $URI --as_header` +METHOD="PUT" +SYNC_MASTER_SECRET="INSERT_SECRET_KEY_HERE" +AUTH=`../hawk/venv/bin/python ../hawk/make_hawk_token.py --node $NODE --uri $URI --method $METHOD --secret=$SYNC_MASTER_SECRET --as_header` curl -vv -X PUT "$NODE$URI" \ -H "Authorization: $AUTH" \ -H 'Content-Type: application/json' \ diff --git a/tools/hawk/README.md b/tools/hawk/README.md index 7b0bf853..56d4c081 100644 --- a/tools/hawk/README.md +++ b/tools/hawk/README.md @@ -19,6 +19,11 @@ virutal environment. 3) To create a Token Header: -`venv/bin/python make_hawk_token.py` +You'll need to pass along your `SYNC_MASTER_SECRET` and the uri you'll be testing in order to generate a valid Hawk Id: + +`venv/bin/python make_hawk_token.py --uri /1.5/1/storage/meta/global --secret=$SYNC_MASTER_SECRET --as_header` + +** For testing against uri's using methods other than GET, you'll need to pass along the `--method` flag to generate your token. Ie, `venv/bin/python make_hawk_token.py --method PUT --uri /1.5/1/storage/meta/global --secret=$SYNC_MASTER_SECRET --as_header`. See [examples/put.bash](https://github.com/mozilla-services/syncstorage-rs/blob/master/tools/examples/put.bash) for an example of this. + Use `-h` for help. diff --git a/tools/poster/README.md b/tools/poster/README.md deleted file mode 100644 index 716042da..00000000 --- a/tools/poster/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Post a fake BSO to the local server - -`post.bash` is a crappy bash script that attempts to post a fake BSO to a local instance of syncserver-rs. It's useful for line testing operations. - From e1b2560345ee99bff30fadcdcb8433f88065a5f3 Mon Sep 17 00:00:00 2001 From: Rachel Tublitz Date: Thu, 5 Dec 2019 17:37:21 -0500 Subject: [PATCH 4/4] chore: adjust perms on sample file --- tools/examples/put.bash | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tools/examples/put.bash diff --git a/tools/examples/put.bash b/tools/examples/put.bash old mode 100755 new mode 100644