Auth requests are now done async, the register system is fetching it, via a PendingLogin component

The auth server no longer allows the protocol to be specified. we enforce `https` for the auth server, so DO NOT provide a auth url with `https://` but without.
correct is now `auth.veloren.net`
incorrect is: `https://auth.veloren.net`
This commit is contained in:
Marcel Märtens 2021-03-11 01:08:12 +01:00
parent a3d54e908e
commit a98e72c391
18 changed files with 323 additions and 385 deletions

356
Cargo.lock generated
View File

@ -278,9 +278,9 @@ dependencies = [
[[package]] [[package]]
name = "auth-common" name = "auth-common"
version = "0.1.0" version = "0.1.0"
source = "git+https://gitlab.com/veloren/auth.git?rev=bffb5181a35c19ddfd33ee0b4aedba741aafb68d#bffb5181a35c19ddfd33ee0b4aedba741aafb68d" source = "git+https://gitlab.com/veloren/auth.git?rev=f3683798bc5ea656845010f9bae11b05dd671ece#f3683798bc5ea656845010f9bae11b05dd671ece"
dependencies = [ dependencies = [
"rand 0.7.3", "rand 0.8.3",
"serde", "serde",
"uuid", "uuid",
] ]
@ -288,15 +288,17 @@ dependencies = [
[[package]] [[package]]
name = "authc" name = "authc"
version = "1.0.0" version = "1.0.0"
source = "git+https://gitlab.com/veloren/auth.git?rev=bffb5181a35c19ddfd33ee0b4aedba741aafb68d#bffb5181a35c19ddfd33ee0b4aedba741aafb68d" source = "git+https://gitlab.com/veloren/auth.git?rev=f3683798bc5ea656845010f9bae11b05dd671ece#f3683798bc5ea656845010f9bae11b05dd671ece"
dependencies = [ dependencies = [
"auth-common", "auth-common",
"fxhash", "fxhash",
"hex", "hex",
"reqwest", "http",
"hyper",
"hyper-rustls",
"rust-argon2", "rust-argon2",
"serde", "serde",
"url", "serde_json",
"uuid", "uuid",
] ]
@ -326,12 +328,6 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b"
[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.13.0" version = "0.13.0"
@ -447,12 +443,6 @@ version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]]
name = "bytes"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.0.1" version = "1.0.1"
@ -721,7 +711,7 @@ version = "4.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc4369b5e4c0cddf64ad8981c0111e7df4f7078f4d6ba98fb31f2e17c4c57b7e" checksum = "cc4369b5e4c0cddf64ad8981c0111e7df4f7078f4d6ba98fb31f2e17c4c57b7e"
dependencies = [ dependencies = [
"bytes 1.0.1", "bytes",
"memchr", "memchr",
] ]
@ -1066,7 +1056,7 @@ dependencies = [
"serde_derive", "serde_derive",
"serde_json", "serde_json",
"tinytemplate", "tinytemplate",
"tokio 1.3.0", "tokio",
"walkdir 2.3.1", "walkdir 2.3.1",
] ]
@ -1258,6 +1248,15 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "ct-logs"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8"
dependencies = [
"sct",
]
[[package]] [[package]]
name = "daggy" name = "daggy"
version = "0.5.0" version = "0.5.0"
@ -1855,7 +1854,7 @@ dependencies = [
"futures-sink", "futures-sink",
"futures-task", "futures-task",
"memchr", "memchr",
"pin-project-lite 0.2.6", "pin-project-lite",
"pin-utils", "pin-utils",
"proc-macro-hack", "proc-macro-hack",
"proc-macro-nested", "proc-macro-nested",
@ -2199,11 +2198,11 @@ dependencies = [
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.2.7" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" checksum = "d832b01df74254fe364568d6ddc294443f61cbec82816b60904303af87efae78"
dependencies = [ dependencies = [
"bytes 0.5.6", "bytes",
"fnv", "fnv",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
@ -2211,10 +2210,9 @@ dependencies = [
"http", "http",
"indexmap", "indexmap",
"slab", "slab",
"tokio 0.2.25", "tokio",
"tokio-util", "tokio-util",
"tracing", "tracing",
"tracing-futures",
] ]
[[package]] [[package]]
@ -2301,28 +2299,18 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747"
dependencies = [ dependencies = [
"bytes 1.0.1", "bytes",
"fnv", "fnv",
"itoa", "itoa",
] ]
[[package]]
name = "http-body"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b"
dependencies = [
"bytes 0.5.6",
"http",
]
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994"
dependencies = [ dependencies = [
"bytes 1.0.1", "bytes",
"http", "http",
] ]
@ -2340,46 +2328,23 @@ checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.13.10" version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" checksum = "e8e946c2b1349055e0b72ae281b238baf1a3ea7307c7e9f9d64673bdd9c26ac7"
dependencies = [ dependencies = [
"bytes 0.5.6", "bytes",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2", "h2",
"http", "http",
"http-body 0.3.1", "http-body",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
"pin-project", "pin-project",
"socket2", "socket2",
"tokio 0.2.25", "tokio",
"tower-service",
"tracing",
"want",
]
[[package]]
name = "hyper"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8e946c2b1349055e0b72ae281b238baf1a3ea7307c7e9f9d64673bdd9c26ac7"
dependencies = [
"bytes 1.0.1",
"futures-channel",
"futures-core",
"futures-util",
"http",
"http-body 0.4.0",
"httparse",
"httpdate",
"itoa",
"pin-project",
"socket2",
"tokio 1.3.0",
"tower-service", "tower-service",
"tracing", "tracing",
"want", "want",
@ -2387,16 +2352,17 @@ dependencies = [
[[package]] [[package]]
name = "hyper-rustls" name = "hyper-rustls"
version = "0.21.0" version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37743cc83e8ee85eacfce90f2f4102030d9ff0a95244098d781e9bee4a90abb6" checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64"
dependencies = [ dependencies = [
"bytes 0.5.6", "ct-logs",
"futures-util", "futures-util",
"hyper 0.13.10", "hyper",
"log", "log",
"rustls 0.18.1", "rustls",
"tokio 0.2.25", "rustls-native-certs",
"tokio",
"tokio-rustls", "tokio-rustls",
"webpki", "webpki",
] ]
@ -2575,12 +2541,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "ipnet"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135"
[[package]] [[package]]
name = "itertools" name = "itertools"
version = "0.9.0" version = "0.9.0"
@ -2986,22 +2946,6 @@ dependencies = [
"syn 1.0.63", "syn 1.0.63",
] ]
[[package]]
name = "mime"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "mime_guess"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
dependencies = [
"mime",
"unicase",
]
[[package]] [[package]]
name = "minifb" name = "minifb"
version = "0.19.1" version = "0.19.1"
@ -3797,12 +3741,6 @@ dependencies = [
"syn 1.0.63", "syn 1.0.63",
] ]
[[package]]
name = "pin-project-lite"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777"
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.6" version = "0.2.6"
@ -3985,9 +3923,9 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df5edaa7893393e195534aefb9ace447292d9fa0afcb70e114a4de05cd0a7d81" checksum = "df5edaa7893393e195534aefb9ace447292d9fa0afcb70e114a4de05cd0a7d81"
dependencies = [ dependencies = [
"hyper 0.14.4", "hyper",
"prometheus", "prometheus",
"tokio 1.3.0", "tokio",
"tracing", "tracing",
] ]
@ -4243,43 +4181,6 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "reqwest"
version = "0.10.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c"
dependencies = [
"base64 0.13.0",
"bytes 0.5.6",
"encoding_rs",
"futures-core",
"futures-util",
"http",
"http-body 0.3.1",
"hyper 0.13.10",
"hyper-rustls",
"ipnet",
"js-sys",
"lazy_static",
"log",
"mime",
"mime_guess",
"percent-encoding",
"pin-project-lite 0.2.6",
"rustls 0.18.1",
"serde",
"serde_json",
"serde_urlencoded",
"tokio 0.2.25",
"tokio-rustls",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots 0.20.0",
"winreg",
]
[[package]] [[package]]
name = "ring" name = "ring"
version = "0.16.20" version = "0.16.20"
@ -4318,7 +4219,7 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "064ea8613fb712a19faf920022ec8ddf134984f100090764a4e1d768f3827f1f" checksum = "064ea8613fb712a19faf920022ec8ddf134984f100090764a4e1d768f3827f1f"
dependencies = [ dependencies = [
"base64 0.13.0", "base64",
"bitflags", "bitflags",
"serde", "serde",
] ]
@ -4335,7 +4236,7 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb"
dependencies = [ dependencies = [
"base64 0.13.0", "base64",
"blake2b_simd", "blake2b_simd",
"constant_time_eq", "constant_time_eq",
] ]
@ -4363,11 +4264,11 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.18.1" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b"
dependencies = [ dependencies = [
"base64 0.12.3", "base64",
"log", "log",
"ring", "ring",
"sct", "sct",
@ -4375,16 +4276,15 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rustls" name = "rustls-native-certs"
version = "0.19.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b" checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092"
dependencies = [ dependencies = [
"base64 0.13.0", "openssl-probe",
"log", "rustls",
"ring", "schannel",
"sct", "security-framework",
"webpki",
] ]
[[package]] [[package]]
@ -4456,6 +4356,16 @@ dependencies = [
"regex", "regex",
] ]
[[package]]
name = "schannel"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
dependencies = [
"lazy_static",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "scoped-tls" name = "scoped-tls"
version = "1.0.0" version = "1.0.0"
@ -4506,6 +4416,29 @@ dependencies = [
"version-compare", "version-compare",
] ]
[[package]]
name = "security-framework"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d493c5f39e02dfb062cd8f33301f90f9b13b650e8c1b1d0fd75c19dd64bff69d"
dependencies = [
"bitflags",
"core-foundation 0.9.1",
"core-foundation-sys 0.8.2",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dee48cdde5ed250b0d3252818f646e174ab414036edb884dde62d80a3ac6082d"
dependencies = [
"core-foundation-sys 0.8.2",
"libc",
]
[[package]] [[package]]
name = "semver" name = "semver"
version = "0.9.0" version = "0.9.0"
@ -4582,18 +4515,6 @@ dependencies = [
"syn 1.0.63", "syn 1.0.63",
] ]
[[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]] [[package]]
name = "sha1" name = "sha1"
version = "0.6.0" version = "0.6.0"
@ -5135,24 +5056,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092"
dependencies = [
"bytes 0.5.6",
"fnv",
"futures-core",
"iovec",
"lazy_static",
"memchr",
"mio 0.6.23",
"num_cpus",
"pin-project-lite 0.1.12",
"slab",
]
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.3.0" version = "1.3.0"
@ -5160,13 +5063,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d56477f6ed99e10225f38f9f75f872f29b8b8bd8c0b946f63345bb144e9eeda" checksum = "8d56477f6ed99e10225f38f9f75f872f29b8b8bd8c0b946f63345bb144e9eeda"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"bytes 1.0.1", "bytes",
"libc", "libc",
"memchr", "memchr",
"mio 0.7.9", "mio 0.7.9",
"num_cpus", "num_cpus",
"once_cell", "once_cell",
"pin-project-lite 0.2.6", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"tokio-macros", "tokio-macros",
"winapi 0.3.9", "winapi 0.3.9",
@ -5185,13 +5088,12 @@ dependencies = [
[[package]] [[package]]
name = "tokio-rustls" name = "tokio-rustls"
version = "0.14.1" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
dependencies = [ dependencies = [
"futures-core", "rustls",
"rustls 0.18.1", "tokio",
"tokio 0.2.25",
"webpki", "webpki",
] ]
@ -5202,22 +5104,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c535f53c0cfa1acace62995a8994fc9cc1f12d202420da96ff306ee24d576469" checksum = "c535f53c0cfa1acace62995a8994fc9cc1f12d202420da96ff306ee24d576469"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"pin-project-lite 0.2.6", "pin-project-lite",
"tokio 1.3.0", "tokio",
] ]
[[package]] [[package]]
name = "tokio-util" name = "tokio-util"
version = "0.3.1" version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" checksum = "ec31e5cc6b46e653cf57762f36f71d5e6386391d88a72fd6db4508f8f676fb29"
dependencies = [ dependencies = [
"bytes 0.5.6", "bytes",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"log", "log",
"pin-project-lite 0.1.12", "pin-project-lite",
"tokio 0.2.25", "tokio",
] ]
[[package]] [[package]]
@ -5242,8 +5144,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"log", "pin-project-lite",
"pin-project-lite 0.2.6",
"tracing-attributes", "tracing-attributes",
"tracing-core", "tracing-core",
] ]
@ -5279,16 +5180,6 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[package]] [[package]]
name = "tracing-log" name = "tracing-log"
version = "0.1.2" version = "0.1.2"
@ -5420,15 +5311,6 @@ version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check 0.9.2",
]
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.4" version = "0.3.4"
@ -5503,17 +5385,17 @@ version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "294b85ef5dbc3670a72e82a89971608a1fcc4ed5c7c5a2895230d31a95f0569b" checksum = "294b85ef5dbc3670a72e82a89971608a1fcc4ed5c7c5a2895230d31a95f0569b"
dependencies = [ dependencies = [
"base64 0.13.0", "base64",
"chunked_transfer", "chunked_transfer",
"cookie", "cookie",
"cookie_store", "cookie_store",
"log", "log",
"once_cell", "once_cell",
"qstring", "qstring",
"rustls 0.19.0", "rustls",
"url", "url",
"webpki", "webpki",
"webpki-roots 0.21.0", "webpki-roots",
] ]
[[package]] [[package]]
@ -5588,7 +5470,7 @@ dependencies = [
"num 0.4.0", "num 0.4.0",
"rayon", "rayon",
"specs", "specs",
"tokio 1.3.0", "tokio",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"vek 0.14.1", "vek 0.14.1",
@ -5704,7 +5586,7 @@ dependencies = [
"async-trait", "async-trait",
"bincode", "bincode",
"bitflags", "bitflags",
"bytes 1.0.1", "bytes",
"clap", "clap",
"criterion", "criterion",
"crossbeam-channel", "crossbeam-channel",
@ -5717,7 +5599,7 @@ dependencies = [
"rand 0.8.3", "rand 0.8.3",
"serde", "serde",
"shellexpand", "shellexpand",
"tokio 1.3.0", "tokio",
"tokio-stream", "tokio-stream",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
@ -5731,11 +5613,11 @@ dependencies = [
"async-channel", "async-channel",
"async-trait", "async-trait",
"bitflags", "bitflags",
"bytes 1.0.1", "bytes",
"criterion", "criterion",
"prometheus", "prometheus",
"rand 0.8.3", "rand 0.8.3",
"tokio 1.3.0", "tokio",
"tracing", "tracing",
] ]
@ -5795,7 +5677,7 @@ dependencies = [
"slab", "slab",
"specs", "specs",
"specs-idvs", "specs-idvs",
"tokio 1.3.0", "tokio",
"tracing", "tracing",
"vek 0.14.1", "vek 0.14.1",
"veloren-common", "veloren-common",
@ -5820,7 +5702,7 @@ dependencies = [
"serde", "serde",
"signal-hook 0.3.6", "signal-hook 0.3.6",
"termcolor", "termcolor",
"tokio 1.3.0", "tokio",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"tracing-tracy", "tracing-tracy",
@ -5879,7 +5761,7 @@ dependencies = [
"specs", "specs",
"specs-idvs", "specs-idvs",
"termcolor", "termcolor",
"tokio 1.3.0", "tokio",
"tracing", "tracing",
"tracing-appender", "tracing-appender",
"tracing-log", "tracing-log",
@ -6022,8 +5904,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7" checksum = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"serde",
"serde_json",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]
@ -6454,15 +6334,6 @@ dependencies = [
"untrusted", "untrusted",
] ]
[[package]]
name = "webpki-roots"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f"
dependencies = [
"webpki",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.21.0" version = "0.21.0"
@ -6588,15 +6459,6 @@ dependencies = [
"x11-dl", "x11-dl",
] ]
[[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]] [[package]]
name = "winres" name = "winres"
version = "0.1.11" version = "0.1.11"

View File

@ -41,6 +41,7 @@ You can create an account over at
https://veloren.net/account/."#, https://veloren.net/account/."#,
"main.login.server_not_found": "Server not found", "main.login.server_not_found": "Server not found",
"main.login.authentication_error": "Auth error on server", "main.login.authentication_error": "Auth error on server",
"main.login.failed_auth_server_url_invalid": "Failed to connect to auth server",
"main.login.server_full": "Server is full", "main.login.server_full": "Server is full",
"main.login.untrusted_auth_server": "Auth server not trusted", "main.login.untrusted_auth_server": "Auth server not trusted",
"main.login.outdated_client_or_server": "ServerWentMad: Probably versions are incompatible, check for updates.", "main.login.outdated_client_or_server": "ServerWentMad: Probably versions are incompatible, check for updates.",

View File

@ -27,7 +27,7 @@ rayon = "1.5"
specs = { git = "https://github.com/amethyst/specs.git", rev = "5a9b71035007be0e3574f35184acac1cd4530496" } specs = { git = "https://github.com/amethyst/specs.git", rev = "5a9b71035007be0e3574f35184acac1cd4530496" }
vek = { version = "=0.14.1", features = ["serde"] } vek = { version = "=0.14.1", features = ["serde"] }
hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] } hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] }
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "bffb5181a35c19ddfd33ee0b4aedba741aafb68d" } authc = { git = "https://gitlab.com/veloren/auth.git", rev = "f3683798bc5ea656845010f9bae11b05dd671ece" }
[dev-dependencies] [dev-dependencies]
tracing-subscriber = { version = "0.2.3", default-features = false, features = ["fmt", "chrono", "ansi", "smallvec"] } tracing-subscriber = { version = "0.2.3", default-features = false, features = ["fmt", "chrono", "ansi", "smallvec"] }

