Compare commits
2 commits
renovate/a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ac7cb0ddee | |||
| 8d6a90df79 |
5 changed files with 46 additions and 43 deletions
51
Cargo.lock
generated
51
Cargo.lock
generated
|
|
@ -218,13 +218,13 @@ checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aes"
|
name = "aes"
|
||||||
version = "0.9.0"
|
version = "0.8.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "66bd29a732b644c0431c6140f370d097879203d79b80c94a6747ba0872adaef8"
|
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cipher 0.5.1",
|
"cfg-if",
|
||||||
"cpubits",
|
"cipher",
|
||||||
"cpufeatures 0.3.0",
|
"cpufeatures 0.2.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -521,7 +521,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e412e2cd0f2b2d93e02543ceae7917b3c70331573df19ee046bcbc35e45e87d7"
|
checksum = "e412e2cd0f2b2d93e02543ceae7917b3c70331573df19ee046bcbc35e45e87d7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cipher 0.4.4",
|
"cipher",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -586,7 +586,7 @@ 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 = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
|
checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cipher 0.4.4",
|
"cipher",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -645,17 +645,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-common 0.1.6",
|
"crypto-common 0.1.6",
|
||||||
"inout 0.1.4",
|
"inout",
|
||||||
]
|
|
||||||
|
|
||||||
[[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]]
|
[[package]]
|
||||||
|
|
@ -755,12 +745,6 @@ version = "0.8.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cpubits"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
|
|
@ -1990,15 +1974,6 @@ dependencies = [
|
||||||
"generic-array",
|
"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]]
|
[[package]]
|
||||||
name = "ipconfig"
|
name = "ipconfig"
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
|
|
@ -2577,6 +2552,15 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
|
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]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.114"
|
version = "0.9.114"
|
||||||
|
|
@ -2585,6 +2569,7 @@ checksum = "13ce1245cd07fcc4cfdb438f7507b0c7e4f3849a69fd84d52374c66d83741bb6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
|
"openssl-src",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ hex = "0.4.3"
|
||||||
thiserror = "2.0.11"
|
thiserror = "2.0.11"
|
||||||
bcrypt = "0.19.0"
|
bcrypt = "0.19.0"
|
||||||
sqlx = { version = "0.8.3", features = [ "runtime-tokio", "tls-native-tls", "postgres", "chrono", "ipnetwork" ] }
|
sqlx = { version = "0.8.3", features = [ "runtime-tokio", "tls-native-tls", "postgres", "chrono", "ipnetwork" ] }
|
||||||
aes = "0.9.0"
|
aes = "0.8.4"
|
||||||
hmac = "0.13.0"
|
hmac = "0.13.0"
|
||||||
md-5 = "0.11.0"
|
md-5 = "0.11.0"
|
||||||
cbc = "0.1.2"
|
cbc = "0.1.2"
|
||||||
|
|
@ -53,6 +53,6 @@ sha256 = "1.6.0"
|
||||||
p256 = "0.13.2"
|
p256 = "0.13.2"
|
||||||
k256 = "0.13.4"
|
k256 = "0.13.4"
|
||||||
dsa = "0.6.3"
|
dsa = "0.6.3"
|
||||||
openssl = "0.10.78"
|
openssl = {version = "0.10.78", features = ["vendored"]}
|
||||||
time = "0.3.47"
|
time = "0.3.47"
|
||||||
hickory-resolver = { version = "0.24", features = ["tokio-runtime"] }
|
hickory-resolver = { version = "0.24", features = ["tokio-runtime"] }
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
FROM rust:alpine as builder
|
FROM rust:alpine as builder
|
||||||
|
|
||||||
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld
|
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld perl make
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@ COPY . .
|
||||||
RUN touch src/main.rs
|
RUN touch src/main.rs
|
||||||
|
|
||||||
ENV SQLX_OFFLINE=true
|
ENV SQLX_OFFLINE=true
|
||||||
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
|
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
|
||||||
|
|
||||||
FROM scratch AS final
|
FROM scratch AS final
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ impl juniper::Context for Context {}
|
||||||
struct TokenInfo {
|
struct TokenInfo {
|
||||||
pid: i32,
|
pid: i32,
|
||||||
expire_date: NaiveDateTime,
|
expire_date: NaiveDateTime,
|
||||||
title_id: Option<String>
|
title_id: Option<String>,
|
||||||
|
token_type: i32
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(GraphQLObject)]
|
#[derive(GraphQLObject)]
|
||||||
|
|
@ -60,6 +61,16 @@ struct UserInfo {
|
||||||
mii_data: String,
|
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)]
|
#[derive(GraphQLObject)]
|
||||||
#[graphql(description = "User information from a username")]
|
#[graphql(description = "User information from a username")]
|
||||||
pub struct UserInfoWithPId {
|
pub struct UserInfoWithPId {
|
||||||
|
|
@ -96,13 +107,14 @@ impl Query {
|
||||||
pid: data.pid,
|
pid: data.pid,
|
||||||
expire_date: token_info.expires,
|
expire_date: token_info.expires,
|
||||||
title_id: token_info.title_id,
|
title_id: token_info.title_id,
|
||||||
|
token_type: token_info.token_type,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn user_from_token(
|
async fn user_from_token(
|
||||||
token_data: String,
|
token_data: String,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
) -> Option<UserInfo> {
|
) -> Option<TokenUserInfo> {
|
||||||
let data = match TokenData::decode(&token_data) {
|
let data = match TokenData::decode(&token_data) {
|
||||||
Some(data) => data,
|
Some(data) => data,
|
||||||
None => {
|
None => {
|
||||||
|
|
@ -111,6 +123,13 @@ 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!(
|
let user = match sqlx::query!(
|
||||||
"SELECT username, account_level, nex_password, mii_data FROM users WHERE pid = $1",
|
"SELECT username, account_level, nex_password, mii_data FROM users WHERE pid = $1",
|
||||||
data.pid
|
data.pid
|
||||||
|
|
@ -127,11 +146,12 @@ impl Query {
|
||||||
|
|
||||||
let nex_password = user.nex_password;
|
let nex_password = user.nex_password;
|
||||||
|
|
||||||
Some(UserInfo {
|
Some(TokenUserInfo {
|
||||||
username: user.username,
|
username: user.username,
|
||||||
account_level: user.account_level,
|
account_level: user.account_level,
|
||||||
nex_password,
|
nex_password,
|
||||||
mii_data: user.mii_data.replace('\n', "").replace('\r', ""),
|
mii_data: user.mii_data.replace('\n', "").replace('\r', ""),
|
||||||
|
token_type: token_info.token_type
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,6 @@ pub async fn get_service_token(pool: &State<Pool>, auth: Auth<true, false>) -> R
|
||||||
|
|
||||||
let token = create_token(pool, auth.pid, NEX_TOKEN, None).await;
|
let token = create_token(pool, auth.pid, NEX_TOKEN, None).await;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
Xml(
|
Xml(
|
||||||
ServiceToken{
|
ServiceToken{
|
||||||
|
|
@ -114,4 +112,4 @@ pub async fn get_nex_token(pool: &State<Pool>, auth: Auth<true, false>, game_ser
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue