From d765055da83ee94546399f6348aee14d8427d462 Mon Sep 17 00:00:00 2001 From: THOMAS B Date: Fri, 24 May 2024 18:05:05 +0200 Subject: [PATCH] feat(auth): send real information on login (#470) * feat(auth): send real ip on login * feat(auth): send application name on login --- server/api/jellyfin.ts | 15 ++++++++++++--- server/routes/auth.ts | 8 +++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/server/api/jellyfin.ts b/server/api/jellyfin.ts index 3f7130f79..bab7ea725 100644 --- a/server/api/jellyfin.ts +++ b/server/api/jellyfin.ts @@ -104,9 +104,9 @@ class JellyfinAPI { let authHeaderVal = ''; if (this.authToken) { - authHeaderVal = `MediaBrowser Client="Overseerr", Device="Axios", DeviceId="${deviceId}", Version="10.8.0", Token="${authToken}"`; + authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${deviceId}", Version="10.8.0", Token="${authToken}"`; } else { - authHeaderVal = `MediaBrowser Client="Overseerr", Device="Axios", DeviceId="${deviceId}", Version="10.8.0"`; + authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${deviceId}", Version="10.8.0"`; } this.axios = axios.create({ @@ -121,14 +121,23 @@ class JellyfinAPI { public async login( Username?: string, - Password?: string + Password?: string, + ClientIP?: string ): Promise { try { + const headers = ClientIP + ? { + 'X-Forwarded-For': ClientIP, + } + : {}; const account = await this.axios.post( '/Users/AuthenticateByName', { Username: Username, Pw: Password, + }, + { + headers: headers, } ); diff --git a/server/routes/auth.ts b/server/routes/auth.ts index 9ef3ef7e4..c0f789a10 100644 --- a/server/routes/auth.ts +++ b/server/routes/auth.ts @@ -271,7 +271,13 @@ authRoutes.post('/jellyfin', async (req, res, next) => { ? jellyfinHost.slice(0, -1) : jellyfinHost; - const account = await jellyfinserver.login(body.username, body.password); + const ip = req.ip ? req.ip.split(':').reverse()[0] : undefined; + const account = await jellyfinserver.login( + body.username, + body.password, + ip + ); + // Next let's see if the user already exists user = await userRepository.findOne({ where: { jellyfinUserId: account.User.Id },