use reqwest in authc and enable trust_dns

This commit is contained in:
Marcel Märtens 2021-04-07 15:23:40 +02:00
parent add74cd0ea
commit 87a5034bdf
7 changed files with 227 additions and 35 deletions

228
Cargo.lock generated
View File

@ -288,7 +288,7 @@ dependencies = [
[[package]]
name = "auth-common"
version = "0.1.0"
source = "git+https://gitlab.com/veloren/auth.git?rev=fb3dcbc4962b367253f8f2f92760ef44d2679c9a#fb3dcbc4962b367253f8f2f92760ef44d2679c9a"
source = "git+https://gitlab.com/veloren/auth.git?rev=9d3df28de3bc9a34321b3c99789a9add652cb2ba#9d3df28de3bc9a34321b3c99789a9add652cb2ba"
dependencies = [
"rand 0.8.4",
"serde",
@ -298,17 +298,16 @@ dependencies = [
[[package]]
name = "authc"
version = "1.0.0"
source = "git+https://gitlab.com/veloren/auth.git?rev=fb3dcbc4962b367253f8f2f92760ef44d2679c9a#fb3dcbc4962b367253f8f2f92760ef44d2679c9a"
source = "git+https://gitlab.com/veloren/auth.git?rev=9d3df28de3bc9a34321b3c99789a9add652cb2ba#9d3df28de3bc9a34321b3c99789a9add652cb2ba"
dependencies = [
"auth-common",
"fxhash",
"hex",
"http",
"hyper",
"hyper-rustls",
"reqwest",
"rust-argon2",
"serde",
"serde_json",
"url",
"uuid",
]
@ -1321,6 +1320,12 @@ dependencies = [
"syn 1.0.73",
]
[[package]]
name = "data-encoding"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57"
[[package]]
name = "deflate"
version = "0.8.6"
@ -1498,6 +1503,18 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"
[[package]]
name = "enum-as-inner"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c5f0096a91d210159eceb2ff5e1c4da18388a170e1e3ce948aac9c8fdbbf595"
dependencies = [
"heck",
"proc-macro2 1.0.27",
"quote 1.0.9",
"syn 1.0.73",
]
[[package]]
name = "enum-iterator"
version = "0.6.0"
@ -2370,9 +2387,9 @@ dependencies = [
[[package]]
name = "hex"
version = "0.3.2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hibitset"
@ -2384,6 +2401,17 @@ dependencies = [
"rayon",
]
[[package]]
name = "hostname"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867"
dependencies = [
"libc",
"match_cfg",
"winapi 0.3.9",
]
[[package]]
name = "http"
version = "0.2.4"
@ -2454,12 +2482,10 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64"
dependencies = [
"ct-logs",
"futures-util",
"hyper",
"log",
"rustls",
"rustls-native-certs",
"tokio",
"tokio-rustls",
"webpki",
@ -2637,6 +2663,24 @@ dependencies = [
"libc",
]
[[package]]
name = "ipconfig"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7"
dependencies = [
"socket2 0.3.19",
"widestring",
"winapi 0.3.9",
"winreg 0.6.2",
]
[[package]]
name = "ipnet"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9"
[[package]]
name = "itertools"
version = "0.9.0"
@ -2920,6 +2964,15 @@ dependencies = [
"syn 1.0.73",
]
[[package]]
name = "lru-cache"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c"
dependencies = [
"linked-hash-map",
]
[[package]]
name = "lz-fear"
version = "0.1.1"
@ -2960,6 +3013,12 @@ dependencies = [
"libc",
]
[[package]]
name = "match_cfg"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
[[package]]
name = "matchers"
version = "0.0.1"
@ -3047,6 +3106,12 @@ dependencies = [
"objc",
]
[[package]]
name = "mime"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "minifb"
version = "0.19.3"
@ -4047,6 +4112,12 @@ dependencies = [
"syn 1.0.73",
]
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]]
name = "quinn"
version = "0.7.2"
@ -4401,6 +4472,53 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157"
[[package]]
name = "reqwest"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22"
dependencies = [
"base64",
"bytes",
"encoding_rs",
"futures-core",
"futures-util",
"http",
"http-body",
"hyper",
"hyper-rustls",
"ipnet",
"js-sys",
"lazy_static",
"log",
"mime",
"percent-encoding",
"pin-project-lite",
"rustls",
"serde",
"serde_json",
"serde_urlencoded",
"tokio",
"tokio-rustls",
"trust-dns-resolver",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots",
"winreg 0.7.0",
]
[[package]]
name = "resolv-conf"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00"
dependencies = [
"hostname",
"quick-error",
]
[[package]]
name = "ring"
version = "0.16.20"
@ -4831,6 +4949,18 @@ dependencies = [
"syn 1.0.73",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9"
dependencies = [
"form_urlencoded",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "sha1"
version = "0.6.0"
@ -5641,6 +5771,51 @@ dependencies = [
"vek",
]
[[package]]
name = "trust-dns-proto"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad0d7f5db438199a6e2609debe3f69f808d074e0a2888ee0bccb45fe234d03f4"
dependencies = [
"async-trait",
"cfg-if 1.0.0",
"data-encoding",
"enum-as-inner",
"futures-channel",
"futures-io",
"futures-util",
"idna",
"ipnet",
"lazy_static",
"log",
"rand 0.8.4",
"smallvec",
"thiserror",
"tinyvec",
"tokio",
"url",
]
[[package]]
name = "trust-dns-resolver"
version = "0.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ad17b608a64bd0735e67bde16b0636f8aa8591f831a25d18443ed00a699770"
dependencies = [
"cfg-if 1.0.0",
"futures-util",
"ipconfig",
"lazy_static",
"log",
"lru-cache",
"parking_lot 0.11.1",
"resolv-conf",
"smallvec",
"thiserror",
"tokio",
"trust-dns-proto",
]
[[package]]
name = "try-lock"
version = "0.2.3"
@ -6385,6 +6560,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd"
dependencies = [
"cfg-if 1.0.0",
"serde",
"serde_json",
"wasm-bindgen-macro",
]
@ -6744,6 +6921,15 @@ dependencies = [
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940"
dependencies = [
"webpki",
]
[[package]]
name = "wfd"
version = "0.1.7"
@ -6842,6 +7028,12 @@ dependencies = [
"libc",
]
[[package]]
name = "widestring"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
[[package]]
name = "winapi"
version = "0.2.8"
@ -6940,6 +7132,24 @@ dependencies = [
"x11-dl",
]
[[package]]
name = "winreg"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "winreg"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "winres"
version = "0.1.11"

View File

@ -30,7 +30,7 @@ rayon = "1.5"
specs = { git = "https://github.com/amethyst/specs.git", rev = "f985bec5d456f7b0dd8aae99848f9473c2cd9d46" }
vek = { version = "=0.14.1", features = ["serde"] }
hashbrown = { version = "0.11", features = ["rayon", "serde", "nightly"] }
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "fb3dcbc4962b367253f8f2f92760ef44d2679c9a" }
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "9d3df28de3bc9a34321b3c99789a9add652cb2ba" }
#TODO: put bot in a different crate
#bot only

View File

@ -108,12 +108,6 @@ impl BotClient {
info!("usernames: {:?}", usernames);
if let Some(auth_addr) = self.menu_client.server_info().auth_provider.as_ref() {
let (scheme, authority) = auth_addr.split_once("://").expect("invalid auth url");
let scheme = scheme
.parse::<authc::Scheme>()
.expect("invalid auth url scheme");
let authority = authority
.parse::<authc::Authority>()
.expect("invalid auth url authority");
let authc = AuthClient::new(scheme, authority).expect("couldn't connect to , insecure");
for username in usernames.iter() {

View File

@ -670,16 +670,6 @@ impl Client {
None => return Err(Error::AuthServerUrlInvalid(addr.to_string())),
};
let scheme = match scheme.parse::<authc::Scheme>() {
Ok(s) => s,
Err(_) => return Err(Error::AuthServerUrlInvalid(addr.to_string())),
};
let authority = match authority.parse::<authc::Authority>() {
Ok(a) => a,
Err(_) => return Err(Error::AuthServerUrlInvalid(addr.to_string())),
};
Ok(authc::AuthClient::new(scheme, authority)?
.sign_in(&username, &password)
.await?

View File

@ -47,7 +47,7 @@ rayon = "1.5"
crossbeam-channel = "0.5"
prometheus = { version = "0.12", default-features = false}
portpicker = { git = "https://github.com/xMAC94x/portpicker-rs", rev = "df6b37872f3586ac3b21d08b56c8ec7cd92fb172" }
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "fb3dcbc4962b367253f8f2f92760ef44d2679c9a" }
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "9d3df28de3bc9a34321b3c99789a9add652cb2ba" }
slab = "0.4"
rand_distr = "0.4.0"

View File

@ -59,13 +59,6 @@ impl LoginProvider {
let auth_server = auth_addr.map(|addr| {
let (scheme, authority) = addr.split_once("://").expect("invalid auth url");
let scheme = scheme
.parse::<authc::Scheme>()
.expect("invalid auth url scheme");
let authority = authority
.parse::<authc::Authority>()
.expect("invalid auth url authority");
Arc::new(AuthClient::new(scheme, authority).expect("insecure auth scheme"))
});

View File

@ -429,11 +429,16 @@ fn get_client_msg_error(
client::AuthClientError::InsecureSchema => {
localization.get("main.login.insecure_auth_scheme").into()
},
client::AuthClientError::InvalidUrl(e) => format!(
"{}: {}",
localization.get("main.login.failed_auth_server_url_invalid"),
e
),
client::AuthClientError::ServerError(_, e) => String::from_utf8_lossy(&e).into(),
},
Error::AuthServerUrlInvalid(e) => {
format!(
"{}: https://{}",
"{}: {}",
localization.get("main.login.failed_auth_server_url_invalid"),
e
)