Add legacy authentication and session routes

Introduces legacy endpoints for login, joinserver, and checkserver, along with their input validation schemas. Updates sessionsService with joinLegacyServer to support legacy session handling. This enables compatibility with legacy clients requiring these authentication flows.
This commit is contained in:
2025-12-28 23:19:38 +01:00
parent e8f58e63cd
commit 3cd42103e5
7 changed files with 139 additions and 0 deletions

36
routes/legacy/login.js Normal file
View File

@@ -0,0 +1,36 @@
const express = require("express")
const router = express.Router()
const crypto = require("crypto")
const authService = require("../../services/authService")
const sessionsService = require("../../services/sessionsService")
const logger = require("../../modules/logger")
router.all("/", async (req, res) => {
const { user, password } = { ...req.query, ...req.body }
try {
const result = await authService.authenticate({
identifier: user,
password,
clientToken: "",
requireUser: false
})
const profile = result.response.selectedProfile
const sessionId = crypto.randomBytes(16).toString("hex")
await sessionsService.registerLegacySession({
uuid: profile.id,
sessionId
})
logger.log(`Legacy Login: ${user}`, ["AUTH", "green"])
const timestamp = Date.now()
return res.send(`${timestamp}:deprecated:${profile.name}:${sessionId}:${profile.id}`)
} catch (err) {
return res.send("Bad login")
}
})
module.exports = router