View File

@ -62,7 +62,7 @@ fn main() {
runtime runtime
.block_on(client.register(username, password, |provider| { .block_on(client.register(username, password, |provider| {
provider == "https://auth.veloren.net" provider == "auth.veloren.net"
})) }))
.unwrap(); .unwrap();

View File

@ -16,6 +16,7 @@ pub enum Error {
AlreadyLoggedIn, AlreadyLoggedIn,
AuthErr(String), AuthErr(String),
AuthClientError(AuthClientError), AuthClientError(AuthClientError),
AuthServerUrlInvalid(String),
AuthServerNotTrusted, AuthServerNotTrusted,
Banned(String), Banned(String),
/// Persisted character data is invalid or missing /// Persisted character data is invalid or missing

View File

@ -485,16 +485,24 @@ impl Client {
mut auth_trusted: impl FnMut(&str) -> bool, mut auth_trusted: impl FnMut(&str) -> bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
// Authentication // Authentication
let token_or_username = self.server_info.auth_provider.as_ref().map(|addr| let token_or_username = match &self.server_info.auth_provider {
Some(addr) => {
// Query whether this is a trusted auth server // Query whether this is a trusted auth server
if auth_trusted(&addr) { if auth_trusted(&addr) {
Ok(authc::AuthClient::new(addr)? use std::str::FromStr;
.sign_in(&username, &password)? match authc::Authority::from_str(&addr) {
.serialize()) Ok(addr) => Ok(authc::AuthClient::new(addr)
.sign_in(&username, &password)
.await?
.serialize()),
Err(_) => Err(Error::AuthServerUrlInvalid(addr.to_string())),
}
} else { } else {
Err(Error::AuthServerNotTrusted) Err(Error::AuthServerNotTrusted)
} }
).unwrap_or(Ok(username))?; },
None => Ok(username),
}?;
self.send_msg_err(ClientRegister { token_or_username })?; self.send_msg_err(ClientRegister { token_or_username })?;

View File

@ -21,7 +21,7 @@ tracing = { version = "0.1", default-features = false }
hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] } hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] }
# Auth # Auth
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "bffb5181a35c19ddfd33ee0b4aedba741aafb68d" } authc = { git = "https://gitlab.com/veloren/auth.git", rev = "f3683798bc5ea656845010f9bae11b05dd671ece" }
# ECS # ECS
specs = { git = "https://github.com/amethyst/specs.git", features = ["serde", "storage-event-control"], rev = "5a9b71035007be0e3574f35184acac1cd4530496" } specs = { git = "https://github.com/amethyst/specs.git", features = ["serde", "storage-event-control"], rev = "5a9b71035007be0e3574f35184acac1cd4530496" }

View File

@ -1,11 +1,17 @@
use std::sync::Arc;
use tokio::runtime::Runtime;
pub fn admin_subcommand( pub fn admin_subcommand(
runtime: Arc<Runtime>,
sub_m: &clap::ArgMatches, sub_m: &clap::ArgMatches,
server_settings: &server::Settings, server_settings: &server::Settings,
editable_settings: &mut server::EditableSettings, editable_settings: &mut server::EditableSettings,
data_dir: &std::path::Path, data_dir: &std::path::Path,
) { ) {
let login_provider = let login_provider = server::login_provider::LoginProvider::new(
server::login_provider::LoginProvider::new(server_settings.auth_server_address.clone()); server_settings.auth_server_address.clone(),
runtime,
);
match sub_m.subcommand() { match sub_m.subcommand() {
("add", Some(sub_m)) => { ("add", Some(sub_m)) => {

View File

@ -20,6 +20,9 @@ pub fn init(basic: bool) {
.add_directive("prometheus_hyper=info".parse().unwrap()) .add_directive("prometheus_hyper=info".parse().unwrap())
.add_directive("mio::pool=info".parse().unwrap()) .add_directive("mio::pool=info".parse().unwrap())
.add_directive("mio::sys::windows=debug".parse().unwrap()) .add_directive("mio::sys::windows=debug".parse().unwrap())
.add_directive("h2=info".parse().unwrap())
.add_directive("tokio_util=info".parse().unwrap())
.add_directive("rustls=debug".parse().unwrap())
.add_directive("veloren_network_protocol=info".parse().unwrap()) .add_directive("veloren_network_protocol=info".parse().unwrap())
.add_directive( .add_directive(
"veloren_server::persistence::character=info" "veloren_server::persistence::character=info"

View File

@ -92,6 +92,13 @@ fn main() -> io::Result<()> {
path path
}; };
let runtime = Arc::new(
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap(),
);
// Load server settings // Load server settings
let mut server_settings = server::Settings::load(&server_data_dir); let mut server_settings = server::Settings::load(&server_data_dir);
let mut editable_settings = server::EditableSettings::load(&server_data_dir); let mut editable_settings = server::EditableSettings::load(&server_data_dir);
@ -99,6 +106,7 @@ fn main() -> io::Result<()> {
match matches.subcommand() { match matches.subcommand() {
("admin", Some(sub_m)) => { ("admin", Some(sub_m)) => {
admin::admin_subcommand( admin::admin_subcommand(
runtime,
sub_m, sub_m,
&server_settings, &server_settings,
&mut editable_settings, &mut editable_settings,
@ -130,12 +138,6 @@ fn main() -> io::Result<()> {
let server_port = &server_settings.gameserver_address.port(); let server_port = &server_settings.gameserver_address.port();
let metrics_port = &server_settings.metrics_address.port(); let metrics_port = &server_settings.metrics_address.port();
// Create server // Create server
let runtime = Arc::new(
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap(),
);
let mut server = Server::new( let mut server = Server::new(
server_settings, server_settings,
editable_settings, editable_settings,

View File

@ -42,7 +42,7 @@ rayon = "1.5"
crossbeam-channel = "0.5" crossbeam-channel = "0.5"
prometheus = { version = "0.12", default-features = false} prometheus = { version = "0.12", default-features = false}
portpicker = { git = "https://github.com/xMAC94x/portpicker-rs", rev = "df6b37872f3586ac3b21d08b56c8ec7cd92fb172" } portpicker = { git = "https://github.com/xMAC94x/portpicker-rs", rev = "df6b37872f3586ac3b21d08b56c8ec7cd92fb172" }
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "bffb5181a35c19ddfd33ee0b4aedba741aafb68d" } authc = { git = "https://gitlab.com/veloren/auth.git", rev = "f3683798bc5ea656845010f9bae11b05dd671ece" }
libsqlite3-sys = { version = "0.18", features = ["bundled"] } libsqlite3-sys = { version = "0.18", features = ["bundled"] }
diesel = { version = "1.4.3", features = ["sqlite"] } diesel = { version = "1.4.3", features = ["sqlite"] }
diesel_migrations = "1.4.0" diesel_migrations = "1.4.0"

View File

@ -179,9 +179,10 @@ impl Server {
path: data_dir.to_owned(), path: data_dir.to_owned(),
}); });
state.ecs_mut().insert(EventBus::<ServerEvent>::default()); state.ecs_mut().insert(EventBus::<ServerEvent>::default());
state state.ecs_mut().insert(LoginProvider::new(
.ecs_mut() settings.auth_server_address.clone(),
.insert(LoginProvider::new(settings.auth_server_address.clone())); Arc::clone(&runtime),
));
state.ecs_mut().insert(HwStats { state.ecs_mut().insert(HwStats {
hardware_threads: num_cpus::get() as u32, hardware_threads: num_cpus::get() as u32,
rayon_threads: num_cpus::get() as u32, rayon_threads: num_cpus::get() as u32,
@ -222,6 +223,7 @@ impl Server {
state.ecs_mut().register::<Client>(); state.ecs_mut().register::<Client>();
state.ecs_mut().register::<Presence>(); state.ecs_mut().register::<Presence>();
state.ecs_mut().register::<comp::HomeChunk>(); state.ecs_mut().register::<comp::HomeChunk>();
state.ecs_mut().register::<login_provider::PendingLogin>();
//Alias validator //Alias validator
let banned_words_paths = &settings.banned_words_files; let banned_words_paths = &settings.banned_words_files;

View File

@ -1,17 +1,15 @@
use crate::settings::BanRecord; use crate::settings::BanRecord;
use authc::{AuthClient, AuthClientError, AuthToken, Uuid}; use authc::{AuthClient, AuthClientError, AuthToken, Uuid};
use common::{comp::Player, uid::UidAllocator};
use common_net::msg::RegisterError; use common_net::msg::RegisterError;
use common_sys::plugin::memory_manager::EcsWorld; use common_sys::plugin::memory_manager::EcsWorld;
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]
use common_sys::plugin::PluginMgr; use common_sys::plugin::PluginMgr;
use hashbrown::{HashMap, HashSet}; use hashbrown::{HashMap, HashSet};
use plugin_api::{ use plugin_api::event::{PlayerJoinEvent, PlayerJoinResult};
event::{PlayerJoinEvent, PlayerJoinResult}, use specs::Component;
Health, use specs_idvs::IdvStorage;
}; use std::{str::FromStr, sync::Arc};
use specs::{Entities, Read, ReadStorage, WriteStorage}; use tokio::{runtime::Runtime, sync::oneshot};
use std::str::FromStr;
use tracing::{error, info}; use tracing::{error, info};
fn derive_uuid(username: &str) -> Uuid { fn derive_uuid(username: &str) -> Uuid {
@ -25,19 +23,31 @@ fn derive_uuid(username: &str) -> Uuid {
Uuid::from_slice(&state.to_be_bytes()).unwrap() Uuid::from_slice(&state.to_be_bytes()).unwrap()
} }
/// derive Uuid for "singleplayer" is a pub fn
pub fn derive_singleplayer_uuid() -> Uuid { derive_uuid("singleplayer") }
pub struct PendingLogin {
pending_r: oneshot::Receiver<Result<(String, Uuid), RegisterError>>,
}
impl Component for PendingLogin {
type Storage = IdvStorage<Self>;
}
pub struct LoginProvider { pub struct LoginProvider {
runtime: Arc<Runtime>,
accounts: HashMap<Uuid, String>, accounts: HashMap<Uuid, String>,
auth_server: Option<AuthClient>, auth_server: Option<Arc<AuthClient>>,
} }
impl LoginProvider { impl LoginProvider {
pub fn new(auth_addr: Option<String>) -> Self { pub fn new(auth_addr: Option<String>, runtime: Arc<Runtime>) -> Self {
let auth_server = match auth_addr { tracing::trace!(?auth_addr, "Starting LoginProvider");
Some(addr) => Some(AuthClient::new(&addr).unwrap()), let auth_server = auth_addr
None => None, .map(|addr| Arc::new(AuthClient::new(authc::Authority::from_str(&addr).unwrap())));
};
Self { Self {
runtime,
accounts: HashMap::new(), accounts: HashMap::new(),
auth_server, auth_server,
} }
@ -59,54 +69,61 @@ impl LoginProvider {
}; };
} }
#[allow(clippy::too_many_arguments)] pub fn verify(&self, username_or_token: &str) -> PendingLogin {
pub fn try_login<'a>( let (pending_s, pending_r) = oneshot::channel();
match &self.auth_server {
// Token from auth server expected
Some(srv) => {
let srv = Arc::clone(srv);
let username_or_token = username_or_token.to_string();
self.runtime.spawn(async move {
let _ = pending_s.send(Self::query(srv, &username_or_token).await);
});
},
// Username is expected
None => {
let username = username_or_token;
let uuid = derive_uuid(username);
let _ = pending_s.send(Ok((username.to_string(), uuid)));
},
}
PendingLogin { pending_r }
}
pub fn try_login(
&mut self, &mut self,
username_or_token: &str, pending: &mut PendingLogin,
#[cfg(feature = "plugins")] entities: &Entities<'a>, #[cfg(feature = "plugins")] world: &EcsWorld,
#[cfg(feature = "plugins")] health_comp: &ReadStorage<'a, Health>,
#[cfg(feature = "plugins")] uid_comp: &ReadStorage<'a, common::uid::Uid>,
#[cfg(feature = "plugins")] player_comp: &WriteStorage<'a, Player>,
#[cfg(feature = "plugins")] uids_res: &Read<'a, UidAllocator>,
#[cfg(feature = "plugins")] plugin_manager: &PluginMgr, #[cfg(feature = "plugins")] plugin_manager: &PluginMgr,
admins: &HashSet<Uuid>, admins: &HashSet<Uuid>,
whitelist: &HashSet<Uuid>, whitelist: &HashSet<Uuid>,
banlist: &HashMap<Uuid, BanRecord>, banlist: &HashMap<Uuid, BanRecord>,
) -> Result<(String, Uuid), RegisterError> { ) -> Option<Result<(String, Uuid), RegisterError>> {
self match pending.pending_r.try_recv() {
// resolve user information Ok(Err(e)) => Some(Err(e)),
.query(username_or_token) Ok(Ok((username, uuid))) => {
// if found, check name against whitelist or if user is admin
.and_then(|(username, uuid)| {
// user cannot join if they are listed on the banlist
if let Some(ban_record) = banlist.get(&uuid) { if let Some(ban_record) = banlist.get(&uuid) {
// Pull reason string out of ban record and send a copy of it // Pull reason string out of ban record and send a copy of it
return Err(RegisterError::Banned(ban_record.reason.clone())); return Some(Err(RegisterError::Banned(ban_record.reason.clone())));
} }
// user can only join if he is admin, the whitelist is empty (everyone can join) // user can only join if he is admin, the whitelist is empty (everyone can join)
// or his name is in the whitelist // or his name is in the whitelist
if !whitelist.is_empty() && !whitelist.contains(&uuid) && !admins.contains(&uuid) { if !whitelist.is_empty() && !whitelist.contains(&uuid) && !admins.contains(&uuid) {
return Err(RegisterError::NotOnWhitelist); return Some(Err(RegisterError::NotOnWhitelist));
} }
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]
{ {
match plugin_manager.execute_event(&world, &PlayerJoinEvent {
let ecs_world = EcsWorld {
entities: &entities,
health: health_comp.into(),
uid: uid_comp.into(),
player: player_comp.into(),
uid_allocator: uids_res,
};
match plugin_manager.execute_event(&ecs_world, &PlayerJoinEvent {
player_name: username.clone(), player_name: username.clone(),
player_id: *uuid.as_bytes(), player_id: *uuid.as_bytes(),
}) { }) {
Ok(e) => { Ok(e) => {
for i in e.into_iter() { for i in e.into_iter() {
if let PlayerJoinResult::Kick(a) = i { if let PlayerJoinResult::Kick(a) = i {
return Err(RegisterError::Kicked(a)); return Some(Err(RegisterError::Kicked(a)));
} }
} }
}, },
@ -117,41 +134,42 @@ impl LoginProvider {
} }
// add the user to self.accounts // add the user to self.accounts
self.login(uuid, username.clone())?; match self.login(uuid, username.clone()) {
Ok(()) => Some(Ok((username, uuid))),
Ok((username, uuid)) Err(e) => Some(Err(e)),
}) }
},
Err(tokio::sync::oneshot::error::TryRecvError::Closed) => {
error!("channel got closed to early, this shouldn't happen");
Some(Err(RegisterError::AuthError(
"Internal Error verifying".to_string(),
)))
},
Err(tokio::sync::oneshot::error::TryRecvError::Empty) => None,
}
} }
pub fn query(&mut self, username_or_token: &str) -> Result<(String, Uuid), RegisterError> { async fn query(
// Based on whether auth server is provided or not we expect an username or srv: Arc<AuthClient>,
// token username_or_token: &str,
match &self.auth_server { ) -> Result<(String, Uuid), RegisterError> {
// Token from auth server expected
Some(srv) => {
info!(?username_or_token, "Validating token"); info!(?username_or_token, "Validating token");
// Parse token // Parse token
let token = AuthToken::from_str(username_or_token) let token = AuthToken::from_str(username_or_token)
.map_err(|e| RegisterError::AuthError(e.to_string()))?; .map_err(|e| RegisterError::AuthError(e.to_string()))?;
// Validate token // Validate token
let uuid = srv.validate(token)?; let uuid = srv.validate(token).await?;
let username = srv.uuid_to_username(uuid)?; let username = srv.uuid_to_username(uuid).await?;
Ok((username, uuid)) Ok((username, uuid))
},
// Username is expected
None => {
// Assume username was provided
let username = username_or_token;
let uuid = derive_uuid(username);
Ok((username.to_string(), uuid))
},
}
} }
pub fn username_to_uuid(&self, username: &str) -> Result<Uuid, AuthClientError> { pub fn username_to_uuid(&self, username: &str) -> Result<Uuid, AuthClientError> {
self.auth_server.as_ref().map_or_else( match &self.auth_server {
|| Ok(derive_uuid(username)), Some(srv) => {
|auth| auth.username_to_uuid(&username), //TODO: optimize
) self.runtime.block_on(srv.username_to_uuid(&username))
},
None => Ok(derive_uuid(username)),
}
} }
} }

View File

@ -49,7 +49,7 @@ impl Default for Settings {
Self { Self {
gameserver_address: SocketAddr::from(([0; 4], 14004)), gameserver_address: SocketAddr::from(([0; 4], 14004)),
metrics_address: SocketAddr::from(([0; 4], 14005)), metrics_address: SocketAddr::from(([0; 4], 14005)),
auth_server_address: Some("https://auth.veloren.net".into()), auth_server_address: Some("auth.veloren.net".into()),
world_seed: DEFAULT_WORLD_SEED, world_seed: DEFAULT_WORLD_SEED,
server_name: "Veloren Alpha".into(), server_name: "Veloren Alpha".into(),
max_players: 100, max_players: 100,
@ -202,13 +202,7 @@ impl EditableSettings {
server_description: ServerDescription("Who needs friends anyway?".into()), server_description: ServerDescription("Who needs friends anyway?".into()),
// TODO: Let the player choose if they want to use admin commands or not // TODO: Let the player choose if they want to use admin commands or not
admins: Admins( admins: Admins(
std::iter::once( std::iter::once(crate::login_provider::derive_singleplayer_uuid()).collect(),
// TODO: hacky
crate::login_provider::LoginProvider::new(None)
.username_to_uuid("singleplayer")
.unwrap(),
)
.collect(),
), ),
..load ..load
} }

View File

@ -1,5 +1,8 @@
use crate::{ use crate::{
client::Client, login_provider::LoginProvider, metrics::PlayerMetrics, EditableSettings, client::Client,
login_provider::{LoginProvider, PendingLogin},
metrics::PlayerMetrics,
EditableSettings,
}; };
use common::{ use common::{
comp::{Admin, Player, Stats}, comp::{Admin, Player, Stats},
@ -13,6 +16,9 @@ use common_net::msg::{
use hashbrown::HashMap; use hashbrown::HashMap;
use plugin_api::Health; use plugin_api::Health;
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, WriteExpect, WriteStorage}; use specs::{Entities, Join, Read, ReadExpect, ReadStorage, WriteExpect, WriteStorage};
use tracing::trace;
use common_sys::plugin::memory_manager::EcsWorld;
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]
use common_sys::plugin::PluginMgr; use common_sys::plugin::PluginMgr;
@ -29,6 +35,7 @@ impl<'a> System<'a> for Sys {
ReadStorage<'a, Uid>, ReadStorage<'a, Uid>,
ReadStorage<'a, Client>, ReadStorage<'a, Client>,
WriteStorage<'a, Player>, WriteStorage<'a, Player>,
WriteStorage<'a, PendingLogin>,
Read<'a, UidAllocator>, Read<'a, UidAllocator>,
Read<'a, PluginMgr>, Read<'a, PluginMgr>,
ReadStorage<'a, Stats>, ReadStorage<'a, Stats>,
@ -50,6 +57,7 @@ impl<'a> System<'a> for Sys {
uids, uids,
clients, clients,
mut players, mut players,
mut pending_logins,
uid_allocator, uid_allocator,
plugin_mgr, plugin_mgr,
stats, stats,
@ -75,31 +83,50 @@ impl<'a> System<'a> for Sys {
// List of new players to update player lists of all clients. // List of new players to update player lists of all clients.
let mut new_players = Vec::new(); let mut new_players = Vec::new();
// defer auth lockup
for (entity, client) in (&entities, &clients).join() { for (entity, client) in (&entities, &clients).join() {
let _ = super::try_recv_all(client, 0, |client, msg: ClientRegister| { let _ = super::try_recv_all(client, 0, |_, msg: ClientRegister| {
trace!(?msg.token_or_username, "defer auth lockup");
let pending = login_provider.verify(&msg.token_or_username);
let _ = pending_logins.insert(entity, pending);
Ok(())
});
}
let mut finished_pending = vec![];
for (entity, client, mut pending) in (&entities, &clients, &mut pending_logins).join() {
if let Err(e) = || -> std::result::Result<(), crate::error::Error> {
#[cfg(feature = "plugins")]
let ecs_world = EcsWorld {
entities: &entities,
health: (&health_comp).into(),
uid: (&uids).into(),
player: (&players).into(),
uid_allocator: &uid_allocator,
};
let (username, uuid) = match login_provider.try_login( let (username, uuid) = match login_provider.try_login(
&msg.token_or_username, &mut pending,
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]
&entities, &ecs_world,
#[cfg(feature = "plugins")]
&health_comp,
#[cfg(feature = "plugins")]
&uids,
#[cfg(feature = "plugins")]
&players,
#[cfg(feature = "plugins")]
&uid_allocator,
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]
&plugin_mgr, &plugin_mgr,
&*editable_settings.admins, &*editable_settings.admins,
&*editable_settings.whitelist, &*editable_settings.whitelist,
&*editable_settings.banlist, &*editable_settings.banlist,
) { ) {
Err(err) => { None => return Ok(()),
client.send(ServerRegisterAnswer::Err(err))?; Some(r) => {
finished_pending.push(entity);
trace!(?r, "pending login returned");
match r {
Err(e) => {
client.send(ServerRegisterAnswer::Err(e))?;
return Ok(()); return Ok(());
}, },
Ok((username, uuid)) => (username, uuid), Ok((username, uuid)) => (username, uuid),
}
},
}; };
let player = Player::new(username, uuid); let player = Player::new(username, uuid);
@ -133,9 +160,13 @@ impl<'a> System<'a> for Sys {
// Add to list to notify all clients of the new player // Add to list to notify all clients of the new player
new_players.push(entity); new_players.push(entity);
} }
Ok(()) Ok(())
}); }() {
tracing::trace!(?e, "failed to process register")
};
}
for e in finished_pending {
pending_logins.remove(e);
} }
// Handle new players. // Handle new players.

View File

@ -44,6 +44,9 @@ pub fn init(settings: &Settings) -> Vec<impl Drop> {
.add_directive("gfx_device_gl=warn".parse().unwrap()) .add_directive("gfx_device_gl=warn".parse().unwrap())
.add_directive("prometheus_hyper=warn".parse().unwrap()) .add_directive("prometheus_hyper=warn".parse().unwrap())
.add_directive("mio::sys::windows=debug".parse().unwrap()) .add_directive("mio::sys::windows=debug".parse().unwrap())
.add_directive("h2=info".parse().unwrap())
.add_directive("tokio_util=info".parse().unwrap())
.add_directive("rustls=debug".parse().unwrap())
.add_directive("veloren_network_protocol=info".parse().unwrap()) .add_directive("veloren_network_protocol=info".parse().unwrap())
.add_directive( .add_directive(
"veloren_server::persistence::character=info" "veloren_server::persistence::character=info"

View File

@ -186,18 +186,28 @@ impl PlayState for MainMenuState {
format!("{}: {}", localized_strings.get("common.error"), e) format!("{}: {}", localized_strings.get("common.error"), e)
}, },
client::Error::AuthClientError(e) => match e { client::Error::AuthClientError(e) => match e {
client::AuthClientError::InvalidUrl(e) => format!(
"{}: {}",
localized_strings.get("common.fatal_error"),
e
),
// TODO: remove parentheses // TODO: remove parentheses
client::AuthClientError::RequestError(e) => format!( client::AuthClientError::RequestError(e) => format!(
"{}: {}", "{}: {}",
localized_strings.get("main.login.failed_sending_request"), localized_strings.get("main.login.failed_sending_request"),
e e
), ),
client::AuthClientError::ServerError(_, e) => e, client::AuthClientError::JsonError(e) => format!(
"{}: {}",
localized_strings.get("main.login.failed_sending_request"),
e
),
client::AuthClientError::ServerError(_, e) => {
String::from_utf8_lossy(&e).to_string()
},
},
client::Error::AuthServerUrlInvalid(e) => {
format!(
"{}: https://{}",
localized_strings
.get("main.login.failed_auth_server_url_invalid"),
e
)
}, },
}, },
InitError::ClientCrashed => { InitError::ClientCrashed => {

View File

@ -526,10 +526,7 @@ impl Default for NetworkingSettings {
username: "".to_string(), username: "".to_string(),
servers: vec!["server.veloren.net".to_string()], servers: vec!["server.veloren.net".to_string()],
default_server: "server.veloren.net".to_string(), default_server: "server.veloren.net".to_string(),
trusted_auth_servers: ["https://auth.veloren.net"] trusted_auth_servers: ["auth.veloren.net"].iter().map(|s| s.to_string()).collect(),
.iter()
.map(|s| s.to_string())
.collect(),
} }
} }
} }