commit bcbe6177b8a0cf7d320a683b1c636aec363a0d0f parent 7439aeb63ef692510c121a0e9f090d58de8d87e2 Author: BlackDex <black.dex@gmail.com> Date: Mon, 16 Mar 2020 17:19:27 +0100 Merge branch 'master' of https://github.com/dani-garcia/bitwarden_rs into log-panics Diffstat:
64 files changed, 1715 insertions(+), 659 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md @@ -1,33 +0,0 @@ -<!-- -Please fill out the following template to make solving your problem easier and faster for us. -This is only a guideline. If you think that parts are unneccessary for your issue, feel free to remove them. - -Remember to hide/obfuscate personal and confidential information, -such as names, global IP/DNS adresses and especially passwords, if neccessary. ---> - -### Subject of the issue -<!-- Describe your issue here.--> - -### Your environment -<!-- The version number, obtained from the logs or the admin page --> -* Bitwarden_rs version: -<!-- How the server was installed: Docker image / package / built from source --> -* Install method: -* Clients used: <!-- if applicable --> -* Reverse proxy and version: <!-- if applicable --> -* Version of mysql/postgresql: <!-- if applicable --> -* Other relevant information: - -### Steps to reproduce -<!-- Tell us how to reproduce this issue. What parameters did you set (differently from the defaults) -and how did you start bitwarden_rs? --> - -### Expected behaviour -<!-- Tell us what should happen --> - -### Actual behaviour -<!-- Tell us what happens instead --> - -### Relevant logs -<!-- Share some logfiles, screenshots or output of relevant programs with us. --> diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,42 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +<!-- +Please fill out the following template to make solving your problem easier and faster for us. +This is only a guideline. If you think that parts are unneccessary for your issue, feel free to remove them. + +Remember to hide/obfuscate personal and confidential information, +such as names, global IP/DNS adresses and especially passwords, if neccessary. +--> + +### Subject of the issue +<!-- Describe your issue here.--> + +### Your environment +<!-- The version number, obtained from the logs or the admin page --> +* Bitwarden_rs version: +<!-- How the server was installed: Docker image / package / built from source --> +* Install method: +* Clients used: <!-- if applicable --> +* Reverse proxy and version: <!-- if applicable --> +* Version of mysql/postgresql: <!-- if applicable --> +* Other relevant information: + +### Steps to reproduce +<!-- Tell us how to reproduce this issue. What parameters did you set (differently from the defaults) +and how did you start bitwarden_rs? --> + +### Expected behaviour +<!-- Tell us what should happen --> + +### Actual behaviour +<!-- Tell us what happens instead --> + +### Relevant logs +<!-- Share some logfiles, screenshots or output of relevant programs with us. --> diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,11 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: better for forum +assignees: '' + +--- + +# Please submit all your feature requests to the forum +Link: https://bitwardenrs.discourse.group/c/feature-requests diff --git a/.github/ISSUE_TEMPLATE/help-with-installation-configuration.md b/.github/ISSUE_TEMPLATE/help-with-installation-configuration.md @@ -0,0 +1,11 @@ +--- +name: Help with installation/configuration +about: Any questions about the setup of bitwarden_rs +title: '' +labels: better for forum +assignees: '' + +--- + +# Please submit all your third party help requests to the forum +Link: https://bitwardenrs.discourse.group/c/help diff --git a/.github/ISSUE_TEMPLATE/help-with-proxy-database-nas-setup.md b/.github/ISSUE_TEMPLATE/help-with-proxy-database-nas-setup.md @@ -0,0 +1,11 @@ +--- +name: Help with proxy/database/NAS setup +about: Any questions about third party software +title: '' +labels: better for forum +assignees: '' + +--- + +# Please submit all your third party help requests to the forum +Link: https://bitwardenrs.discourse.group/c/third-party-help diff --git a/Cargo.lock b/Cargo.lock @@ -8,14 +8,23 @@ checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" [[package]] name = "aho-corasick" -version = "0.7.7" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f56c476256dc249def911d6f7580b5fc7e875895b5d7ee88f5d602208035744" +checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" dependencies = [ "memchr", ] [[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] name = "arrayvec" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -55,9 +64,9 @@ checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" [[package]] name = "backtrace" -version = "0.3.43" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f80256bc78f67e7df7e36d77366f636ed976895d91fe2ab9efa3973e8fe8c4f" +checksum = "ad235dabf00f36301792cfe82499880ba54c6486be094d1047b02bacb67c14e8" dependencies = [ "backtrace-sys", "cfg-if", @@ -67,9 +76,9 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" +checksum = "e17b52e737c40a7d75abca20b29a19a0eb7ba9fc72c5a72dd282a0a3c2c0dc35" dependencies = [ "cc", "libc", @@ -122,7 +131,6 @@ dependencies = [ "handlebars", "idna 0.2.0", "jsonwebtoken", - "lazy_static", "lettre", "libsqlite3-sys", "log 0.4.8", @@ -131,11 +139,12 @@ dependencies = [ "num-derive", "num-traits", "oath", + "once_cell", "openssl", "percent-encoding 2.1.0", "quoted_printable", "regex", - "reqwest", + "reqwest 0.10.4", "ring", "rmpv", "rocket", @@ -144,6 +153,7 @@ dependencies = [ "serde_derive", "serde_json", "soup", + "structopt", "syslog", "u2f", "uuid 0.8.1", @@ -189,6 +199,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" [[package]] +name = "bumpalo" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742" + +[[package]] name = "byte-tools" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -202,9 +218,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.2" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "bytes" @@ -218,6 +234,12 @@ dependencies = [ ] [[package]] +name = "bytes" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" + +[[package]] name = "c2-chacha" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -250,9 +272,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" +checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" dependencies = [ "num-integer", "num-traits", @@ -260,6 +282,21 @@ dependencies = [ ] [[package]] +name = "clap" +version = "2.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -304,9 +341,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" dependencies = [ "core-foundation-sys", "libc", @@ -314,9 +351,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" [[package]] name = "crc32fast" @@ -329,54 +366,47 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" +checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" dependencies = [ "crossbeam-epoch", - "crossbeam-utils 0.7.0", + "crossbeam-utils", + "maybe-uninit", ] [[package]] name = "crossbeam-epoch" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg 0.1.7", + "autocfg 1.0.0", "cfg-if", - "crossbeam-utils 0.7.0", + "crossbeam-utils", "lazy_static", + "maybe-uninit", "memoffset", "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" -dependencies = [ - "crossbeam-utils 0.6.6", -] - -[[package]] -name = "crossbeam-utils" -version = "0.6.6" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" dependencies = [ "cfg-if", - "lazy_static", + "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 0.1.7", + "autocfg 1.0.0", "cfg-if", "lazy_static", ] @@ -403,9 +433,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" +checksum = "11c0346158a19b3627234e15596f5e465c360fcdb97d817bcb255e0510f5a788" [[package]] name = "data-url" @@ -417,13 +447,13 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.2" +version = "0.99.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2159be042979966de68315bce7034bb000c775f22e3e834e1c52ff78f041cae8" +checksum = "a806e96c59a76a5ba6e18735b6cf833344671e61e7863f2edb5c518ea2cac95c" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] @@ -441,7 +471,7 @@ version = "0.3.0" source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089" dependencies = [ "devise_core", - "quote 1.0.2", + "quote 1.0.3", ] [[package]] @@ -450,9 +480,9 @@ version = "0.3.0" source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089" dependencies = [ "bitflags", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] @@ -478,9 +508,9 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] @@ -638,18 +668,18 @@ dependencies = [ [[package]] name = "error-chain" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" +checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" dependencies = [ - "version_check 0.1.5", + "version_check 0.9.1", ] [[package]] name = "failure" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" dependencies = [ "backtrace", "failure_derive", @@ -657,13 +687,13 @@ dependencies = [ [[package]] name = "failure_derive" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" +checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", "synstructure", ] @@ -684,11 +714,10 @@ dependencies = [ [[package]] name = "fern" -version = "0.5.9" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69ab0d5aca163e388c3a49d284fed6c3d0810700e77c5ae2756a50ec1a4daaa" +checksum = "8c9a4820f0ccc8a7afd67c39a0f1a0f4b07ca1725164271a64939d7aeb9af065" dependencies = [ - "chrono", "log 0.4.8", "syslog", ] @@ -796,6 +825,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" [[package]] +name = "futures-channel" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" + +[[package]] name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -806,6 +850,38 @@ dependencies = [ ] [[package]] +name = "futures-io" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" + +[[package]] +name = "futures-sink" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6" + +[[package]] +name = "futures-task" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" + +[[package]] +name = "futures-util" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-utils", + "slab", +] + +[[package]] name = "generic-array" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -842,10 +918,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" dependencies = [ "byteorder", - "bytes", + "bytes 0.4.12", "fnv", "futures", - "http", + "http 0.1.21", "indexmap", "log 0.4.8", "slab", @@ -854,6 +930,25 @@ dependencies = [ ] [[package]] +name = "h2" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5c295d1c0c68e4e42003d75f908f5e16a1edd1cbe0b0d02e4dc2006a384f47" +dependencies = [ + "bytes 0.5.4", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.0", + "indexmap", + "log 0.4.8", + "slab", + "tokio 0.2.13", + "tokio-util", +] + +[[package]] name = "handlebars" version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -869,10 +964,19 @@ dependencies = [ ] [[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", +] + +[[package]] name = "hermit-abi" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" +checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8" dependencies = [ "libc", ] @@ -900,9 +1004,9 @@ dependencies = [ [[package]] name = "hostname" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01b1af8d6d068ba9de1c39c6ff0d879aed20f74873d4d3929a4535000bb07886" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" dependencies = [ "libc", "match_cfg", @@ -911,16 +1015,16 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b04478cf718862650a0bf66acaf8f2f8c906fbc703f35c916c1f4211b069a364" +checksum = "c213fa6a618dc1da552f54f85cba74b05d8e883c92ec4e89067736938084c26e" dependencies = [ "log 0.4.8", "mac", "markup5ever", - "proc-macro2 0.3.8", - "quote 0.5.2", - "syn 0.13.11", + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", ] [[package]] @@ -929,7 +1033,18 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" dependencies = [ - "bytes", + "bytes 0.4.12", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" +dependencies = [ + "bytes 0.5.4", "fnv", "itoa", ] @@ -940,13 +1055,23 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" dependencies = [ - "bytes", + "bytes 0.4.12", "futures", - "http", + "http 0.1.21", "tokio-buf", ] [[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes 0.5.4", + "http 0.2.0", +] + +[[package]] name = "httparse" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -977,12 +1102,12 @@ version = "0.12.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" dependencies = [ - "bytes", + "bytes 0.4.12", "futures", "futures-cpupool", - "h2", - "http", - "http-body", + "h2 0.1.26", + "http 0.1.21", + "http-body 0.1.0", "httparse", "iovec", "itoa", @@ -990,7 +1115,7 @@ dependencies = [ "net2", "rustc_version", "time 0.1.42", - "tokio", + "tokio 0.1.22", "tokio-buf", "tokio-executor", "tokio-io", @@ -998,7 +1123,31 @@ dependencies = [ "tokio-tcp", "tokio-threadpool", "tokio-timer", - "want", + "want 0.2.0", +] + +[[package]] +name = "hyper" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7b15203263d1faa615f9337d79c1d37959439dc46c2b4faab33286fadc2a1c5" +dependencies = [ + "bytes 0.5.4", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.2.2", + "http 0.2.0", + "http-body 0.3.1", + "httparse", + "itoa", + "log 0.4.8", + "net2", + "pin-project", + "time 0.1.42", + "tokio 0.2.13", + "tower-service", + "want 0.3.0", ] [[package]] @@ -1019,7 +1168,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" dependencies = [ - "bytes", + "bytes 0.4.12", "futures", "hyper 0.12.35", "native-tls", @@ -1027,6 +1176,19 @@ dependencies = [ ] [[package]] +name = "hyper-tls" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3adcd308402b9553630734e9c36b77a7e48b3821251ca2493e8cd596763aafaa" +dependencies = [ + "bytes 0.5.4", + "hyper 0.13.3", + "native-tls", + "tokio 0.2.13", + "tokio-tls", +] + +[[package]] name = "idna" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1050,9 +1212,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" +checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" dependencies = [ "autocfg 1.0.0", ] @@ -1093,6 +1255,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" [[package]] +name = "js-sys" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cb931d43e71f560c81badb0191596562bafad2be06a3f9025b845c847c60df5" +dependencies = [ + "wasm-bindgen", +] + +[[package]] name = "jsonwebtoken" version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1151,15 +1322,15 @@ dependencies = [ "nom", "serde", "serde_json", - "time 0.2.6", + "time 0.2.7", "uuid 0.8.1", ] [[package]] name = "lexical-core" -version = "0.4.6" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304bccb228c4b020f3a4835d247df0a02a7c4686098d4167762cfbbe4c5cb14" +checksum = "d7043aa5c05dd34fb73b47acb8c3708eac428de4545ea3682ed2f11293ebd890" dependencies = [ "arrayvec", "cfg-if", @@ -1170,9 +1341,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.66" +version = "0.2.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" +checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" [[package]] name = "libsqlite3-sys" @@ -1260,9 +1431,9 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" -version = "2.3.0" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] name = "memoffset" @@ -1289,9 +1460,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719ef0bc7f531428764c9b70661c14abd50a7f3d21f355752d9985aa21251c9e" dependencies = [ "migrations_internals", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] @@ -1311,9 +1482,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mime_guess" -version = "1.8.7" +version = "1.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d977de9ee851a0b16e932979515c0f3da82403183879811bc97d50bd9cc50f7" +checksum = "216929a5ee4dd316b1702eedf5e74548c123d370f47841ceaac38ca154690ca3" dependencies = [ "mime 0.2.6", "phf", @@ -1323,9 +1494,9 @@ dependencies = [ [[package]] name = "mime_guess" -version = "2.0.1" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" +checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" dependencies = [ "mime 0.3.16", "unicase 2.6.0", @@ -1333,9 +1504,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" +checksum = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" dependencies = [ "adler32", ] @@ -1393,7 +1564,7 @@ dependencies = [ "httparse", "log 0.4.8", "mime 0.2.6", - "mime_guess 1.8.7", + "mime_guess 1.8.8", "quick-error", "rand 0.6.5", "safemem", @@ -1413,9 +1584,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" +checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" dependencies = [ "lazy_static", "libc", @@ -1454,13 +1625,13 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" [[package]] name = "nom" -version = "5.1.0" +version = "5.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c433f4d505fe6ce7ff78523d2fa13a0b9f2690e181fc26168bcbe5ccc5d14e07" +checksum = "0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6" dependencies = [ "lexical-core", "memchr", - "version_check 0.1.5", + "version_check 0.9.1", ] [[package]] @@ -1487,9 +1658,9 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c8b15b261814f992e33760b1fca9fe8b693d8a65299f20c9901688636cfb746" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] @@ -1535,6 +1706,12 @@ dependencies = [ ] [[package]] +name = "once_cell" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" + +[[package]] name = "opaque-debug" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1542,9 +1719,9 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "openssl" -version = "0.10.27" +version = "0.10.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e176a45fedd4c990e26580847a525e39e16ec32ac78957dbf62ded31b3abfd6f" +checksum = "973293749822d7dd6370d6da1e523b0d1db19f06c459134c658b2a4261378b52" dependencies = [ "bitflags", "cfg-if", @@ -1690,9 +1867,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pest" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4fb201c5c22a55d8b24fef95f78be52738e5e1361129be1b5e862ecdb6894a" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" dependencies = [ "ucd-trie", ] @@ -1709,22 +1886,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b9fcf299b5712d06ee128a556c94709aaa04512c4dffb8ead07c5c998447fc0" +checksum = "27e5277315f6b4f27e0e6744feb5d5ba1891e7164871033d3c8344c6783b349a" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] name = "pest_meta" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df43fd99896fd72c485fe47542c7b500e4ac1e8700bf995544d1317a60ded547" +checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" dependencies = [ "maplit", "pest", @@ -1771,6 +1948,38 @@ dependencies = [ ] [[package]] +name = "pin-project" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f" +dependencies = [ + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" + +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" + +[[package]] name = "pkg-config" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1798,23 +2007,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] -name = "proc-macro-hack" -version = "0.5.11" +name = "proc-macro-error" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +checksum = "e7959c6467d962050d639361f7703b2051c43036d03493c36f01d440fdd3138a" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro-error-attr", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", + "version_check 0.9.1", ] [[package]] -name = "proc-macro2" -version = "0.3.8" +name = "proc-macro-error-attr" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" +checksum = "e4002d9f55991d5e019fb940a90e1a95eb80c24e77cb2462dd4dc869604d543a" dependencies = [ - "unicode-xid 0.1.0", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", + "syn-mid", + "version_check 0.9.1", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +dependencies = [ + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] @@ -1828,9 +2054,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" +checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" dependencies = [ "unicode-xid 0.2.0", ] @@ -1841,7 +2067,7 @@ version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bbaa49075179162b49acac1c6aa45fb4dafb5f13cf6794276d77bc7fd95757b" dependencies = [ - "error-chain 0.12.1", + "error-chain 0.12.2", "idna 0.2.0", "lazy_static", "regex", @@ -1856,15 +2082,6 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" -dependencies = [ - "proc-macro2 0.3.8", -] - -[[package]] -name = "quote" version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" @@ -1874,18 +2091,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ - "proc-macro2 1.0.8", + "proc-macro2 1.0.9", ] [[package]] name = "quoted_printable" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86cedf331228892e747bb85beb130b6bb23fc628c40dde9ea01eb6becea3c798" +checksum = "47b080c5db639b292ac79cbd34be0cfc5d36694768d8341109634d90b86930e2" [[package]] name = "r2d2" @@ -2075,9 +2292,9 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" [[package]] name = "regex" -version = "1.3.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5508c1941e4e7cb19965abef075d35a9a8b5cdf0846f30b4050e9b55dc55e87" +checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" dependencies = [ "aho-corasick", "memchr", @@ -2087,9 +2304,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.13" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e734e891f5b408a29efbf8309e656876276f49ab6a6ac208600b4419bd893d90" +checksum = "1132f845907680735a84409c3bebc64d1364a5683ffbce899550cd09d5eaefc1" [[package]] name = "remove_dir_all" @@ -2107,24 +2324,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab" dependencies = [ "base64 0.10.1", - "bytes", + "bytes 0.4.12", "cookie", "cookie_store", "encoding_rs", "flate2", "futures", - "http", + "http 0.1.21", "hyper 0.12.35", - "hyper-tls", + "hyper-tls 0.3.2", "log 0.4.8", "mime 0.3.16", - "mime_guess 2.0.1", + "mime_guess 2.0.3", "native-tls", "serde", "serde_json", - "serde_urlencoded", + "serde_urlencoded 0.5.5", "time 0.1.42", - "tokio", + "tokio 0.1.22", "tokio-executor", "tokio-io", "tokio-threadpool", @@ -2135,6 +2352,42 @@ dependencies = [ ] [[package]] +name = "reqwest" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b81e49ddec5109a9dcfc5f2a317ff53377c915e9ae9d4f2fb50914b85614e2" +dependencies = [ + "base64 0.11.0", + "bytes 0.5.4", + "encoding_rs", + "futures-core", + "futures-util", + "http 0.2.0", + "http-body 0.3.1", + "hyper 0.13.3", + "hyper-tls 0.4.1", + "js-sys", + "lazy_static", + "log 0.4.8", + "mime 0.3.16", + "mime_guess 2.0.3", + "native-tls", + "percent-encoding 2.1.0", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded 0.6.1", + "time 0.1.42", + "tokio 0.2.13", + "tokio-tls", + "url 2.1.1", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] name = "ring" version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2195,7 +2448,7 @@ source = "git+https://github.com/SergioBenitez/Rocket?rev=b95b6765e1cc8be7c1e7ea dependencies = [ "devise", "indexmap", - "quote 1.0.2", + "quote 1.0.3", "rocket_http", "version_check 0.9.1", "yansi 0.5.0", @@ -2272,9 +2525,9 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] @@ -2300,9 +2553,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" +checksum = "507a9e6e8ffe0a4e0ebb9a10293e62fdf7657c06f1b8bb07a8fcf697d2abf295" dependencies = [ "lazy_static", "winapi 0.3.8", @@ -2319,9 +2572,9 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "sct" @@ -2335,23 +2588,24 @@ dependencies = [ [[package]] name = "security-framework" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef2429d7cefe5fd28bd1d2ed41c944547d4ff84776f5935b456da44593a16df" +checksum = "97bbedbe81904398b6ebb054b3e912f99d55807125790f3198ac990d98def5b0" dependencies = [ + "bitflags", "core-foundation", "core-foundation-sys", - "libc", "security-framework-sys", ] [[package]] name = "security-framework-sys" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31493fc37615debb8c5090a7aeb4a9730bc61e77ab10b9af59f1a202284f895" +checksum = "06fd2f23e31ef68dd2328cc383bd493142e46107a3a0e24f7d734e3f3b80fe4c" dependencies = [ "core-foundation-sys", + "libc", ] [[package]] @@ -2384,16 +2638,16 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] name = "serde_json" -version = "1.0.45" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b" +checksum = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25" dependencies = [ "itoa", "ryu", @@ -2413,6 +2667,18 @@ dependencies = [ ] [[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa", + "serde", + "url 2.1.1", +] + +[[package]] name = "sha-1" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2479,9 +2745,9 @@ checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" [[package]] name = "soup" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16eb6b0678654a57009598ed84610f2afa5fadb22f3815e9f23dc5eab1056031" +checksum = "ee42b8c117ede655c8ffe18dafcd239b23eb3bb7a2c71b1f01237587736f139f" dependencies = [ "html5ever", "regex", @@ -2517,7 +2783,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" dependencies = [ - "bytes", + "bytes 0.4.12", ] [[package]] @@ -2543,8 +2809,8 @@ checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" dependencies = [ "phf_generator", "phf_shared", - "proc-macro2 1.0.8", - "quote 1.0.2", + "proc-macro2 1.0.9", + "quote 1.0.3", "string_cache_shared", ] @@ -2555,6 +2821,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" [[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fe43617218c0805c6eb37160119dc3c548110a67786da7218d1c6555212f073" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e79c80e0f4efd86ca960218d4e056249be189ff1c42824dcd9a7f51a56f0bd" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", +] + +[[package]] name = "subtle" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2568,17 +2864,6 @@ checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" [[package]] name = "syn" -version = "0.13.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" -dependencies = [ - "proc-macro2 0.3.8", - "quote 0.5.2", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" version = "0.15.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" @@ -2590,24 +2875,35 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" +checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", + "proc-macro2 1.0.9", + "quote 1.0.3", "unicode-xid 0.2.0", ] [[package]] +name = "syn-mid" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" +dependencies = [ + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", +] + +[[package]] name = "synstructure" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", "unicode-xid 0.2.0", ] @@ -2649,6 +2945,15 @@ dependencies = [ ] [[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] name = "thread_local" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2679,12 +2984,14 @@ dependencies = [ [[package]] name = "time" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcb8742444475438c500d017736dd7cf3d9c9dd1f0153cfa4af428692484e3ef" +checksum = "3043ac959c44dccc548a57417876c8fe241502aed69d880efc91166c02717a93" dependencies = [ + "libc", "rustversion", "time-macros", + "winapi 0.3.8", ] [[package]] @@ -2704,9 +3011,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e987cfe0537f575b5fc99909de6185f6c19c3ad8889e2275e686a873d0869ba1" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.8", - "quote 1.0.2", - "syn 1.0.14", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", ] [[package]] @@ -2715,7 +3022,7 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" dependencies = [ - "bytes", + "bytes 0.4.12", "futures", "mio", "num_cpus", @@ -2729,21 +3036,38 @@ dependencies = [ ] [[package]] +name = "tokio" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa5e81d6bc4e67fe889d5783bd2a128ab2e0cfa487e0be16b6a8d177b101616" +dependencies = [ + "bytes 0.5.4", + "fnv", + "iovec", + "lazy_static", + "memchr", + "mio", + "num_cpus", + "pin-project-lite", + "slab", +] + +[[package]] name = "tokio-buf" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" dependencies = [ - "bytes", + "bytes 0.4.12", "either", "futures", ] [[package]] name = "tokio-current-thread" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" +checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" dependencies = [ "futures", "tokio-executor", @@ -2751,32 +3075,32 @@ dependencies = [ [[package]] name = "tokio-executor" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6df436c42b0c3330a82d855d2ef017cd793090ad550a6bc2184f4b933532ab" +checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" dependencies = [ - "crossbeam-utils 0.6.6", + "crossbeam-utils", "futures", ] [[package]] name = "tokio-io" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" +checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" dependencies = [ - "bytes", + "bytes 0.4.12", "futures", "log 0.4.8", ] [[package]] name = "tokio-reactor" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6732fe6b53c8d11178dcb77ac6d9682af27fc6d4cb87789449152e5377377146" +checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" dependencies = [ - "crossbeam-utils 0.6.6", + "crossbeam-utils", "futures", "lazy_static", "log 0.4.8", @@ -2791,9 +3115,9 @@ dependencies = [ [[package]] name = "tokio-sync" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06554cce1ae4a50f42fba8023918afa931413aded705b560e29600ccf7c6d76" +checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" dependencies = [ "fnv", "futures", @@ -2801,11 +3125,11 @@ dependencies = [ [[package]] name = "tokio-tcp" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" +checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" dependencies = [ - "bytes", + "bytes 0.4.12", "futures", "iovec", "mio", @@ -2815,13 +3139,13 @@ dependencies = [ [[package]] name = "tokio-threadpool" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c32ffea4827978e9aa392d2f743d973c1dfa3730a2ed3f22ce1e6984da848c" +checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" dependencies = [ "crossbeam-deque", "crossbeam-queue", - "crossbeam-utils 0.6.6", + "crossbeam-utils", "futures", "lazy_static", "log 0.4.8", @@ -2832,17 +3156,41 @@ dependencies = [ [[package]] name = "tokio-timer" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1739638e364e558128461fc1ad84d997702c8e31c2e6b18fb99842268199e827" +checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" dependencies = [ - "crossbeam-utils 0.6.6", + "crossbeam-utils", "futures", "slab", "tokio-executor", ] [[package]] +name = "tokio-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bde02a3a5291395f59b06ec6945a3077602fac2b07eeeaf0dee2122f3619828" +dependencies = [ + "native-tls", + "tokio 0.2.13", +] + +[[package]] +name = "tokio-util" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" +dependencies = [ + "bytes 0.5.4", + "futures-core", + "futures-sink", + "log 0.4.8", + "pin-project-lite", + "tokio 0.2.13", +] + +[[package]] name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2852,6 +3200,12 @@ dependencies = [ ] [[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] name = "traitobject" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2901,7 +3255,7 @@ checksum = "e2f285392366190c4d46823458f4543ac0f35174759c78e80c5baa39e1f7aa4f" dependencies = [ "base64 0.11.0", "byteorder", - "bytes", + "bytes 0.4.12", "chrono", "openssl", "serde", @@ -2953,6 +3307,18 @@ dependencies = [ ] [[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" + +[[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3023,6 +3389,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" [[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" + +[[package]] name = "version_check" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3057,12 +3429,100 @@ dependencies = [ ] [[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log 0.4.8", + "try-lock", +] + +[[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] +name = "wasm-bindgen" +version = "0.2.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3557c397ab5a8e347d434782bcd31fc1483d927a6826804cec05cc792ee2519d" +dependencies = [ + "cfg-if", + "serde", + "serde_json", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0da9c9a19850d3af6df1cb9574970b566d617ecfaf36eb0b706b6f3ef9bd2f8" +dependencies = [ + "bumpalo", + "lazy_static", + "log 0.4.8", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "457414a91863c0ec00090dba537f88ab955d93ca6555862c29b6d860990b8a8a" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f6fde1d36e75a714b5fe0cffbb78978f222ea6baebb726af13c78869fdb4205" +dependencies = [ + "quote 1.0.3", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25bda4168030a6412ea8a047e27238cadf56f0e53516e1e83fec0a8b7c786f6d" +dependencies = [ + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8" + +[[package]] +name = "web-sys" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721c6263e2c66fd44501cc5efbfa2b7dfa775d13e4ea38c46299646ed1f9c70a" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] name = "webpki" version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3141,7 +3601,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c51a2c47b5798ccc774ffb93ff536aec7c4275d722fd9c740c83cdd1af1f2d94" dependencies = [ "byteorder", - "bytes", + "bytes 0.4.12", "httparse", "log 0.4.8", "mio", @@ -3185,7 +3645,7 @@ dependencies = [ "futures", "hmac 0.7.1", "rand 0.6.5", - "reqwest", + "reqwest 0.9.24", "sha-1 0.8.2", "subtle 2.2.2", "threadpool", diff --git a/Cargo.toml b/Cargo.toml @@ -26,7 +26,8 @@ rocket = { version = "0.5.0-dev", features = ["tls"], default-features = false } rocket_contrib = "0.5.0-dev" # HTTP client -reqwest = "0.9.24" +# reqwest = "0.9.24" +reqwest = { version = "0.10.4", features = ["blocking", "json"] } # multipart/form-data support multipart = { version = "0.16.1", features = ["server"], default-features = false } @@ -35,7 +36,7 @@ multipart = { version = "0.16.1", features = ["server"], default-features = fals ws = "0.9.1" # MessagePack library -rmpv = "0.4.3" +rmpv = "0.4.4" # Concurrent hashmap implementation chashmap = "2.2.2" @@ -43,17 +44,17 @@ chashmap = "2.2.2" # A generic serialization/deserialization framework serde = "1.0.104" serde_derive = "1.0.104" -serde_json = "1.0.45" +serde_json = "1.0.48" # Logging log = "0.4.8" -fern = { version = "0.5.9", features = ["syslog-4"] } +fern = { version = "0.6.0", features = ["syslog-4"] } # A safe, extensible ORM and Query builder diesel = { version = "1.4.3", features = [ "chrono", "r2d2"] } diesel_migrations = "1.4.0" -# Bundled SQLite +# Bundled SQLite libsqlite3-sys = { version = "0.16.0", features = ["bundled"], optional = true } # Crypto library @@ -63,13 +64,13 @@ ring = "0.14.6" uuid = { version = "0.8.1", features = ["v4"] } # Date and time library for Rust -chrono = "0.4.10" +chrono = "0.4.11" # TOTP library oath = "0.10.2" # Data encoding library -data-encoding = "2.1.2" +data-encoding = "2.2.0" # JWT library jsonwebtoken = "6.0.1" @@ -83,11 +84,11 @@ yubico = { version = "0.7.1", features = ["online-tokio"], default-features = fa # A `dotenv` implementation for Rust dotenv = { version = "0.15.0", default-features = false } -# Lazy static macro -lazy_static = "1.4.0" +# Lazy initialization +once_cell = "1.3.1" # More derives -derive_more = "0.99.2" +derive_more = "0.99.3" # Numerical libraries num-traits = "0.2.11" @@ -95,25 +96,28 @@ num-derive = "0.3.0" # Email libraries lettre = "0.10.0-pre" -native-tls = "0.2.3" -quoted_printable = "0.4.1" +native-tls = "0.2.4" +quoted_printable = "0.4.2" # Template library handlebars = { version = "3.0.1", features = ["dir_source"] } # For favicon extraction from main website -soup = "0.4.1" -regex = "1.3.3" +soup = "0.5.0" +regex = "1.3.4" data-url = "0.1.0" # Used by U2F, JWT and Postgres -openssl = "0.10.26" +openssl = "0.10.28" # URL encoding library percent-encoding = "2.1.0" # Punycode conversion idna = "0.2.0" +# CLI argument parsing +structopt = "0.3.11" + [patch.crates-io] # Use newest ring rocket = { git = 'https://github.com/SergioBenitez/Rocket', rev = 'b95b6765e1cc8be7c1e7eaef8a9d9ad940b0ac13' } diff --git a/README.md b/README.md @@ -13,7 +13,7 @@ Image is based on [Rust implementation of Bitwarden API](https://github.com/dani **This project is not associated with the [Bitwarden](https://bitwarden.com/) project nor 8bit Solutions LLC.** -#### ⚠️**IMPORTANT**⚠️: When using this server, please report any Bitwarden related bug-reports or suggestions [here](https://github.com/dani-garcia/bitwarden_rs/issues/new), regardless of whatever clients you are using (mobile, desktop, browser...). DO NOT use the official support channels. +#### ⚠️**IMPORTANT**⚠️: When using this server, please report any bugs or suggestions to us directly (look at the bottom of this page for ways to get in touch), regardless of whatever clients you are using (mobile, desktop, browser...). DO NOT use the official support channels. --- @@ -21,14 +21,14 @@ Image is based on [Rust implementation of Bitwarden API](https://github.com/dani Basically full implementation of Bitwarden API is provided including: - * Basic single user functionality + * Single user functionality * Organizations support * Attachments * Vault API support * Serving the static files for Vault interface * Website icons API * Authenticator and U2F support - * YubiKey OTP + * YubiKey and Duo support ## Installation Pull the docker image and mount a volume from the host for persistent storage: @@ -49,13 +49,13 @@ If you have an available domain name, you can get HTTPS certificates with [Let's See the [bitwarden_rs wiki](https://github.com/dani-garcia/bitwarden_rs/wiki) for more information on how to configure and run the bitwarden_rs server. ## Get in touch +To ask a question, offer suggestions or new features or to get help configuring or installing the software, please [use the forum](https://bitwardenrs.discourse.group/). -To ask a question, [raising an issue](https://github.com/dani-garcia/bitwarden_rs/issues/new) is fine. Please also report any bugs spotted here. +If you spot any bugs or crashes with bitwarden_rs itself, please [create an issue](https://github.com/dani-garcia/bitwarden_rs/issues/). Make sure there aren't any similar issues open, though! If you prefer to chat, we're usually hanging around at [#bitwarden_rs:matrix.org](https://matrix.to/#/#bitwarden_rs:matrix.org) room on Matrix. Feel free to join us! ### Sponsors Thanks for your contribution to the project! -- [@Skaronator](https://github.com/Skaronator) - [@ChonoN](https://github.com/ChonoN) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 @@ -1,16 +1,10 @@ -{{ "# This file was generated using a Jinja2 template." }} -{{ "# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's." }} +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. -# Using multistage build: -# https://docs.docker.com/develop/develop-images/multistage-build/ -# https://whitfin.io/speeding-up-rust-docker-builds/ -####################### VAULT BUILD IMAGE ####################### {% set build_stage_base_image = "rust:1.40" %} -{% set vault_stage_base_image = build_stage_base_image %} {% if "alpine" in target_file %} -{% set build_stage_base_image = "clux/muslrust:nightly-2019-12-19" %} +{% set build_stage_base_image = "clux/muslrust:nightly-2020-03-09" %} {% set runtime_stage_base_image = "alpine:3.11" %} -{% set vault_stage_base_image = runtime_stage_base_image %} {% set package_arch_name = "" %} {% elif "amd64" in target_file %} {% set runtime_stage_base_image = "debian:buster-slim" %} @@ -29,30 +23,23 @@ {% if package_arch_name == "" %} {% set package_arch_prefix = "" %} {% endif %} -FROM {{ vault_stage_base_image }} as vault - -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -{% if "alpine" in vault_stage_base_image %} -RUN apk add --no-cache --upgrade curl tar -{% else %} -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color -{% endif %} - -RUN mkdir /web-vault -WORKDIR /web-vault - -{% if "alpine" in vault_stage_base_image %} -SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] -{% else %} -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] -{% endif %} - -RUN curl -L $URL | tar xz -RUN ls +# Using multistage build: +# https://docs.docker.com/develop/develop-images/multistage-build/ +# https://whitfin.io/speeding-up-rust-docker-builds/ +####################### VAULT BUILD IMAGE ####################### +{% set vault_image_hash = "sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c" %} +{% raw %} +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +{% endraw %} +FROM bitwardenrs/web-vault@{{ vault_image_hash }} as vault ########################## BUILD IMAGE ########################## {% if "musl" in build_stage_base_image %} diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine @@ -5,21 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -RUN apk add --no-cache --upgrade curl tar - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # Musl build image for statically compiled binary diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/docker/amd64/postgresql/Dockerfile.alpine b/docker/amd64/postgresql/Dockerfile.alpine @@ -5,21 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -RUN apk add --no-cache --upgrade curl tar - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # Musl build image for statically compiled binary diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine @@ -5,21 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -RUN apk add --no-cache --upgrade curl tar - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # Musl build image for statically compiled binary diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile @@ -5,22 +5,17 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM rust:1.40 as vault -ENV VAULT_VERSION "v2.12.0c" - -ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - -# Build time options to avoid dpkg warnings and help with reproducible builds. -ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color - -RUN mkdir /web-vault -WORKDIR /web-vault - -SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] - -RUN curl -L $URL | tar xz -RUN ls +# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable. +# It can be viewed in multiple ways: +# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there. +# - From the console, with the following commands: +# docker pull bitwardenrs/web-vault:v2.12.0e +# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.12.0e +# +# - To do the opposite, and get the tag from the hash, you can do: +# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c +FROM bitwardenrs/web-vault@sha256:feb3f46d15738191b9043be4cdb1be2c0078ed411e7b7be73a2f4fcbca01e13c as vault ########################## BUILD IMAGE ########################## # We need to use the Rust build image, because diff --git a/migrations/mysql/2020-03-13-205045_add_policy_table/down.sql b/migrations/mysql/2020-03-13-205045_add_policy_table/down.sql @@ -0,0 +1 @@ +DROP TABLE org_policies; diff --git a/migrations/mysql/2020-03-13-205045_add_policy_table/up.sql b/migrations/mysql/2020-03-13-205045_add_policy_table/up.sql @@ -0,0 +1,9 @@ +CREATE TABLE org_policies ( + uuid CHAR(36) NOT NULL PRIMARY KEY, + org_uuid CHAR(36) NOT NULL REFERENCES organizations (uuid), + atype INTEGER NOT NULL, + enabled BOOLEAN NOT NULL, + data TEXT NOT NULL, + + UNIQUE (org_uuid, atype) +); diff --git a/migrations/postgresql/2020-03-13-205045_add_policy_table/down.sql b/migrations/postgresql/2020-03-13-205045_add_policy_table/down.sql @@ -0,0 +1 @@ +DROP TABLE org_policies; diff --git a/migrations/postgresql/2020-03-13-205045_add_policy_table/up.sql b/migrations/postgresql/2020-03-13-205045_add_policy_table/up.sql @@ -0,0 +1,9 @@ +CREATE TABLE org_policies ( + uuid CHAR(36) NOT NULL PRIMARY KEY, + org_uuid CHAR(36) NOT NULL REFERENCES organizations (uuid), + atype INTEGER NOT NULL, + enabled BOOLEAN NOT NULL, + data TEXT NOT NULL, + + UNIQUE (org_uuid, atype) +); diff --git a/migrations/sqlite/2020-03-13-205045_add_policy_table/down.sql b/migrations/sqlite/2020-03-13-205045_add_policy_table/down.sql @@ -0,0 +1 @@ +DROP TABLE org_policies; diff --git a/migrations/sqlite/2020-03-13-205045_add_policy_table/up.sql b/migrations/sqlite/2020-03-13-205045_add_policy_table/up.sql @@ -0,0 +1,9 @@ +CREATE TABLE org_policies ( + uuid TEXT NOT NULL PRIMARY KEY, + org_uuid TEXT NOT NULL REFERENCES organizations (uuid), + atype INTEGER NOT NULL, + enabled BOOLEAN NOT NULL, + data TEXT NOT NULL, + + UNIQUE (org_uuid, atype) +); diff --git a/rust-toolchain b/rust-toolchain @@ -1 +1 @@ -nightly-2020-01-30 -\ No newline at end of file +nightly-2020-03-09 +\ No newline at end of file diff --git a/src/api/admin.rs b/src/api/admin.rs @@ -1,3 +1,4 @@ +use once_cell::sync::Lazy; use serde_json::Value; use std::process::Command; @@ -34,12 +35,12 @@ pub fn routes() -> Vec<Route> { post_config, delete_config, backup_db, + test_smtp, ] } -lazy_static! { - static ref CAN_BACKUP: bool = cfg!(feature = "sqlite") && Command::new("sqlite3").arg("-version").status().is_ok(); -} +static CAN_BACKUP: Lazy<bool> = + Lazy::new(|| cfg!(feature = "sqlite") && Command::new("sqlite3").arg("-version").status().is_ok()); #[get("/")] fn admin_disabled() -> &'static str { @@ -52,11 +53,15 @@ const ADMIN_PATH: &str = "/admin"; const BASE_TEMPLATE: &str = "admin/base"; const VERSION: Option<&str> = option_env!("GIT_VERSION"); +fn admin_path() -> String { + format!("{}{}", CONFIG.domain_path(), ADMIN_PATH) +} + #[get("/", rank = 2)] fn admin_login(flash: Option<FlashMessage>) -> ApiResult<Html<String>> { // If there is an error, show it let msg = flash.map(|msg| format!("{}: {}", msg.name(), msg.msg())); - let json = json!({"page_content": "admin/login", "version": VERSION, "error": msg}); + let json = json!({"page_content": "admin/login", "version": VERSION, "error": msg, "urlpath": CONFIG.domain_path()}); // Return the page let text = CONFIG.render_template(BASE_TEMPLATE, &json)?; @@ -76,7 +81,7 @@ fn post_admin_login(data: Form<LoginForm>, mut cookies: Cookies, ip: ClientIp) - if !_validate_token(&data.token) { error!("Invalid admin token. IP: {}", ip.ip); Err(Flash::error( - Redirect::to(ADMIN_PATH), + Redirect::to(admin_path()), "Invalid admin token, please try again.", )) } else { @@ -85,14 +90,14 @@ fn post_admin_login(data: Form<LoginForm>, mut cookies: Cookies, ip: ClientIp) - let jwt = encode_jwt(&claims); let cookie = Cookie::build(COOKIE_NAME, jwt) - .path(ADMIN_PATH) + .path(admin_path()) .max_age(chrono::Duration::minutes(20)) .same_site(SameSite::Strict) .http_only(true) .finish(); cookies.add(cookie); - Ok(Redirect::to(ADMIN_PATH)) + Ok(Redirect::to(admin_path())) } } @@ -111,6 +116,7 @@ struct AdminTemplateData { config: Value, can_backup: bool, logged_in: bool, + urlpath: String, } impl AdminTemplateData { @@ -122,6 +128,7 @@ impl AdminTemplateData { config: CONFIG.prepare_json(), can_backup: *CAN_BACKUP, logged_in: true, + urlpath: CONFIG.domain_path(), } } @@ -164,10 +171,22 @@ fn invite_user(data: Json<InviteData>, _token: AdminToken, conn: DbConn) -> Empt } } +#[post("/test/smtp", data = "<data>")] +fn test_smtp(data: Json<InviteData>, _token: AdminToken) -> EmptyResult { + let data: InviteData = data.into_inner(); + let email = data.email.clone(); + + if CONFIG.mail_enabled() { + mail::send_test(&email) + } else { + err!("Mail is not enabled") + } +} + #[get("/logout")] fn logout(mut cookies: Cookies) -> Result<Redirect, ()> { cookies.remove(Cookie::named(COOKIE_NAME)); - Ok(Redirect::to(ADMIN_PATH)) + Ok(Redirect::to(admin_path())) } #[get("/users")] diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs @@ -79,6 +79,9 @@ fn sync(data: Form<SyncData>, headers: Headers, conn: DbConn) -> JsonResult { let collections = Collection::find_by_user_uuid(&headers.user.uuid, &conn); let collections_json: Vec<Value> = collections.iter().map(Collection::to_json).collect(); + let policies = OrgPolicy::find_by_user(&headers.user.uuid, &conn); + let policies_json: Vec<Value> = policies.iter().map(OrgPolicy::to_json).collect(); + let ciphers = Cipher::find_by_user(&headers.user.uuid, &conn); let ciphers_json: Vec<Value> = ciphers .iter() @@ -95,6 +98,7 @@ fn sync(data: Form<SyncData>, headers: Headers, conn: DbConn) -> JsonResult { "Profile": user_json, "Folders": folders_json, "Collections": collections_json, + "Policies": policies_json, "Ciphers": ciphers_json, "Domains": domains_json, "Object": "sync" @@ -599,10 +603,14 @@ fn share_cipher_by_uuid( None => err!("Cipher doesn't exist"), }; + let mut shared_to_collection = false; + match data.Cipher.OrganizationId.clone() { - None => err!("Organization id not provided"), + // If we don't get an organization ID, we don't do anything + // No error because this is used when using the Clone functionality + None => {}, Some(organization_uuid) => { - let mut shared_to_collection = false; + for uuid in &data.CollectionIds { match Collection::find_by_uuid_and_org(uuid, &organization_uuid, &conn) { None => err!("Invalid collection ID provided"), @@ -616,19 +624,20 @@ fn share_cipher_by_uuid( } } } - update_cipher_from_data( - &mut cipher, - data.Cipher, - &headers, - shared_to_collection, - &conn, - &nt, - UpdateType::CipherUpdate, - )?; - - Ok(Json(cipher.to_json(&headers.host, &headers.user.uuid, &conn))) } - } + }; + + update_cipher_from_data( + &mut cipher, + data.Cipher, + &headers, + shared_to_collection, + &conn, + &nt, + UpdateType::CipherUpdate, + )?; + + Ok(Json(cipher.to_json(&headers.host, &headers.user.uuid, &conn))) } #[post("/ciphers/<uuid>/attachment", format = "multipart/form-data", data = "<data>")] @@ -648,7 +657,7 @@ fn post_attachment( if !cipher.is_write_accessible_to_user(&headers.user.uuid, &conn) { err_discard!("Cipher is not write accessible", data) } - + let mut params = content_type.params(); let boundary_pair = params.next().expect("No boundary provided"); let boundary = boundary_pair.1; diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs @@ -146,10 +146,10 @@ fn hibp_breach(username: String) -> JsonResult { username ); - use reqwest::{header::USER_AGENT, Client}; + use reqwest::{header::USER_AGENT, blocking::Client}; if let Some(api_key) = crate::CONFIG.hibp_api_key() { - let hibp_client = Client::builder().use_sys_proxy().build()?; + let hibp_client = Client::builder().build()?; let res = hibp_client .get(&url) @@ -172,7 +172,7 @@ fn hibp_breach(username: String) -> JsonResult { "BreachDate": "2019-08-18T00:00:00Z", "AddedDate": "2019-08-18T00:00:00Z", "Description": format!("Go to: <a href=\"https://haveibeenpwned.com/account/{account}\" target=\"_blank\" rel=\"noopener\">https://haveibeenpwned.com/account/{account}</a> for a manual check.<br/><br/>HaveIBeenPwned API key not set!<br/>Go to <a href=\"https://haveibeenpwned.com/API/Key\" target=\"_blank\" rel=\"noopener\">https://haveibeenpwned.com/API/Key</a> to purchase an API key from HaveIBeenPwned.<br/><br/>", account=username), - "LogoPath": "/bwrs_static/hibp.png", + "LogoPath": "bwrs_static/hibp.png", "PwnCount": 0, "DataClasses": [ "Error - No API key set!" diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs @@ -2,6 +2,7 @@ use rocket::request::Form; use rocket::Route; use rocket_contrib::json::Json; use serde_json::Value; +use num_traits::FromPrimitive; use crate::api::{ EmptyResult, JsonResult, JsonUpcase, JsonUpcaseVec, Notify, NumberOrString, PasswordData, UpdateType, @@ -45,6 +46,9 @@ pub fn routes() -> Vec<Route> { delete_user, post_delete_user, post_org_import, + list_policies, + get_policy, + put_policy, ] } @@ -830,22 +834,13 @@ struct RelationsData { fn post_org_import( query: Form<OrgIdData>, data: JsonUpcase<ImportData>, - headers: Headers, + headers: AdminHeaders, conn: DbConn, nt: Notify, ) -> EmptyResult { let data: ImportData = data.into_inner().data; let org_id = query.into_inner().organization_id; - let org_user = match UserOrganization::find_by_user_and_org(&headers.user.uuid, &org_id, &conn) { - Some(user) => user, - None => err!("User is not part of the organization"), - }; - - if org_user.atype < UserOrgType::Admin { - err!("Only admins or owners can import into an organization") - } - // Read and create the collections let collections: Vec<_> = data .Collections @@ -866,6 +861,8 @@ fn post_org_import( relations.push((relation.Key, relation.Value)); } + let headers: Headers = headers.into(); + // Read and create the ciphers let ciphers: Vec<_> = data .Ciphers @@ -901,3 +898,59 @@ fn post_org_import( let mut user = headers.user; user.update_revision(&conn) } + +#[get("/organizations/<org_id>/policies")] +fn list_policies(org_id: String, _headers: AdminHeaders, conn: DbConn) -> JsonResult { + let policies = OrgPolicy::find_by_org(&org_id, &conn); + let policies_json: Vec<Value> = policies.iter().map(OrgPolicy::to_json).collect(); + + Ok(Json(json!({ + "Data": policies_json, + "Object": "list", + "ContinuationToken": null + }))) +} + +#[get("/organizations/<org_id>/policies/<pol_type>")] +fn get_policy(org_id: String, pol_type: i32, _headers: AdminHeaders, conn: DbConn) -> JsonResult { + let pol_type_enum = match OrgPolicyType::from_i32(pol_type) { + Some(pt) => pt, + None => err!("Invalid policy type"), + }; + + let policy = match OrgPolicy::find_by_org_and_type(&org_id, pol_type, &conn) { + Some(p) => p, + None => OrgPolicy::new(org_id, pol_type_enum, "{}".to_string()), + }; + + Ok(Json(policy.to_json())) +} + +#[derive(Deserialize)] +struct PolicyData { + enabled: bool, + #[serde(rename = "type")] + _type: i32, + data: Value, +} + +#[put("/organizations/<org_id>/policies/<pol_type>", data = "<data>")] +fn put_policy(org_id: String, pol_type: i32, data: Json<PolicyData>, _headers: AdminHeaders, conn: DbConn) -> JsonResult { + let data: PolicyData = data.into_inner(); + + let pol_type_enum = match OrgPolicyType::from_i32(pol_type) { + Some(pt) => pt, + None => err!("Invalid policy type"), + }; + + let mut policy = match OrgPolicy::find_by_org_and_type(&org_id, pol_type, &conn) { + Some(p) => p, + None => OrgPolicy::new(org_id, pol_type_enum, "{}".to_string()), + }; + + policy.enabled = data.enabled; + policy.data = serde_json::to_string(&data.data)?; + policy.save(&conn)?; + + Ok(Json(policy.to_json())) +} +\ No newline at end of file diff --git a/src/api/core/two_factor/duo.rs b/src/api/core/two_factor/duo.rs @@ -187,7 +187,7 @@ fn activate_duo_put(data: JsonUpcase<EnableDuoData>, headers: Headers, conn: DbC fn duo_api_request(method: &str, path: &str, params: &str, data: &DuoData) -> EmptyResult { const AGENT: &str = "bitwarden_rs:Duo/1.0 (Rust)"; - use reqwest::{header::*, Client, Method}; + use reqwest::{header::*, Method, blocking::Client}; use std::str::FromStr; let url = format!("https://{}{}", &data.host, path); diff --git a/src/api/core/two_factor/u2f.rs b/src/api/core/two_factor/u2f.rs @@ -1,3 +1,4 @@ +use once_cell::sync::Lazy; use rocket::Route; use rocket_contrib::json::Json; use serde_json; @@ -18,10 +19,8 @@ use crate::CONFIG; const U2F_VERSION: &str = "U2F_V2"; -lazy_static! { - static ref APP_ID: String = format!("{}/app-id.json", &CONFIG.domain()); - static ref U2F: U2f = U2f::new(APP_ID.clone()); -} +static APP_ID: Lazy<String> = Lazy::new(|| format!("{}/app-id.json", &CONFIG.domain())); +static U2F: Lazy<U2f> = Lazy::new(|| U2f::new(APP_ID.clone())); pub fn routes() -> Vec<Route> { routes![ diff --git a/src/api/icons.rs b/src/api/icons.rs @@ -1,3 +1,4 @@ +use once_cell::sync::Lazy; use std::fs::{create_dir_all, remove_file, symlink_metadata, File}; use std::io::prelude::*; use std::net::ToSocketAddrs; @@ -7,7 +8,7 @@ use rocket::http::ContentType; use rocket::response::Content; use rocket::Route; -use reqwest::{header::HeaderMap, Client, Response, Url}; +use reqwest::{Url, header::HeaderMap, blocking::Client, blocking::Response}; use rocket::http::Cookie; @@ -26,16 +27,14 @@ const FALLBACK_ICON: &[u8; 344] = include_bytes!("../static/fallback-icon.png"); const ALLOWED_CHARS: &str = "_-."; -lazy_static! { +static CLIENT: Lazy<Client> = Lazy::new(|| { // Reuse the client between requests - static ref CLIENT: Client = Client::builder() - .use_sys_proxy() - .gzip(true) + Client::builder() .timeout(Duration::from_secs(CONFIG.icon_download_timeout())) .default_headers(_header_map()) .build() - .unwrap(); -} + .unwrap() +}); fn is_valid_domain(domain: &str) -> bool { // Don't allow empty or too big domains or path traversal diff --git a/src/api/web.rs b/src/api/web.rs @@ -37,7 +37,17 @@ fn app_id() -> Cached<Content<Json<Value>>> { { "version": { "major": 1, "minor": 0 }, "ids": [ - &CONFIG.domain(), + // Per <https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-appid-and-facets-v2.0-id-20180227.html#determining-the-facetid-of-a-calling-application>: + // + // "In the Web case, the FacetID MUST be the Web Origin [RFC6454] + // of the web page triggering the FIDO operation, written as + // a URI with an empty path. Default ports are omitted and any + // path component is ignored." + // + // This leaves it unclear as to whether the path must be empty, + // or whether it can be non-empty and will be ignored. To be on + // the safe side, use a proper web origin (with empty path). + &CONFIG.domain_origin(), "ios:bundle-id:com.8bit.bitwarden", "android:apk-key-hash:dUGFzUzf3lmHSLBDBIv+WaFyZMI" ] }] @@ -75,6 +85,6 @@ fn static_files(filename: String) -> Result<Content<&'static [u8]>, Error> { "bootstrap-native-v4.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/bootstrap-native-v4.js"))), "md5.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/md5.js"))), "identicon.js" => Ok(Content(ContentType::JavaScript, include_bytes!("../static/scripts/identicon.js"))), - _ => err!("Image not found"), + _ => err!(format!("Static file not found: {}", filename)), } } diff --git a/src/auth.rs b/src/auth.rs @@ -3,6 +3,8 @@ // use crate::util::read_file; use chrono::{Duration, Utc}; +use once_cell::sync::Lazy; +use num_traits::FromPrimitive; use jsonwebtoken::{self, Algorithm, Header}; use serde::de::DeserializeOwned; @@ -13,23 +15,21 @@ use crate::CONFIG; const JWT_ALGORITHM: Algorithm = Algorithm::RS256; -lazy_static! { - pub static ref DEFAULT_VALIDITY: Duration = Duration::hours(2); - static ref JWT_HEADER: Header = Header::new(JWT_ALGORITHM); - pub static ref JWT_LOGIN_ISSUER: String = format!("{}|login", CONFIG.domain()); - pub static ref JWT_INVITE_ISSUER: String = format!("{}|invite", CONFIG.domain()); - pub static ref JWT_DELETE_ISSUER: String = format!("{}|delete", CONFIG.domain()); - pub static ref JWT_VERIFYEMAIL_ISSUER: String = format!("{}|verifyemail", CONFIG.domain()); - pub static ref JWT_ADMIN_ISSUER: String = format!("{}|admin", CONFIG.domain()); - static ref PRIVATE_RSA_KEY: Vec<u8> = match read_file(&CONFIG.private_rsa_key()) { - Ok(key) => key, - Err(e) => panic!("Error loading private RSA Key.\n Error: {}", e), - }; - static ref PUBLIC_RSA_KEY: Vec<u8> = match read_file(&CONFIG.public_rsa_key()) { - Ok(key) => key, - Err(e) => panic!("Error loading public RSA Key.\n Error: {}", e), - }; -} +pub static DEFAULT_VALIDITY: Lazy<Duration> = Lazy::new(|| Duration::hours(2)); +static JWT_HEADER: Lazy<Header> = Lazy::new(|| Header::new(JWT_ALGORITHM)); +pub static JWT_LOGIN_ISSUER: Lazy<String> = Lazy::new(|| format!("{}|login", CONFIG.domain_origin())); +static JWT_INVITE_ISSUER: Lazy<String> = Lazy::new(|| format!("{}|invite", CONFIG.domain_origin())); +static JWT_DELETE_ISSUER: Lazy<String> = Lazy::new(|| format!("{}|delete", CONFIG.domain_origin())); +static JWT_VERIFYEMAIL_ISSUER: Lazy<String> = Lazy::new(|| format!("{}|verifyemail", CONFIG.domain_origin())); +static JWT_ADMIN_ISSUER: Lazy<String> = Lazy::new(|| format!("{}|admin", CONFIG.domain_origin())); +static PRIVATE_RSA_KEY: Lazy<Vec<u8>> = Lazy::new(|| match read_file(&CONFIG.private_rsa_key()) { + Ok(key) => key, + Err(e) => panic!("Error loading private RSA Key.\n Error: {}", e), +}); +static PUBLIC_RSA_KEY: Lazy<Vec<u8>> = Lazy::new(|| match read_file(&CONFIG.public_rsa_key()) { + Ok(key) => key, + Err(e) => panic!("Error loading public RSA Key.\n Error: {}", e), +}); pub fn encode_jwt<T: Serialize>(claims: &T) -> String { match jsonwebtoken::encode(&JWT_HEADER, claims, &PRIVATE_RSA_KEY) { @@ -386,6 +386,16 @@ impl<'a, 'r> FromRequest<'a, 'r> for AdminHeaders { } } +impl Into<Headers> for AdminHeaders { + fn into(self) -> Headers { + Headers { + host: self.host, + device: self.device, + user: self.user + } + } +} + pub struct OwnerHeaders { pub host: String, pub device: Device, diff --git a/src/config.rs b/src/config.rs @@ -1,19 +1,23 @@ +use once_cell::sync::Lazy; use std::process::exit; use std::sync::RwLock; +use reqwest::Url; + use crate::error::Error; use crate::util::{get_env, get_env_bool}; -lazy_static! { - pub static ref CONFIG: Config = Config::load().unwrap_or_else(|e| { +static CONFIG_FILE: Lazy<String> = Lazy::new(|| { + let data_folder = get_env("DATA_FOLDER").unwrap_or_else(|| String::from("data")); + get_env("CONFIG_FILE").unwrap_or_else(|| format!("{}/config.json", data_folder)) +}); + +pub static CONFIG: Lazy<Config> = Lazy::new(|| { + Config::load().unwrap_or_else(|e| { println!("Error loading config:\n\t{:?}\n", e); exit(12) - }); - pub static ref CONFIG_FILE: String = { - let data_folder = get_env("DATA_FOLDER").unwrap_or_else(|| String::from("data")); - get_env("CONFIG_FILE").unwrap_or_else(|| format!("{}/config.json", data_folder)) - }; -} + }) +}); pub type Pass = String; @@ -52,7 +56,7 @@ macro_rules! make_config { $($( builder.$name = make_config! { @getenv &stringify!($name).to_uppercase(), $ty }; )+)+ - + builder } @@ -240,6 +244,10 @@ make_config! { domain: String, true, def, "http://localhost".to_string(); /// Domain Set |> Indicates if the domain is set by the admin. Otherwise the default will be used. domain_set: bool, false, def, false; + /// Domain origin |> Domain URL origin (in https://example.com:8443/path, https://example.com:8443 is the origin) + domain_origin: String, false, auto, |c| extract_url_origin(&c.domain); + /// Domain path |> Domain URL path (in https://example.com:8443/path, /path is the path) + domain_path: String, false, auto, |c| extract_url_path(&c.domain); /// Enable web vault web_vault_enabled: bool, false, def, true; @@ -415,6 +423,11 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> { err!("`DATABASE_URL` should start with postgresql: when using the PostgreSQL server") } + let dom = cfg.domain.to_lowercase(); + if !dom.starts_with("http://") && !dom.starts_with("https://") { + err!("DOMAIN variable needs to contain the protocol (http, https). Use 'http[s]://bw.example.com' instead of 'bw.example.com'"); + } + if let Some(ref token) = cfg.admin_token { if token.trim().is_empty() && !cfg.disable_admin_token { err!("`ADMIN_TOKEN` is enabled but has an empty value. To enable the admin page without token, use `DISABLE_ADMIN_TOKEN`") @@ -457,6 +470,29 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> { Ok(()) } +/// Extracts an RFC 6454 web origin from a URL. +fn extract_url_origin(url: &str) -> String { + match Url::parse(url) { + Ok(u) => u.origin().ascii_serialization(), + Err(e) => { + println!("Error validating domain: {}", e); + String::new() + } + } +} + +/// Extracts the path from a URL. +/// All trailing '/' chars are trimmed, even if the path is a lone '/'. +fn extract_url_path(url: &str) -> String { + match Url::parse(url) { + Ok(u) => u.path().trim_end_matches('/').to_string(), + Err(_) => { + // We already print it in the method above, no need to do it again + String::new() + } + } +} + impl Config { pub fn load() -> Result<Self, Error> { // Loading from env and file @@ -521,7 +557,7 @@ impl Config { warn!("Failed to parse email address '{}'", email); return false; } - + // Allow signups if the whitelist is empty/not configured // (it doesn't contain any domains), or if it matches at least // one domain. @@ -634,6 +670,7 @@ where reg!("email/verify_email", ".html"); reg!("email/welcome", ".html"); reg!("email/welcome_must_verify", ".html"); + reg!("email/smtp_test", ".html"); reg!("admin/base"); reg!("admin/login"); diff --git a/src/db/models/mod.rs b/src/db/models/mod.rs @@ -7,6 +7,7 @@ mod user; mod collection; mod organization; mod two_factor; +mod org_policy; pub use self::attachment::Attachment; pub use self::cipher::Cipher; @@ -17,3 +18,4 @@ pub use self::organization::Organization; pub use self::organization::{UserOrgStatus, UserOrgType, UserOrganization}; pub use self::two_factor::{TwoFactor, TwoFactorType}; pub use self::user::{Invitation, User}; +pub use self::org_policy::{OrgPolicy, OrgPolicyType}; +\ No newline at end of file diff --git a/src/db/models/org_policy.rs b/src/db/models/org_policy.rs @@ -0,0 +1,142 @@ +use diesel; +use diesel::prelude::*; +use serde_json::Value; + +use crate::api::EmptyResult; +use crate::db::schema::org_policies; +use crate::db::DbConn; +use crate::error::MapResult; + +use super::Organization; + +#[derive(Debug, Identifiable, Queryable, Insertable, Associations, AsChangeset)] +#[table_name = "org_policies"] +#[belongs_to(Organization, foreign_key = "org_uuid")] +#[primary_key(uuid)] +pub struct OrgPolicy { + pub uuid: String, + pub org_uuid: String, + pub atype: i32, + pub enabled: bool, + pub data: String, +} + +#[allow(dead_code)] +#[derive(FromPrimitive)] +pub enum OrgPolicyType { + TwoFactorAuthentication = 0, + MasterPassword = 1, + PasswordGenerator = 2, +} + +/// Local methods +impl OrgPolicy { + pub fn new(org_uuid: String, atype: OrgPolicyType, data: String) -> Self { + Self { + uuid: crate::util::get_uuid(), + org_uuid, + atype: atype as i32, + enabled: false, + data, + } + } + + pub fn to_json(&self) -> Value { + let data_json: Value = serde_json::from_str(&self.data).unwrap_or(Value::Null); + json!({ + "Id": self.uuid, + "OrganizationId": self.org_uuid, + "Type": self.atype, + "Data": data_json, + "Enabled": self.enabled, + "Object": "policy", + }) + } +} + +/// Database methods +impl OrgPolicy { + #[cfg(feature = "postgresql")] + pub fn save(&self, conn: &DbConn) -> EmptyResult { + // We need to make sure we're not going to violate the unique constraint on org_uuid and atype. + // This happens automatically on other DBMS backends due to replace_into(). PostgreSQL does + // not support multiple constraints on ON CONFLICT clauses. + diesel::delete( + org_policies::table + .filter(org_policies::org_uuid.eq(&self.org_uuid)) + .filter(org_policies::atype.eq(&self.atype)), + ) + .execute(&**conn) + .map_res("Error deleting org_policy for insert")?; + + diesel::insert_into(org_policies::table) + .values(self) + .on_conflict(org_policies::uuid) + .do_update() + .set(self) + .execute(&**conn) + .map_res("Error saving org_policy") + } + + #[cfg(not(feature = "postgresql"))] + pub fn save(&self, conn: &DbConn) -> EmptyResult { + diesel::replace_into(org_policies::table) + .values(&*self) + .execute(&**conn) + .map_res("Error saving org_policy") + } + + pub fn delete(self, conn: &DbConn) -> EmptyResult { + diesel::delete(org_policies::table.filter(org_policies::uuid.eq(self.uuid))) + .execute(&**conn) + .map_res("Error deleting org_policy") + } + + pub fn find_by_uuid(uuid: &str, conn: &DbConn) -> Option<Self> { + org_policies::table + .filter(org_policies::uuid.eq(uuid)) + .first::<Self>(&**conn) + .ok() + } + + pub fn find_by_org(org_uuid: &str, conn: &DbConn) -> Vec<Self> { + org_policies::table + .filter(org_policies::org_uuid.eq(org_uuid)) + .load::<Self>(&**conn) + .expect("Error loading org_policy") + } + + pub fn find_by_user(user_uuid: &str, conn: &DbConn) -> Vec<Self> { + use crate::db::schema::users_organizations; + + org_policies::table + .left_join( + users_organizations::table.on( + users_organizations::org_uuid.eq(org_policies::org_uuid) + .and(users_organizations::user_uuid.eq(user_uuid))) + ) + .select(org_policies::all_columns) + .load::<Self>(&**conn) + .expect("Error loading org_policy") + } + + pub fn find_by_org_and_type(org_uuid: &str, atype: i32, conn: &DbConn) -> Option<Self> { + org_policies::table + .filter(org_policies::org_uuid.eq(org_uuid)) + .filter(org_policies::atype.eq(atype)) + .first::<Self>(&**conn) + .ok() + } + + pub fn delete_all_by_organization(org_uuid: &str, conn: &DbConn) -> EmptyResult { + diesel::delete(org_policies::table.filter(org_policies::org_uuid.eq(org_uuid))) + .execute(&**conn) + .map_res("Error deleting org_policy") + } + + /*pub fn delete_all_by_user(user_uuid: &str, conn: &DbConn) -> EmptyResult { + diesel::delete(twofactor::table.filter(twofactor::user_uuid.eq(user_uuid))) + .execute(&**conn) + .map_res("Error deleting twofactors") + }*/ +} diff --git a/src/db/models/organization.rs b/src/db/models/organization.rs @@ -1,7 +1,8 @@ use serde_json::Value; use std::cmp::Ordering; +use num_traits::FromPrimitive; -use super::{CollectionUser, User}; +use super::{CollectionUser, User, OrgPolicy}; #[derive(Debug, Identifiable, Queryable, Insertable, AsChangeset)] #[table_name = "organizations"] @@ -33,6 +34,7 @@ pub enum UserOrgStatus { } #[derive(Copy, Clone, PartialEq, Eq)] +#[derive(FromPrimitive)] pub enum UserOrgType { Owner = 0, Admin = 1, @@ -135,16 +137,6 @@ impl UserOrgType { _ => None, } } - - pub fn from_i32(i: i32) -> Option<Self> { - match i { - 0 => Some(UserOrgType::Owner), - 1 => Some(UserOrgType::Admin), - 2 => Some(UserOrgType::User), - 3 => Some(UserOrgType::Manager), - _ => None, - } - } } /// Local methods @@ -170,6 +162,7 @@ impl Organization { "UseEvents": false, "UseGroups": false, "UseTotp": true, + "UsePolicies": true, "BusinessName": null, "BusinessAddress1": null, @@ -250,6 +243,7 @@ impl Organization { Cipher::delete_all_by_organization(&self.uuid, &conn)?; Collection::delete_all_by_organization(&self.uuid, &conn)?; UserOrganization::delete_all_by_organization(&self.uuid, &conn)?; + OrgPolicy::delete_all_by_organization(&self.uuid, &conn)?; diesel::delete(organizations::table.filter(organizations::uuid.eq(self.uuid))) .execute(&**conn) @@ -267,7 +261,7 @@ impl Organization { impl UserOrganization { pub fn to_json(&self, conn: &DbConn) -> Value { let org = Organization::find_by_uuid(&self.org_uuid, conn).unwrap(); - + json!({ "Id": self.org_uuid, "Name": org.name, @@ -280,6 +274,7 @@ impl UserOrganization { "UseEvents": false, "UseGroups": false, "UseTotp": true, + "UsePolicies": true, "MaxStorageGb": 10, // The value doesn't matter, we don't check server-side diff --git a/src/db/schemas/mysql/schema.rs b/src/db/schemas/mysql/schema.rs @@ -78,6 +78,16 @@ table! { } table! { + org_policies (uuid) { + uuid -> Varchar, + org_uuid -> Varchar, + atype -> Integer, + enabled -> Bool, + data -> Text, + } +} + +table! { organizations (uuid) { uuid -> Varchar, name -> Text, @@ -155,6 +165,7 @@ joinable!(devices -> users (user_uuid)); joinable!(folders -> users (user_uuid)); joinable!(folders_ciphers -> ciphers (cipher_uuid)); joinable!(folders_ciphers -> folders (folder_uuid)); +joinable!(org_policies -> organizations (org_uuid)); joinable!(twofactor -> users (user_uuid)); joinable!(users_collections -> collections (collection_uuid)); joinable!(users_collections -> users (user_uuid)); @@ -170,6 +181,7 @@ allow_tables_to_appear_in_same_query!( folders, folders_ciphers, invitations, + org_policies, organizations, twofactor, users, diff --git a/src/db/schemas/postgresql/schema.rs b/src/db/schemas/postgresql/schema.rs @@ -78,6 +78,16 @@ table! { } table! { + org_policies (uuid) { + uuid -> Text, + org_uuid -> Text, + atype -> Integer, + enabled -> Bool, + data -> Text, + } +} + +table! { organizations (uuid) { uuid -> Text, name -> Text, @@ -155,6 +165,7 @@ joinable!(devices -> users (user_uuid)); joinable!(folders -> users (user_uuid)); joinable!(folders_ciphers -> ciphers (cipher_uuid)); joinable!(folders_ciphers -> folders (folder_uuid)); +joinable!(org_policies -> organizations (org_uuid)); joinable!(twofactor -> users (user_uuid)); joinable!(users_collections -> collections (collection_uuid)); joinable!(users_collections -> users (user_uuid)); @@ -170,6 +181,7 @@ allow_tables_to_appear_in_same_query!( folders, folders_ciphers, invitations, + org_policies, organizations, twofactor, users, diff --git a/src/db/schemas/sqlite/schema.rs b/src/db/schemas/sqlite/schema.rs @@ -78,6 +78,16 @@ table! { } table! { + org_policies (uuid) { + uuid -> Text, + org_uuid -> Text, + atype -> Integer, + enabled -> Bool, + data -> Text, + } +} + +table! { organizations (uuid) { uuid -> Text, name -> Text, @@ -155,6 +165,7 @@ joinable!(devices -> users (user_uuid)); joinable!(folders -> users (user_uuid)); joinable!(folders_ciphers -> ciphers (cipher_uuid)); joinable!(folders_ciphers -> folders (folder_uuid)); +joinable!(org_policies -> organizations (org_uuid)); joinable!(twofactor -> users (user_uuid)); joinable!(users_collections -> collections (collection_uuid)); joinable!(users_collections -> users (user_uuid)); @@ -170,6 +181,7 @@ allow_tables_to_appear_in_same_query!( folders, folders_ciphers, invitations, + org_policies, organizations, twofactor, users, diff --git a/src/mail.rs b/src/mail.rs @@ -18,21 +18,21 @@ use chrono::NaiveDateTime; fn mailer() -> SmtpTransport { let host = CONFIG.smtp_host().unwrap(); - let client_security = if CONFIG.smtp_ssl() { - let tls = TlsConnector::builder() - .min_protocol_version(Some(Protocol::Tlsv11)) - .build() - .unwrap(); + let tls = TlsConnector::builder() + .min_protocol_version(Some(Protocol::Tlsv11)) + .build() + .unwrap(); - let params = ClientTlsParameters::new(host.clone(), tls); + let tls_params = ClientTlsParameters::new(host.clone(), tls); + let client_security = if CONFIG.smtp_ssl() { if CONFIG.smtp_explicit_tls() { - ClientSecurity::Wrapper(params) + ClientSecurity::Wrapper(tls_params) } else { - ClientSecurity::Required(params) + ClientSecurity::Required(tls_params) } } else { - ClientSecurity::None + ClientSecurity::Opportunistic(tls_params) }; use std::time::Duration; @@ -44,10 +44,11 @@ fn mailer() -> SmtpTransport { _ => smtp_client, }; - let smtp_client = match &CONFIG.smtp_auth_mechanism() { - Some(auth_mechanism_json) => { - let auth_mechanism = serde_json::from_str::<SmtpAuthMechanism>(&auth_mechanism_json); - match auth_mechanism { + let smtp_client = match CONFIG.smtp_auth_mechanism() { + Some(mechanism) => { + let correct_mechanism = format!("\"{}\"", crate::util::upcase_first(&mechanism.trim_matches('"'))); + + match serde_json::from_str::<SmtpAuthMechanism>(&correct_mechanism) { Ok(auth_mechanism) => smtp_client.authentication_mechanism(auth_mechanism), _ => panic!("Failure to parse mechanism. Is it proper Json? Eg. `\"Plain\"` not `Plain`"), } @@ -258,6 +259,17 @@ pub fn send_change_email(address: &str, token: &str) -> EmptyResult { send_email(&address, &subject, &body_html, &body_text) } +pub fn send_test(address: &str) -> EmptyResult { + let (subject, body_html, body_text) = get_text( + "email/smtp_test", + json!({ + "url": CONFIG.domain(), + }), + )?; + + send_email(&address, &subject, &body_html, &body_text) +} + fn send_email(address: &str, subject: &str, body_html: &str, body_text: &str) -> EmptyResult { let address_split: Vec<&str> = address.rsplitn(2, '@').collect(); if address_split.len() != 2 { diff --git a/src/main.rs b/src/main.rs @@ -16,8 +16,6 @@ extern crate diesel; #[macro_use] extern crate diesel_migrations; #[macro_use] -extern crate lazy_static; -#[macro_use] extern crate derive_more; #[macro_use] extern crate num_derive; @@ -43,7 +41,18 @@ mod util; pub use config::CONFIG; pub use error::{Error, MapResult}; +use structopt::StructOpt; + +#[derive(Debug, StructOpt)] +#[structopt(name = "bitwarden_rs", about = "A Bitwarden API server written in Rust")] +struct Opt { + /// Prints the app version + #[structopt(short, long)] + version: bool, +} + fn main() { + parse_args(); launch_info(); use log::LevelFilter as LF; @@ -65,6 +74,18 @@ fn main() { launch_rocket(extra_debug); } +fn parse_args() { + let opt = Opt::from_args(); + if opt.version { + if let Some(version) = option_env!("GIT_VERSION") { + println!("bitwarden_rs {}", version); + } else { + println!("bitwarden_rs (Version info from Git not present)"); + } + exit(0); + } +} + fn launch_info() { println!("/--------------------------------------------------------------------\\"); println!("| Starting Bitwarden_RS |"); @@ -183,7 +204,9 @@ fn check_rsa_keys() { info!("JWT keys don't exist, checking if OpenSSL is available..."); Command::new("openssl").arg("version").status().unwrap_or_else(|_| { - info!("Can't create keys because OpenSSL is not available, make sure it's installed and available on the PATH"); + info!( + "Can't create keys because OpenSSL is not available, make sure it's installed and available on the PATH" + ); exit(1); }); @@ -261,18 +284,20 @@ mod migrations { } fn launch_rocket(extra_debug: bool) { - // Create Rocket object, this stores current log level and sets it's own + // Create Rocket object, this stores current log level and sets its own let rocket = rocket::ignite(); - // If addding more base paths here, consider also adding them to + let basepath = &CONFIG.domain_path(); + + // If adding more paths here, consider also adding them to // crate::utils::LOGGED_ROUTES to make sure they appear in the log let rocket = rocket - .mount("/", api::web_routes()) - .mount("/api", api::core_routes()) - .mount("/admin", api::admin_routes()) - .mount("/identity", api::identity_routes()) - .mount("/icons", api::icons_routes()) - .mount("/notifications", api::notifications_routes()) + .mount(&[basepath, "/"].concat(), api::web_routes()) + .mount(&[basepath, "/api"].concat(), api::core_routes()) + .mount(&[basepath, "/admin"].concat(), api::admin_routes()) + .mount(&[basepath, "/identity"].concat(), api::identity_routes()) + .mount(&[basepath, "/icons"].concat(), api::icons_routes()) + .mount(&[basepath, "/notifications"].concat(), api::notifications_routes()) .manage(db::init_pool()) .manage(api::start_notification_server()) .attach(util::AppHeaders()) diff --git a/src/static/global_domains.json b/src/static/global_domains.json @@ -775,5 +775,71 @@ "customercontrolpanel.de" ], "Excluded": false + }, + { + "Type": 76, + "Domains": [ + "docusign.com", + "docusign.net" + ], + "Excluded": false + }, + { + "Type": 77, + "Domains": [ + "envato.com", + "themeforest.net", + "codecanyon.net", + "videohive.net", + "audiojungle.net", + "graphicriver.net", + "photodune.net", + "3docean.net" + ], + "Excluded": false + }, + { + "Type": 78, + "Domains": [ + "x10hosting.com", + "x10premium.com" + ], + "Excluded": false + }, + { + "Type": 79, + "Domains": [ + "dnsomatic.com", + "opendns.com", + "umbrella.com" + ], + "Excluded": false + }, + { + "Type": 80, + "Domains": [ + "cagreatamerica.com", + "canadaswonderland.com", + "carowinds.com", + "cedarfair.com", + "cedarpoint.com", + "dorneypark.com", + "kingsdominion.com", + "knotts.com", + "miadventure.com", + "schlitterbahn.com", + "valleyfair.com", + "visitkingsisland.com", + "worldsoffun.com" + ], + "Excluded": false + }, + { + "Type": 81, + "Domains": [ + "ubnt.com", + "ui.com" + ], + "Excluded": false } ] diff --git a/src/static/templates/admin/base.hbs b/src/static/templates/admin/base.hbs @@ -6,10 +6,10 @@ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Bitwarden_rs Admin Panel</title> - <link rel="stylesheet" href="/bwrs_static/bootstrap.css" /> - <script src="/bwrs_static/bootstrap-native-v4.js"></script> - <script src="/bwrs_static/md5.js"></script> - <script src="/bwrs_static/identicon.js"></script> + <link rel="stylesheet" href="{{urlpath}}/bwrs_static/bootstrap.css" /> + <script src="{{urlpath}}/bwrs_static/bootstrap-native-v4.js"></script> + <script src="{{urlpath}}/bwrs_static/md5.js"></script> + <script src="{{urlpath}}/bwrs_static/identicon.js"></script> <style> body { padding-top: 70px; @@ -38,10 +38,10 @@ <div class="navbar-collapse"> <ul class="navbar-nav"> <li class="nav-item active"> - <a class="nav-link" href="/admin">Admin Panel</a> + <a class="nav-link" href="{{urlpath}}/admin">Admin Panel</a> </li> <li class="nav-item"> - <a class="nav-link" href="/">Vault</a> + <a class="nav-link" href="{{urlpath}}/">Vault</a> </li> </ul> </div> @@ -55,7 +55,7 @@ {{#if logged_in}} <li class="nav-item"> - <a class="nav-link" href="/admin/logout">Log Out</a> + <a class="nav-link" href="{{urlpath}}/admin/logout">Log Out</a> </li> {{/if}} </ul> @@ -64,4 +64,4 @@ {{> (page_content) }} </body> -</html> -\ No newline at end of file +</html> diff --git a/src/static/templates/admin/page.hbs b/src/static/templates/admin/page.hbs @@ -19,7 +19,7 @@ <span class="d-block">{{Email}}</span> </div> <div class="col"> - <strong> Organizations:</strong> + <strong> Organizations: </strong> <span class="d-block"> {{#each Organizations}} <span class="badge badge-primary" data-orgtype="{{Type}}">{{Name}}</span> @@ -71,6 +71,7 @@ them to avoid confusion. This does not apply to the read-only section, which can only be set through the environment. </div> + <form class="form accordion" id="config-form" onsubmit="saveConfig(); return false;"> {{#each config}} {{#if groupdoc}} @@ -110,6 +111,17 @@ </div> {{/if}} {{/each}} + {{#case group "smtp"}} + <div class="form-group row pt-3 border-top" title="Send a test email to given email address"> + <label for="smtp-test-email" class="col-sm-3 col-form-label">Test SMTP</label> + <div class="col-sm-8 input-group"> + <input class="form-control" id="smtp-test-email" type="email" placeholder="Enter test email"> + <div class="input-group-append"> + <button type="button" class="btn btn-outline-primary" onclick="smtpTest(); return false;">Send test email</button> + </div> + </div> + </div> + {{/case}} </div> </div> {{/if}} @@ -191,7 +203,10 @@ <script> function reload() { window.location.reload(); } - function msg(text) { text && alert(text); reload(); } + function msg(text, reload_page = true) { + text && alert(text); + reload_page && reload(); + } function identicon(email) { const data = new Identicon(md5(email), { size: 48, format: 'svg' }); return "data:image/svg+xml;base64," + data.toString(); @@ -206,26 +221,37 @@ } return false; } - function _post(url, successMsg, errMsg, body) { + function _post(url, successMsg, errMsg, body, reload_page = true) { fetch(url, { method: 'POST', body: body, mode: "same-origin", credentials: "same-origin", headers: { "Content-Type": "application/json" } - }).then(e => { - if (e.ok) { return msg(successMsg); } - e.json().then(json => { - const msg = json ? json.ErrorModel.Message : "Unknown error"; - msg(errMsg + ": " + msg); - }); - }).catch(e => { msg(errMsg + ": Unknown error") }); + }).then( resp => { + if (resp.ok) { msg(successMsg, reload_page); return Promise.reject({error: false}); } + respStatus = resp.status; + respStatusText = resp.statusText; + return resp.text(); + }).then( respText => { + try { + const respJson = JSON.parse(respText); + return respJson ? respJson.ErrorModel.Message : "Unknown error"; + } catch (e) { + return Promise.reject({body:respStatus + ' - ' + respStatusText, error: true}); + } + }).then( apiMsg => { + msg(errMsg + "\n" + apiMsg, reload_page); + }).catch( e => { + if (e.error === false) { return true; } + else { msg(errMsg + "\n" + e.body, reload_page); } + }); } function deleteUser(id, mail) { var input_mail = prompt("To delete user '" + mail + "', please type the email below") if (input_mail != null) { if (input_mail == mail) { - _post("/admin/users/" + id + "/delete", + _post("{{urlpath}}/admin/users/" + id + "/delete", "User deleted correctly", "Error deleting user"); } else { @@ -235,19 +261,19 @@ return false; } function remove2fa(id) { - _post("/admin/users/" + id + "/remove-2fa", + _post("{{urlpath}}/admin/users/" + id + "/remove-2fa", "2FA removed correctly", "Error removing 2FA"); return false; } function deauthUser(id) { - _post("/admin/users/" + id + "/deauth", + _post("{{urlpath}}/admin/users/" + id + "/deauth", "Sessions deauthorized correctly", "Error deauthorizing sessions"); return false; } function updateRevisions() { - _post("/admin/users/update_revision", + _post("{{urlpath}}/admin/users/update_revision", "Success, clients will sync next time they connect", "Error forcing clients to sync"); return false; @@ -256,10 +282,18 @@ inv = document.getElementById("email-invite"); data = JSON.stringify({ "email": inv.value }); inv.value = ""; - _post("/admin/invite/", "User invited correctly", + _post("{{urlpath}}/admin/invite/", "User invited correctly", "Error inviting user", data); return false; } + function smtpTest() { + test_email = document.getElementById("smtp-test-email"); + data = JSON.stringify({ "email": test_email.value }); + _post("{{urlpath}}/admin/test/smtp/", + "SMTP Test email sent correctly", + "Error sending SMTP test email", data, false); + return false; + } function getFormData() { let data = {}; @@ -278,7 +312,7 @@ } function saveConfig() { data = JSON.stringify(getFormData()); - _post("/admin/config/", "Config saved correctly", + _post("{{urlpath}}/admin/config/", "Config saved correctly", "Error saving config", data); return false; } @@ -286,7 +320,7 @@ var input = prompt("This will remove all user configurations, and restore the defaults and the " + "values set by the environment. This operation could be dangerous. Type 'DELETE' to proceed:"); if (input === "DELETE") { - _post("/admin/config/delete", + _post("{{urlpath}}/admin/config/delete", "Config deleted correctly", "Error deleting config"); } else { @@ -296,9 +330,9 @@ return false; } function backupDatabase() { - _post("/admin/config/backup_db", + _post("{{urlpath}}/admin/config/backup_db", "Backup created successfully", - "Error creating backup"); + "Error creating backup", null, false); return false; } function masterCheck(check_id, inputs_query) { @@ -331,9 +365,9 @@ e.title = orgtype.name; }); - // These are formatted because otherwise the + // These are formatted because otherwise the // VSCode formatter breaks But they still work // {{#each config}} {{#if grouptoggle}} masterCheck("input_{{grouptoggle}}", "#g_{{group}} input"); // {{/if}} {{/each}} -</script> -\ No newline at end of file +</script> diff --git a/src/static/templates/email/invite_accepted.hbs b/src/static/templates/email/invite_accepted.hbs @@ -3,6 +3,6 @@ Invitation accepted <html> <p> Your invitation for <b>{{email}}</b> to join <b>{{org_name}}</b> was accepted. - Please <a href="{{url}}">log in</a> to the bitwarden_rs server and confirm them from the organization management page. + Please <a href="{{url}}/">log in</a> to the bitwarden_rs server and confirm them from the organization management page. </p> </html> diff --git a/src/static/templates/email/invite_accepted.html.hbs b/src/static/templates/email/invite_accepted.html.hbs @@ -101,7 +101,7 @@ Invitation accepted </tr> <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> <td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none;" valign="top"> - Please <a href="{{url}}">log in</a> to the bitwarden_rs server and confirm them from the organization management page. + Please <a href="{{url}}/">log in</a> to the bitwarden_rs server and confirm them from the organization management page. </td> </tr> <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> diff --git a/src/static/templates/email/invite_confirmed.hbs b/src/static/templates/email/invite_confirmed.hbs @@ -3,6 +3,6 @@ Invitation to {{org_name}} confirmed <html> <p> Your invitation to join <b>{{org_name}}</b> was confirmed. - It will now appear under the Organizations the next time you <a href="{{url}}">log in</a> to the web vault. + It will now appear under the Organizations the next time you <a href="{{url}}/">log in</a> to the web vault. </p> </html> diff --git a/src/static/templates/email/invite_confirmed.html.hbs b/src/static/templates/email/invite_confirmed.html.hbs @@ -102,7 +102,7 @@ Invitation to {{org_name}} confirmed <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> <td class="content-block last" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0; -webkit-text-size-adjust: none;" valign="top"> Any collections and logins being shared with you by this organization will now appear in your Bitwarden vault. <br> - <a href="{{url}}">Log in</a> + <a href="{{url}}/">Log in</a> </td> </tr> </table> diff --git a/src/static/templates/email/new_device_logged_in.hbs b/src/static/templates/email/new_device_logged_in.hbs @@ -9,6 +9,6 @@ New Device Logged In From {{device}} Device Type: {{device}} You can deauthorize all devices that have access to your account from the - <a href="{{url}}">web vault</a> under Settings > My Account > Deauthorize Sessions. + <a href="{{url}}/">web vault</a> under Settings > My Account > Deauthorize Sessions. </p> </html> diff --git a/src/static/templates/email/new_device_logged_in.html.hbs b/src/static/templates/email/new_device_logged_in.html.hbs @@ -116,7 +116,7 @@ New Device Logged In From {{device}} </tr> <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> <td class="content-block last" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0; -webkit-text-size-adjust: none;" valign="top"> - You can deauthorize all devices that have access to your account from the <a href="{{url}}">web vault</a> under Settings > My Account > Deauthorize Sessions. + You can deauthorize all devices that have access to your account from the <a href="{{url}}/">web vault</a> under Settings > My Account > Deauthorize Sessions. </td> </tr> </table> diff --git a/src/static/templates/email/pw_hint_some.hbs b/src/static/templates/email/pw_hint_some.hbs @@ -3,7 +3,7 @@ Your master password hint You (or someone) recently requested your master password hint. Your hint is: "{{hint}}" -Log in: <a href="{{url}}">Web Vault</a> +Log in: <a href="{{url}}/">Web Vault</a> If you cannot remember your master password, there is no way to recover your data. The only option to gain access to your account again is to <a href="{{url}}/#/recover-delete">delete the account</a> so that you can register again and start over. All data associated with your account will be deleted. diff --git a/src/static/templates/email/pw_hint_some.html.hbs b/src/static/templates/email/pw_hint_some.html.hbs @@ -102,7 +102,7 @@ Your master password hint <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> <td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none;" valign="top"> Your hint is: "{{hint}}"<br style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;" /> - Log in: <a href="{{url}}">Web Vault</a> + Log in: <a href="{{url}}/">Web Vault</a> </td> </tr> <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> diff --git a/src/static/templates/email/smtp_test.hbs b/src/static/templates/email/smtp_test.hbs @@ -0,0 +1,8 @@ +Bitwarden_rs SMTP Test +<!----------------> +<html> +<p> +This is a test email to verify the SMTP configuration for <a href="{{url}}">{{url}}</a>. +</p> +<p>When you can read this email it is probably configured correctly.</p> +</html> diff --git a/src/static/templates/email/smtp_test.html.hbs b/src/static/templates/email/smtp_test.html.hbs @@ -0,0 +1,129 @@ +Bitwarden_rs SMTP Test +<!----------------> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> + <head> + <meta name="viewport" content="width=device-width" /> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <title>Bitwarden_rs</title> + </head> + <body style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; height: 100%; line-height: 25px; width: 100% !important;" bgcolor="#f6f6f6"> + <style type="text/css"> + body { + margin: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + box-sizing: border-box; + font-size: 16px; + color: #333; + line-height: 25px; + -webkit-font-smoothing: antialiased; + -webkit-text-size-adjust: none; + } + body * { + margin: 0; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + box-sizing: border-box; + font-size: 16px; + color: #333; + line-height: 25px; + -webkit-font-smoothing: antialiased; + -webkit-text-size-adjust: none; + } + img { + max-width: 100%; + border: none; + } + body { + -webkit-font-smoothing: antialiased; + -webkit-text-size-adjust: none; + width: 100% !important; + height: 100%; + line-height: 25px; + } + body { + background-color: #f6f6f6; + } + @media only screen and (max-width: 600px) { + body { + padding: 0 !important; + } + .container { + padding: 0 !important; + width: 100% !important; + } + .container-table { + padding: 0 !important; + width: 100% !important; + } + .content { + padding: 0 0 10px 0 !important; + } + .content-wrap { + padding: 10px !important; + } + .invoice { + width: 100% !important; + } + .main { + border-right: none !important; + border-left: none !important; + border-radius: 0 !important; + } + .logo { + padding-top: 10px !important; + } + .footer { + margin-top: 10px !important; + } + .indented { + padding-left: 10px; + } + } + </style> + <table class="body-wrap" cellpadding="0" cellspacing="0" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0; width: 100%;" bgcolor="#f6f6f6"> + <tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> + <td valign="middle" class="aligncenter middle logo" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0; padding: 20px 0 10px;" align="center"> + <img src="{{url}}/bwrs_static/logo-gray.png" alt="" width="250" height="39" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; border: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0; max-width: 100%;" /> + </td> + </tr> + <tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> + <td class="container" align="center" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; clear: both !important; color: #333; display: block !important; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0 auto; max-width: 600px !important; width: 600px;" valign="top"> + <table cellpadding="0" cellspacing="0" class="container-table" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; clear: both !important; color: #333; display: block !important; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0 auto; max-width: 600px !important; width: 600px;"> + <tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> + <td class="content" align="center" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; display: block; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 0; line-height: 0; margin: 0 auto; max-width: 600px; padding-bottom: 20px;" valign="top"> + <table class="main" width="100%" cellpadding="0" cellspacing="0" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; margin: 0; -webkit-text-size-adjust: none; border: 1px solid #e9e9e9; border-radius: 3px;" bgcolor="white"> + <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> + <td class="content-wrap" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 20px; -webkit-text-size-adjust: none;" valign="top"> + <table width="100%" cellpadding="0" cellspacing="0" style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> + <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> + <td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none; text-align: center;" valign="top" align="center"> + This is a test email to verify the SMTP configuration for <a href="{{url}}">{{url}}</a>. + </td> + </tr> + <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> + <td class="content-block last" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0; -webkit-text-size-adjust: none; text-align: center;" valign="top" align="center"> + When you can read this email it is probably configured correctly. + </td> + </tr> + </table> + </td> + </tr> + </table> + <table class="footer" cellpadding="0" cellspacing="0" width="100%" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; clear: both; color: #999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; margin: 0; width: 100%;"> + <tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> + <td class="aligncenter social-icons" align="center" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; margin: 0; padding: 15px 0 0 0;" valign="top"> + <table cellpadding="0" cellspacing="0" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0 auto;"> + <tr style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0;"> + <td style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; margin: 0; padding: 0 10px;" valign="top"><a href="https://github.com/dani-garcia/bitwarden_rs" target="_blank" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; box-sizing: border-box; color: #999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 20px; margin: 0; text-decoration: underline;"><img src="{{url}}/bwrs_static/mail-github.png" alt="GitHub" width="30" height="30" style="-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; border: none; box-sizing: border-box; color: #333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin: 0; max-width: 100%;" /></a></td> + </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> + </table> + </body> +</html> diff --git a/src/static/templates/email/welcome.hbs b/src/static/templates/email/welcome.hbs @@ -2,7 +2,7 @@ Welcome <!----------------> <html> <p> -Thank you for creating an account at <a href="{{url}}">{{url}}</a>. You may now log in with your new account. +Thank you for creating an account at <a href="{{url}}/">{{url}}</a>. You may now log in with your new account. </p> <p>If you did not request to create an account, you can safely ignore this email.</p> </html> diff --git a/src/static/templates/email/welcome.html.hbs b/src/static/templates/email/welcome.html.hbs @@ -96,7 +96,7 @@ Welcome <table width="100%" cellpadding="0" cellspacing="0" style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> <td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none; text-align: center;" valign="top" align="center"> - Thank you for creating an account at <a href="{{url}}">{{url}}</a>. You may now log in with your new account. + Thank you for creating an account at <a href="{{url}}/">{{url}}</a>. You may now log in with your new account. </td> </tr> <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> diff --git a/src/static/templates/email/welcome_must_verify.hbs b/src/static/templates/email/welcome_must_verify.hbs @@ -2,7 +2,7 @@ Welcome <!----------------> <html> <p> -Thank you for creating an account at <a href="{{url}}">{{url}}</a>. Before you can login with your new account, you must verify this email address by clicking the link below. +Thank you for creating an account at <a href="{{url}}/">{{url}}</a>. Before you can login with your new account, you must verify this email address by clicking the link below. <br> <br> <a href="{{url}}/#/verify-email/?userId={{user_id}}&token={{token}}"> diff --git a/src/static/templates/email/welcome_must_verify.html.hbs b/src/static/templates/email/welcome_must_verify.html.hbs @@ -96,7 +96,7 @@ Welcome <table width="100%" cellpadding="0" cellspacing="0" style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> <td class="content-block" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; margin: 0; -webkit-font-smoothing: antialiased; padding: 0 0 10px; -webkit-text-size-adjust: none; text-align: center;" valign="top" align="center"> - Thank you for creating an account at <a href="{{url}}">{{url}}</a>. Before you can login with your new account, you must verify this email address by clicking the link below. + Thank you for creating an account at <a href="{{url}}/">{{url}}</a>. Before you can login with your new account, you must verify this email address by clicking the link below. </td> </tr> <tr style="margin: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; color: #333; line-height: 25px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none;"> diff --git a/src/util.rs b/src/util.rs @@ -109,7 +109,7 @@ impl<'r, R: Responder<'r>> Responder<'r> for Cached<R> { } } -// Log all the routes from the main base paths list, and the attachments endoint +// Log all the routes from the main paths list, and the attachments endpoint // Effectively ignores, any static file route, and the alive endpoint const LOGGED_ROUTES: [&str; 6] = [ "/api", @@ -157,7 +157,10 @@ impl Fairing for BetterLogging { } let uri = request.uri(); let uri_path = uri.path(); - if self.0 || LOGGED_ROUTES.iter().any(|r| uri_path.starts_with(r)) { + // FIXME: trim_start_matches() could result in over-trimming in pathological cases; + // strip_prefix() would be a better option once it's stable. + let uri_subpath = uri_path.trim_start_matches(&CONFIG.domain_path()); + if self.0 || LOGGED_ROUTES.iter().any(|r| uri_subpath.starts_with(r)) { match uri.query() { Some(q) => info!(target: "request", "{} {}?{}", method, uri_path, &q[..q.len().min(30)]), None => info!(target: "request", "{} {}", method, uri_path), @@ -169,8 +172,10 @@ impl Fairing for BetterLogging { if !self.0 && request.method() == Method::Options { return; } - let uri_path = request.uri().path(); - if self.0 || LOGGED_ROUTES.iter().any(|r| uri_path.starts_with(r)) { + // FIXME: trim_start_matches() could result in over-trimming in pathological cases; + // strip_prefix() would be a better option once it's stable. + let uri_subpath = request.uri().path().trim_start_matches(&CONFIG.domain_path()); + if self.0 || LOGGED_ROUTES.iter().any(|r| uri_subpath.starts_with(r)) { let status = response.status(); if let Some(ref route) = request.route() { info!(target: "response", "{} => {} {}", route, status.code, status.reason)