my power's back
All checks were successful
Galvanic Corrosion Cross-Compile / build (push) Successful in 1m57s
All checks were successful
Galvanic Corrosion Cross-Compile / build (push) Successful in 1m57s
* Steam authentication * Profile events * Objective fixes for some rooms (reccenter, goldentrophy, etc) * Profile meta (displayname) somewhat works * Player socket subscriptions
This commit is contained in:
@@ -34,7 +34,7 @@ route.router.get('/me/haspassword',
|
||||
APIUtils.Authentication,
|
||||
APIUtils.AuthenticationType(AuthType.Game),
|
||||
|
||||
(rq, rs) => {
|
||||
(_rq, rs) => {
|
||||
rs.json(true);
|
||||
},
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import { z } from "zod";
|
||||
import { AuthType } from "../../data/users.ts";
|
||||
import { Redis } from "../../db.ts";
|
||||
import { validVersions } from "../api/versioncheck.ts";
|
||||
import { Steam } from "../../data/steam.ts";
|
||||
|
||||
const config = Config.getConfig();
|
||||
|
||||
@@ -53,9 +54,18 @@ interface RefreshRequest extends AuthBodyBase {
|
||||
refresh_token: string,
|
||||
grant_type: "refresh_token"
|
||||
}
|
||||
interface SteamPlatformParams {
|
||||
Ticket: string,
|
||||
AppId: string
|
||||
}
|
||||
|
||||
type TokenRequestBody = TokenRequest | RefreshRequest;
|
||||
|
||||
const SteamPlatformParamsSchema = z.object({
|
||||
Ticket: z.string(),
|
||||
AppId: z.literal('471710')
|
||||
});
|
||||
|
||||
const AuthBodyBaseSchema = z.object({
|
||||
grant_type: z.string(),
|
||||
client_id: z.string(),
|
||||
@@ -98,6 +108,7 @@ route.router.post("/token",
|
||||
APIUtils.Authentication,
|
||||
APIUtils.AuthenticationType(AuthType.Web),
|
||||
express.urlencoded({ extended: true }),
|
||||
APIUtils.logBody,
|
||||
APIUtils.validateRequestBody<AuthBodyBase>(TokenRequestBodySchema),
|
||||
|
||||
async (
|
||||
@@ -125,6 +136,7 @@ route.router.post("/token",
|
||||
!(rq.body.platform_id.length > 32),
|
||||
!(rq.body.time.length > 32),
|
||||
!(rq.body.asid.length > 32),
|
||||
SteamPlatformParamsSchema.safeParse(JSON.parse(rq.body.platform_auth)).success
|
||||
].includes(false);
|
||||
|
||||
if (!conditionsMet) {
|
||||
@@ -153,6 +165,16 @@ route.router.post("/token",
|
||||
targetAccount = parseInt(decodedToken.sub ? decodedToken.sub : "NaN");
|
||||
|
||||
}
|
||||
|
||||
const platformAuth = (JSON.parse(rq.body.platform_auth)) as SteamPlatformParams;
|
||||
|
||||
if (config.auth.steamkey) {
|
||||
const steamAuthed = await Steam.AuthenticateUserTicket(platformAuth.Ticket, rq.body.platform_id);
|
||||
if (!steamAuthed) {
|
||||
requestFailed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isNaN(targetAccount)) {
|
||||
requestFailed();
|
||||
|
||||
Reference in New Issue
Block a user