Compare commits
2 commits
renovate/a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ac7cb0ddee | |||
| 8d6a90df79 |
5 changed files with 44 additions and 10 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
|
@ -607,6 +607,12 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg_aliases"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chacha20"
|
name = "chacha20"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
|
@ -2546,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"
|
||||||
|
|
@ -2554,6 +2569,7 @@ checksum = "13ce1245cd07fcc4cfdb438f7507b0c7e4f3849a69fd84d52374c66d83741bb6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
|
"openssl-src",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
@ -3905,7 +3921,7 @@ dependencies = [
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"rsa",
|
"rsa",
|
||||||
"serde",
|
"serde",
|
||||||
"sha1",
|
"sha1 0.10.6",
|
||||||
"sha2 0.10.9",
|
"sha2 0.10.9",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
|
|
|
||||||
|
|
@ -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