diff --git a/Cargo.lock b/Cargo.lock index fd6a9c5..981a2f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,13 +218,13 @@ checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aes" -version = "0.8.4" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +checksum = "66bd29a732b644c0431c6140f370d097879203d79b80c94a6747ba0872adaef8" dependencies = [ - "cfg-if", - "cipher", - "cpufeatures 0.2.17", + "cipher 0.5.1", + "cpubits", + "cpufeatures 0.3.0", ] [[package]] @@ -521,7 +521,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e412e2cd0f2b2d93e02543ceae7917b3c70331573df19ee046bcbc35e45e87d7" dependencies = [ "byteorder", - "cipher", + "cipher 0.4.4", ] [[package]] @@ -586,7 +586,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -645,7 +645,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common 0.1.6", - "inout", + "inout 0.1.4", +] + +[[package]] +name = "cipher" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e34d8227fe1ba289043aeb13792056ff80fd6de1a9f49137a5f499de8e8c78ea" +dependencies = [ + "crypto-common 0.2.1", + "inout 0.2.2", ] [[package]] @@ -745,6 +755,12 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "cpubits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -1974,6 +1990,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "inout" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" +dependencies = [ + "hybrid-array", +] + [[package]] name = "ipconfig" version = "0.3.4" @@ -2552,15 +2577,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" -[[package]] -name = "openssl-src" -version = "300.6.0+3.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e8cbfd3a4a8c8f089147fd7aaa33cf8c7450c4d09f8f80698a0cf093abeff4" -dependencies = [ - "cc", -] - [[package]] name = "openssl-sys" version = "0.9.114" @@ -2569,7 +2585,6 @@ checksum = "13ce1245cd07fcc4cfdb438f7507b0c7e4f3849a69fd84d52374c66d83741bb6" dependencies = [ "cc", "libc", - "openssl-src", "pkg-config", "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index efa0706..87468d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ hex = "0.4.3" thiserror = "2.0.11" bcrypt = "0.19.0" sqlx = { version = "0.8.3", features = [ "runtime-tokio", "tls-native-tls", "postgres", "chrono", "ipnetwork" ] } -aes = "0.8.4" +aes = "0.9.0" hmac = "0.13.0" md-5 = "0.11.0" cbc = "0.1.2" @@ -53,6 +53,6 @@ sha256 = "1.6.0" p256 = "0.13.2" k256 = "0.13.4" dsa = "0.6.3" -openssl = {version = "0.10.78", features = ["vendored"]} +openssl = "0.10.78" time = "0.3.47" hickory-resolver = { version = "0.24", features = ["tokio-runtime"] } diff --git a/Dockerfile b/Dockerfile index 7c1b107..d868a5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM rust:alpine as builder -RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld perl make +RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld WORKDIR /app @@ -16,7 +16,7 @@ COPY . . RUN touch src/main.rs ENV SQLX_OFFLINE=true -RUN RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld" cargo build --profile prod --target x86_64-unknown-linux-musl +RUN OPENSSL_LIB_DIR=/usr/lib OPENSSL_INCLUDE_DIR=/usr/include/openssl OPENSSL_STATIC=1 RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld" cargo build --profile prod --target x86_64-unknown-linux-musl FROM scratch AS final diff --git a/src/graphql/mod.rs b/src/graphql/mod.rs index b8ce114..633be82 100644 --- a/src/graphql/mod.rs +++ b/src/graphql/mod.rs @@ -48,8 +48,7 @@ impl juniper::Context for Context {} struct TokenInfo { pid: i32, expire_date: NaiveDateTime, - title_id: Option, - token_type: i32 + title_id: Option } #[derive(GraphQLObject)] @@ -61,16 +60,6 @@ struct UserInfo { mii_data: String, } -#[derive(GraphQLObject)] -#[graphql(description = "User information from a token")] -struct TokenUserInfo { - username: String, - account_level: i32, - nex_password: String, - mii_data: String, - token_type: i32, -} - #[derive(GraphQLObject)] #[graphql(description = "User information from a username")] pub struct UserInfoWithPId { @@ -107,14 +96,13 @@ impl Query { pid: data.pid, expire_date: token_info.expires, title_id: token_info.title_id, - token_type: token_info.token_type, }) } async fn user_from_token( token_data: String, context: &Context, - ) -> Option { + ) -> Option { let data = match TokenData::decode(&token_data) { Some(data) => data, None => { @@ -123,13 +111,6 @@ impl Query { } }; - let token_info = - sqlx::query!( - "select * from tokens where pid = $1 and token_id = $2 and random = $3", - data.pid, data.token_id, data.random - ). - fetch_one(&context.pool).await.ok()?; - let user = match sqlx::query!( "SELECT username, account_level, nex_password, mii_data FROM users WHERE pid = $1", data.pid @@ -146,12 +127,11 @@ impl Query { let nex_password = user.nex_password; - Some(TokenUserInfo { + Some(UserInfo { username: user.username, account_level: user.account_level, nex_password, mii_data: user.mii_data.replace('\n', "").replace('\r', ""), - token_type: token_info.token_type }) } diff --git a/src/nnid/provider.rs b/src/nnid/provider.rs index 973916a..a178b53 100644 --- a/src/nnid/provider.rs +++ b/src/nnid/provider.rs @@ -57,6 +57,8 @@ pub async fn get_service_token(pool: &State, auth: Auth) -> R let token = create_token(pool, auth.pid, NEX_TOKEN, None).await; + + Ok( Xml( ServiceToken{ @@ -112,4 +114,4 @@ pub async fn get_nex_token(pool: &State, auth: Auth, game_ser } ) ) -} +} \ No newline at end of file