upgrade webfinger everywhere, and implement async

This commit is contained in:
Mina Galić 2020-05-24 20:27:39 +02:00
parent 18bb413011
commit 7aabb9661e
No known key found for this signature in database
GPG Key ID: ACFEFF7F6A123A86
3 changed files with 41 additions and 50 deletions

75
Cargo.lock generated
View File

@ -31,7 +31,7 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65608fdeae5eb05485d5b71a3d2242d76b2b7413608c196d47eb4dff3eed7b85" checksum = "65608fdeae5eb05485d5b71a3d2242d76b2b7413608c196d47eb4dff3eed7b85"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -160,7 +160,7 @@ version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26c4f3195085c36ea8d24d32b2f828d23296a9370a28aa39d111f6f16bef9f3b" checksum = "26c4f3195085c36ea8d24d32b2f828d23296a9370a28aa39d111f6f16bef9f3b"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -324,7 +324,7 @@ dependencies = [
"lazycell", "lazycell",
"log 0.4.8", "log 0.4.8",
"peeking_take_while", "peeking_take_while",
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"regex", "regex",
"rustc-hash", "rustc-hash",
@ -692,9 +692,9 @@ checksum = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9"
[[package]] [[package]]
name = "data-encoding" name = "data-encoding"
version = "2.2.0" version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11c0346158a19b3627234e15596f5e465c360fcdb97d817bcb255e0510f5a788" checksum = "72aa14c04dfae8dd7d8a2b1cb7ca2152618cd01336dbfe704b8dcbf8d41dbd69"
[[package]] [[package]]
name = "dbghelp-sys" name = "dbghelp-sys"
@ -766,7 +766,7 @@ version = "0.3.0"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089" source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089"
dependencies = [ dependencies = [
"bitflags 1.2.1", "bitflags 1.2.1",
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -804,7 +804,7 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -968,7 +968,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd"
dependencies = [ dependencies = [
"backtrace 0.3.48", "backtrace 0.3.48",
"version_check 0.9.1", "version_check 0.9.2",
] ]
[[package]] [[package]]
@ -998,7 +998,7 @@ version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
"synstructure", "synstructure",
@ -1199,7 +1199,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39"
dependencies = [ dependencies = [
"proc-macro-hack 0.5.15", "proc-macro-hack 0.5.15",
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -1850,7 +1850,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c" checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c"
dependencies = [ dependencies = [
"migrations_internals", "migrations_internals",
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -2067,7 +2067,7 @@ checksum = "0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6"
dependencies = [ dependencies = [
"lexical-core", "lexical-core",
"memchr", "memchr",
"version_check 0.9.1", "version_check 0.9.2",
] ]
[[package]] [[package]]
@ -2200,9 +2200,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.56" version = "0.9.57"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f02309a7f127000ed50594f0b50ecc69e7c654e16d41b4e8156d1b3df8e0b52e" checksum = "7410fef80af8ac071d4f63755c0ab89ac3df0fd1ea91f1d1f37cf5cec4395990"
dependencies = [ dependencies = [
"autocfg 1.0.0", "autocfg 1.0.0",
"cc", "cc",
@ -2396,7 +2396,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40" checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -2474,7 +2474,7 @@ dependencies = [
"tokio", "tokio",
"validator", "validator",
"validator_derive", "validator_derive",
"webfinger 0.5.0 (git+https://github.com/Plume-org/webfinger?rev=4e8f12810c4a7ba7a07bbcb722cd265fdff512b6)", "webfinger",
] ]
[[package]] [[package]]
@ -2581,7 +2581,7 @@ dependencies = [
"tokio", "tokio",
"url 2.1.1", "url 2.1.1",
"walkdir", "walkdir",
"webfinger 0.5.0 (git+https://github.com/Plume-org/webfinger?rev=update-deps)", "webfinger",
"whatlang", "whatlang",
] ]
@ -2662,9 +2662,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.15" version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70a50b9351bfa8d65a7d93ce712dc63d2fd15ddbf2c36990fc7cac344859c04f" checksum = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101"
dependencies = [ dependencies = [
"unicode-xid 0.2.0", "unicode-xid 0.2.0",
] ]
@ -2735,7 +2735,7 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
] ]
[[package]] [[package]]
@ -3042,7 +3042,7 @@ dependencies = [
"time", "time",
"tokio", "tokio",
"toml", "toml",
"version_check 0.9.1", "version_check 0.9.2",
"yansi 0.5.0", "yansi 0.5.0",
] ]
@ -3055,7 +3055,7 @@ dependencies = [
"indexmap", "indexmap",
"quote 1.0.6", "quote 1.0.6",
"rocket_http", "rocket_http",
"version_check 0.9.1", "version_check 0.9.2",
"yansi 0.5.0", "yansi 0.5.0",
] ]
@ -3290,7 +3290,7 @@ version = "1.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984" checksum = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -3350,7 +3350,7 @@ checksum = "83695fde96cbe9e08f0e4eb96b1b56fdbd44f2098ee27462dda964c7745fddc7"
dependencies = [ dependencies = [
"bitflags 1.2.1", "bitflags 1.2.1",
"itertools", "itertools",
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -3363,7 +3363,7 @@ checksum = "e63e6744142336dfb606fe2b068afa2e1cca1ee6a5d8377277a92945d81fa331"
dependencies = [ dependencies = [
"bitflags 1.2.1", "bitflags 1.2.1",
"itertools", "itertools",
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
] ]
@ -3513,7 +3513,7 @@ checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6"
dependencies = [ dependencies = [
"phf_generator", "phf_generator",
"phf_shared", "phf_shared",
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"string_cache_shared", "string_cache_shared",
] ]
@ -3591,7 +3591,7 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95b5f192649e48a5302a13f2feb224df883b98933222369e4b3b0fe2a5447269" checksum = "95b5f192649e48a5302a13f2feb224df883b98933222369e4b3b0fe2a5447269"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"unicode-xid 0.2.0", "unicode-xid 0.2.0",
] ]
@ -3611,7 +3611,7 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
"unicode-xid 0.2.0", "unicode-xid 0.2.0",
@ -3869,7 +3869,7 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [ dependencies = [
"version_check 0.9.1", "version_check 0.9.2",
] ]
[[package]] [[package]]
@ -4035,9 +4035,9 @@ checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.1" version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]] [[package]]
name = "void" name = "void"
@ -4093,7 +4093,7 @@ dependencies = [
"bumpalo", "bumpalo",
"lazy_static", "lazy_static",
"log 0.4.8", "log 0.4.8",
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
"wasm-bindgen-shared", "wasm-bindgen-shared",
@ -4127,7 +4127,7 @@ version = "0.2.62"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a"
dependencies = [ dependencies = [
"proc-macro2 1.0.15", "proc-macro2 1.0.17",
"quote 1.0.6", "quote 1.0.6",
"syn 1.0.23", "syn 1.0.23",
"wasm-bindgen-backend", "wasm-bindgen-backend",
@ -4160,15 +4160,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "webfinger"
version = "0.5.0"
source = "git+https://github.com/Plume-org/webfinger?rev=update-deps#cdaab95ed54765cdd70c61c39f9d2d19348472a9"
dependencies = [
"reqwest",
"serde",
]
[[package]] [[package]]
name = "whatlang" name = "whatlang"
version = "0.7.3" version = "0.7.3"

View File

@ -25,7 +25,7 @@ tantivy = "0.10.1"
tokio = "0.2" tokio = "0.2"
url = "2.1" url = "2.1"
walkdir = "2.2" walkdir = "2.2"
webfinger = { git = "https://github.com/Plume-org/webfinger", rev = "update-deps" } webfinger = { git = "https://github.com/Plume-org/webfinger", rev = "4e8f12810c4a7ba7a07bbcb722cd265fdff512b6", features = ["async"] }
whatlang = "0.7.1" whatlang = "0.7.1"
shrinkwraprs = "0.3" shrinkwraprs = "0.3"
diesel-derive-newtype = "0.1.2" diesel-derive-newtype = "0.1.2"

View File

@ -69,9 +69,9 @@ impl AsyncResolver for WebfingerResolver {
Prefix::Custom(_) => Err(ResolverError::NotFound), Prefix::Custom(_) => Err(ResolverError::NotFound),
} }
} }
async fn endpoint( async fn endpoint<R: Into<String> + Send>(
&self, &self,
resource: impl Into<String> + 'async_trait, resource: R,
resource_repo: PlumeRocket, resource_repo: PlumeRocket,
) -> Result<Webfinger, ResolverError> { ) -> Result<Webfinger, ResolverError> {
let resource = resource.into(); let resource = resource.into();
@ -82,10 +82,8 @@ impl AsyncResolver for WebfingerResolver {
let mut parsed_res = res.splitn(2, '@'); let mut parsed_res = res.splitn(2, '@');
let user = parsed_res.next().ok_or(ResolverError::InvalidResource)?; let user = parsed_res.next().ok_or(ResolverError::InvalidResource)?;
let domain = parsed_res.next().ok_or(ResolverError::InvalidResource)?; let domain = parsed_res.next().ok_or(ResolverError::InvalidResource)?;
if domain == webfinger.instance_domain() { if domain == self.instance_domain().await {
webfinger self.find(res_prefix, user.to_string(), resource_repo).await
.find(res_prefix, user.to_string(), resource_repo)
.await
} else { } else {
Err(ResolverError::WrongDomain) Err(ResolverError::WrongDomain)
} }
@ -94,7 +92,9 @@ impl AsyncResolver for WebfingerResolver {
#[get("/.well-known/webfinger?<resource>")] #[get("/.well-known/webfinger?<resource>")]
pub async fn webfinger(resource: String, rockets: PlumeRocket) -> Content<String> { pub async fn webfinger(resource: String, rockets: PlumeRocket) -> Content<String> {
match WebfingerResolver::endpoint(resource, rockets) let wf_resolver = WebfingerResolver;
match wf_resolver
.endpoint(resource, rockets)
.await .await
.and_then(|wf| serde_json::to_string(&wf).map_err(|_| ResolverError::NotFound)) .and_then(|wf| serde_json::to_string(&wf).map_err(|_| ResolverError::NotFound))
{ {