Added authentication support
This commit is contained in:
parent
3389406a10
commit
09af394709
7 changed files with 657 additions and 60 deletions
514
Cargo.lock
generated
514
Cargo.lock
generated
|
@ -2,24 +2,54 @@
|
|||
name = "polaris"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"id3 0.1.10 (git+https://github.com/jameshurst/rust-id3)",
|
||||
"iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mount 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"router 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"oven 1.0.0 (git+https://github.com/agersant/oven?branch=remove_cookie_dep)",
|
||||
"params 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"router 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"staticfile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"toml 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 1.2.0 (git+https://github.com/servo/rust-url)",
|
||||
"toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.5.2"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bodyparser"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"persistent 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "buf_redux"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "conduit-mime-types"
|
||||
version = "0.7.3"
|
||||
|
@ -33,10 +63,83 @@ name = "cookie"
|
|||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "encoding"
|
||||
version = "0.2.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding-index-japanese"
|
||||
version = "1.20141219.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding-index-korean"
|
||||
version = "1.20141219.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding-index-simpchinese"
|
||||
version = "1.20141219.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding-index-singlebyte"
|
||||
version = "1.20141219.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding-index-tradchinese"
|
||||
version = "1.20141219.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_index_tests"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error"
|
||||
version = "0.1.9"
|
||||
|
@ -46,6 +149,29 @@ dependencies = [
|
|||
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gcc"
|
||||
version = "0.3.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "gdi32-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hpack"
|
||||
version = "0.2.0"
|
||||
|
@ -59,6 +185,27 @@ name = "httparse"
|
|||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"httparse 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.9.10"
|
||||
|
@ -70,6 +217,8 @@ dependencies = [
|
|||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-verify 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -80,13 +229,17 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-url#ed1395ec242c7fc929a7821698b901ad174d90a5"
|
||||
name = "id3"
|
||||
version = "0.1.10"
|
||||
source = "git+https://github.com/jameshurst/rust-id3#4220b2d2a87c33890c4328996048bb3df910577d"
|
||||
dependencies = [
|
||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -116,6 +269,11 @@ dependencies = [
|
|||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
|
@ -136,10 +294,23 @@ version = "0.1.16"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.15"
|
||||
name = "lazy_static"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libressl-pnacl-sys"
|
||||
version = "2.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.3.6"
|
||||
|
@ -155,7 +326,7 @@ name = "memchr"
|
|||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -166,6 +337,26 @@ dependencies = [
|
|||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz-sys"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "modifier"
|
||||
version = "0.1.0"
|
||||
|
@ -180,14 +371,211 @@ dependencies = [
|
|||
"sequence_trie 0.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multipart"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"buf_redux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-complex 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-rational 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.7.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.7.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys-extras 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.7.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys-extras"
|
||||
version = "0.7.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.7.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-verify"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oven"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/agersant/oven?branch=remove_cookie_dep#d28c36ea30bb7cfd921fc5cea46d9a0047235fb2"
|
||||
dependencies = [
|
||||
"hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "params"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bodyparser 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"multipart 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"urlencoded 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "persistent"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.7.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"phf_shared 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_codegen"
|
||||
version = "0.7.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"phf_generator 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_shared 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.7.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"phf_shared 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.7.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "plugin"
|
||||
version = "0.2.6"
|
||||
|
@ -197,20 +585,36 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.73"
|
||||
name = "pnacl-build-helper"
|
||||
version = "1.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -220,11 +624,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "router"
|
||||
version = "0.2.0"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"route-recognizer 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -250,6 +655,22 @@ name = "sequence_trie"
|
|||
version = "0.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solicit"
|
||||
version = "0.4.4"
|
||||
|
@ -271,13 +692,21 @@ dependencies = [
|
|||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempdir"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread-id"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -294,13 +723,13 @@ version = "0.1.35"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -360,11 +789,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "1.2.0"
|
||||
source = "git+https://github.com/servo/rust-url#ed1395ec242c7fc929a7821698b901ad174d90a5"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"idna 0.1.0 (git+https://github.com/servo/rust-url)",
|
||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -376,11 +808,39 @@ dependencies = [
|
|||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoded"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bodyparser 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "user32-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8-ranges"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
|
|
18
Cargo.toml
18
Cargo.toml
|
@ -3,17 +3,15 @@ name = "polaris"
|
|||
version = "0.1.0"
|
||||
authors = ["Antoine Gersant <antoine.gersant@lesforges.org>"]
|
||||
|
||||
[dependencies.iron]
|
||||
version = "0.4.0"
|
||||
|
||||
[dependencies.url]
|
||||
git = "https://github.com/servo/rust-url"
|
||||
|
||||
[dependencies]
|
||||
id3 = { git = "https://github.com/jameshurst/rust-id3" }
|
||||
mount = "*"
|
||||
iron = "0.4.0"
|
||||
mount = "0.2.1"
|
||||
oven = { git = "https://github.com/agersant/oven", branch = "remove_cookie_dep" }
|
||||
params = "0.3.1"
|
||||
regex = "0.1"
|
||||
router = "*"
|
||||
router = "0.4.0"
|
||||
rustc-serialize = "0.3"
|
||||
staticfile = "*"
|
||||
toml = "0.2"
|
||||
staticfile = "0.3.0"
|
||||
toml = "0.2"
|
||||
url = "1.2.0"
|
|
@ -4,3 +4,6 @@ album_art_pattern = '^Folder\.(png|jpg|jpeg)$'
|
|||
name = 'root'
|
||||
source = 'M:/Music/Genres/'
|
||||
|
||||
[[users]]
|
||||
name = 'agersant'
|
||||
password = 'test'
|
92
src/api.rs
92
src/api.rs
|
@ -8,8 +8,11 @@ use std::sync::Arc;
|
|||
use std::sync::Mutex;
|
||||
|
||||
use iron::prelude::*;
|
||||
use iron::status;
|
||||
use iron::headers::CookiePair;
|
||||
use iron::{BeforeMiddleware, status};
|
||||
use mount::Mount;
|
||||
use oven::prelude::*;
|
||||
use params;
|
||||
use rustc_serialize::json;
|
||||
use url::percent_encoding::percent_decode;
|
||||
|
||||
|
@ -28,39 +31,59 @@ impl From<PError> for IronError {
|
|||
PError::ConfigFileReadError => IronError::new(err, status::InternalServerError),
|
||||
PError::ConfigFileParseError => IronError::new(err, status::InternalServerError),
|
||||
PError::ConfigMountDirsParseError => IronError::new(err, status::InternalServerError),
|
||||
PError::ConfigUsersParseError => IronError::new(err, status::InternalServerError),
|
||||
PError::ConfigAlbumArtPatternParseError => {
|
||||
IronError::new(err, status::InternalServerError)
|
||||
}
|
||||
PError::AlbumArtSearchError => IronError::new(err, status::InternalServerError),
|
||||
PError::ID3ParseError => IronError::new(err, status::InternalServerError),
|
||||
PError::Unauthorized => IronError::new(err, status::Unauthorized),
|
||||
PError::IncorrectCredentials => IronError::new(err, status::BadRequest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_api_handler(collection: Arc<Mutex<Collection>>) -> Mount {
|
||||
let mut mount = Mount::new();
|
||||
let mut api_handler = Mount::new();
|
||||
|
||||
{
|
||||
let collection = collection.clone();
|
||||
mount.mount("/browse/", move |request: &mut Request| {
|
||||
let mut acquired_collection = collection.deref().lock().unwrap();
|
||||
self::browse(request, acquired_collection.deref_mut())
|
||||
api_handler.mount("/auth/", move |request: &mut Request| {
|
||||
let acquired_collection = collection.deref().lock().unwrap();
|
||||
self::auth(request, acquired_collection.deref())
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let collection = collection.clone();
|
||||
mount.mount("/flatten/", move |request: &mut Request| {
|
||||
let mut acquired_collection = collection.deref().lock().unwrap();
|
||||
self::flatten(request, acquired_collection.deref_mut())
|
||||
});
|
||||
let mut auth_api_mount = Mount::new();
|
||||
{
|
||||
let collection = collection.clone();
|
||||
auth_api_mount.mount("/browse/", move |request: &mut Request| {
|
||||
let mut acquired_collection = collection.deref().lock().unwrap();
|
||||
self::browse(request, acquired_collection.deref_mut())
|
||||
});
|
||||
}
|
||||
{
|
||||
let collection = collection.clone();
|
||||
auth_api_mount.mount("/flatten/", move |request: &mut Request| {
|
||||
let mut acquired_collection = collection.deref().lock().unwrap();
|
||||
self::flatten(request, acquired_collection.deref_mut())
|
||||
});
|
||||
}
|
||||
{
|
||||
let collection = collection.clone();
|
||||
auth_api_mount.mount("/serve/", move |request: &mut Request| {
|
||||
let mut acquired_collection = collection.deref().lock().unwrap();
|
||||
self::serve(request, acquired_collection.deref_mut())
|
||||
});
|
||||
}
|
||||
|
||||
let mut auth_api_chain = Chain::new(auth_api_mount);
|
||||
auth_api_chain.link_before(AuthRequirement);
|
||||
|
||||
api_handler.mount("/", auth_api_chain);
|
||||
}
|
||||
{
|
||||
let collection = collection.clone();
|
||||
mount.mount("/serve/", move |request: &mut Request| {
|
||||
let mut acquired_collection = collection.deref().lock().unwrap();
|
||||
self::serve(request, acquired_collection.deref_mut())
|
||||
});
|
||||
}
|
||||
mount
|
||||
api_handler
|
||||
}
|
||||
|
||||
fn path_from_request(request: &Request) -> Result<PathBuf, Utf8Error> {
|
||||
|
@ -69,6 +92,39 @@ fn path_from_request(request: &Request) -> Result<PathBuf, Utf8Error> {
|
|||
Ok(PathBuf::from(decoded_path.deref()))
|
||||
}
|
||||
|
||||
struct AuthRequirement;
|
||||
impl BeforeMiddleware for AuthRequirement {
|
||||
fn before(&self, req: &mut Request) -> IronResult<()> {
|
||||
let auth_cookie = req.get_cookie("username");
|
||||
if auth_cookie.is_some() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(IronError::new(PError::Unauthorized, status::Unauthorized))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn auth(request: &mut Request, collection: &Collection) -> IronResult<Response> {
|
||||
let input = request.get_ref::<params::Params>().unwrap();
|
||||
let username = match input.find(&["username"]) {
|
||||
Some(¶ms::Value::String(ref username)) => username,
|
||||
_ => return Err(IronError::from(PError::IncorrectCredentials)),
|
||||
};
|
||||
let password = match input.find(&["password"]) {
|
||||
Some(¶ms::Value::String(ref password)) => password,
|
||||
_ => return Err(IronError::from(PError::IncorrectCredentials)),
|
||||
};
|
||||
if collection.auth(username.as_str(), password.as_str()) {
|
||||
let mut response = Response::with((status::Ok, ""));
|
||||
let mut username_cookie = CookiePair::new("username".to_string(), username.clone());
|
||||
username_cookie.path = Some("/".to_owned());
|
||||
response.set_cookie(username_cookie);
|
||||
Ok(response)
|
||||
} else {
|
||||
Err(IronError::from(PError::IncorrectCredentials))
|
||||
}
|
||||
}
|
||||
|
||||
fn browse(request: &mut Request, collection: &mut Collection) -> IronResult<Response> {
|
||||
let path = path_from_request(request);
|
||||
let path = match path {
|
||||
|
|
|
@ -37,6 +37,12 @@ pub struct SongTags {
|
|||
year: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct User {
|
||||
name: String,
|
||||
password: String,
|
||||
}
|
||||
|
||||
impl Album {
|
||||
fn read(collection: &Collection, real_path: &Path) -> Result<Album, PError> {
|
||||
|
||||
|
@ -188,18 +194,23 @@ pub enum CollectionFile {
|
|||
|
||||
pub struct Collection {
|
||||
vfs: Vfs,
|
||||
users: Vec<User>,
|
||||
album_art_pattern: Regex,
|
||||
}
|
||||
|
||||
const CONFIG_MOUNT_DIRS: &'static str = "mount_dirs";
|
||||
const CONFIG_MOUNT_DIR_NAME: &'static str = "name";
|
||||
const CONFIG_MOUNT_DIR_SOURCE: &'static str = "source";
|
||||
const CONFIG_USERS: &'static str = "users";
|
||||
const CONFIG_USER_NAME: &'static str = "name";
|
||||
const CONFIG_USER_PASSWORD: &'static str = "password";
|
||||
const CONFIG_ALBUM_ART_PATTERN: &'static str = "album_art_pattern";
|
||||
|
||||
impl Collection {
|
||||
pub fn new() -> Collection {
|
||||
Collection {
|
||||
vfs: Vfs::new(),
|
||||
users: Vec::new(),
|
||||
album_art_pattern: Regex::new("^Folder\\.png$").unwrap(),
|
||||
}
|
||||
}
|
||||
|
@ -227,6 +238,7 @@ impl Collection {
|
|||
|
||||
// Apply
|
||||
try!(self.load_config_mount_points(&parsed_config));
|
||||
try!(self.load_config_users(&parsed_config));
|
||||
try!(self.load_config_album_art_pattern(&parsed_config));
|
||||
|
||||
Ok(())
|
||||
|
@ -249,6 +261,46 @@ impl Collection {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn load_config_users(&mut self, config: &toml::Table) -> Result<(), PError> {
|
||||
let users = match config.get(CONFIG_USERS) {
|
||||
Some(s) => s,
|
||||
None => return Ok(()),
|
||||
};
|
||||
|
||||
let users = match users {
|
||||
&toml::Value::Array(ref a) => a,
|
||||
_ => return Err(PError::ConfigUsersParseError),
|
||||
};
|
||||
|
||||
for user in users {
|
||||
let name = match user.lookup(CONFIG_USER_NAME) {
|
||||
None => return Err(PError::ConfigUsersParseError),
|
||||
Some(n) => n,
|
||||
};
|
||||
let name = match name.as_str() {
|
||||
None => return Err(PError::ConfigUsersParseError),
|
||||
Some(n) => n,
|
||||
};
|
||||
|
||||
let password = match user.lookup(CONFIG_USER_PASSWORD) {
|
||||
None => return Err(PError::ConfigUsersParseError),
|
||||
Some(n) => n,
|
||||
};
|
||||
let password = match password.as_str() {
|
||||
None => return Err(PError::ConfigUsersParseError),
|
||||
Some(n) => n,
|
||||
};
|
||||
|
||||
let user = User{
|
||||
name: name.to_owned(),
|
||||
password: password.to_owned(),
|
||||
};
|
||||
self.users.push(user);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn load_config_mount_points(&mut self, config: &toml::Table) -> Result<(), PError> {
|
||||
let mount_dirs = match config.get(CONFIG_MOUNT_DIRS) {
|
||||
Some(s) => s,
|
||||
|
@ -290,6 +342,10 @@ impl Collection {
|
|||
self.vfs.mount(name, real_path)
|
||||
}
|
||||
|
||||
pub fn auth(&self, username: &str, password: &str) -> bool {
|
||||
self.users.iter().any(|u| u.name == username && u.password == password )
|
||||
}
|
||||
|
||||
pub fn browse(&self, path: &Path) -> Result<Vec<CollectionFile>, PError> {
|
||||
|
||||
let mut out = vec![];
|
||||
|
|
11
src/error.rs
11
src/error.rs
|
@ -14,9 +14,12 @@ pub enum PError {
|
|||
ConfigFileReadError,
|
||||
ConfigFileParseError,
|
||||
ConfigMountDirsParseError,
|
||||
ConfigUsersParseError,
|
||||
ConfigAlbumArtPatternParseError,
|
||||
AlbumArtSearchError,
|
||||
ID3ParseError,
|
||||
Unauthorized,
|
||||
IncorrectCredentials,
|
||||
}
|
||||
|
||||
impl From<io::Error> for PError {
|
||||
|
@ -45,11 +48,14 @@ impl error::Error for PError {
|
|||
PError::ConfigFileReadError => "Could not read config file",
|
||||
PError::ConfigFileParseError => "Could not parse config file",
|
||||
PError::ConfigMountDirsParseError => "Could not parse mount directories in config file",
|
||||
PError::ConfigUsersParseError => "Could not parse users in config file",
|
||||
PError::ConfigAlbumArtPatternParseError => {
|
||||
"Could not parse album art pattern in config file"
|
||||
}
|
||||
PError::AlbumArtSearchError => "Error while looking for album art",
|
||||
PError::ID3ParseError => "Error while reading ID3 tag",
|
||||
PError::Unauthorized => "Authentication required",
|
||||
PError::IncorrectCredentials => "Incorrect username/password combination",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +78,9 @@ impl fmt::Display for PError {
|
|||
PError::ConfigFileOpenError => write!(f, "Could not open config file"),
|
||||
PError::ConfigFileReadError => write!(f, "Could not read config file"),
|
||||
PError::ConfigFileParseError => write!(f, "Could not parse config file"),
|
||||
PError::ConfigUsersParseError => {
|
||||
write!(f, "Could not parse users in config file")
|
||||
}
|
||||
PError::ConfigMountDirsParseError => {
|
||||
write!(f, "Could not parse mount directories in config file")
|
||||
}
|
||||
|
@ -80,6 +89,8 @@ impl fmt::Display for PError {
|
|||
}
|
||||
PError::AlbumArtSearchError => write!(f, "Error while looking for album art"),
|
||||
PError::ID3ParseError => write!(f, "Error while reading ID3 tag"),
|
||||
PError::Unauthorized => write!(f, "Authentication required"),
|
||||
PError::IncorrectCredentials => write!(f, "Incorrect username/password combination"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
23
src/main.rs
23
src/main.rs
|
@ -1,6 +1,8 @@
|
|||
extern crate core;
|
||||
extern crate iron;
|
||||
extern crate mount;
|
||||
extern crate oven;
|
||||
extern crate params;
|
||||
extern crate regex;
|
||||
extern crate id3;
|
||||
extern crate rustc_serialize;
|
||||
|
@ -26,14 +28,25 @@ use collection::*;
|
|||
|
||||
fn main() {
|
||||
|
||||
let mut collection = Collection::new();
|
||||
collection.load_config(Path::new("Polaris.toml")).unwrap();
|
||||
|
||||
let collection = Arc::new(Mutex::new(collection));
|
||||
let mut api_chain;
|
||||
{
|
||||
let api_handler;
|
||||
{
|
||||
let mut collection = Collection::new();
|
||||
collection.load_config(Path::new("Polaris.toml")).unwrap();
|
||||
let collection = Arc::new(Mutex::new(collection));
|
||||
api_handler = get_api_handler(collection);
|
||||
}
|
||||
api_chain = Chain::new(api_handler);
|
||||
|
||||
let auth_secret = std::env::var("POLARIS_SECRET").expect("Environment variable POLARIS_SECRET must be set");
|
||||
let cookie_middleware = oven::new(auth_secret.into_bytes());
|
||||
api_chain.link(cookie_middleware);
|
||||
}
|
||||
|
||||
let mut mount = Mount::new();
|
||||
let api_handler = get_api_handler(collection);
|
||||
mount.mount("/api/", api_handler);
|
||||
mount.mount("/api/", api_chain);
|
||||
mount.mount("/", Static::new(Path::new("web")));
|
||||
|
||||
Iron::new(mount).http("localhost:3000").unwrap();
|
||||
|
|
Loading…
Add table
Reference in a new issue