diff --git a/apps/api/src/modules/resources/index.ts b/apps/api/src/modules/resources/index.ts index f0bff2f..facd64f 100644 --- a/apps/api/src/modules/resources/index.ts +++ b/apps/api/src/modules/resources/index.ts @@ -24,7 +24,7 @@ const PROFILE_TTL_SEC = 24 * 3600; const profileSig = (body: string) => createHmac('sha256', config.secretKey).update(`mail-profile:${body}`).digest('base64url'); const profileLink = (resourceId: string, childId: string, protocol: string) => { const body = Buffer.from(JSON.stringify({ r: resourceId, c: childId, p: protocol, x: Math.floor(Date.now() / 1000) + PROFILE_TTL_SEC })).toString('base64url'); - return `${config.baseUrl}/api/mail-profile/${body}.${profileSig(body)}`; + return `${config.baseUrl}/api/mail-profile?t=${body}.${profileSig(body)}`; // Query statt Pfad: Fastify begrenzt Pfadparameter auf 100 Zeichen }; function readProfileToken(token: string): { r: string; c: string; p: 'imap' | 'pop3' } | null { const [body, sig] = token.split('.'); if (!body || !sig) return null; @@ -266,8 +266,8 @@ export const resourcesModule: KcModule = { } catch (e) { return providerError(e); } }); /** Öffentlich (Token statt Anmeldung): holt das Apple-Profil beim Anbieter und liefert es per https aus. */ - app.get('/mail-profile/:token', { config: rl(30, '1 minute') }, async (req, reply) => { - const { token } = z.object({ token: z.string().min(10).max(600) }).parse(req.params); + app.get('/mail-profile', { config: rl(30, '1 minute') }, async (req, reply) => { + const { t: token } = z.object({ t: z.string().min(10).max(600) }).parse(req.query); const t = readProfileToken(token); if (!t) throw new AppError(404, 'LINK_INVALID', 'Der Link ist ungültig oder abgelaufen. Bitte die Verbindungsdaten im Kundencenter neu öffnen.'); const r = await loadResource(t.r); if (!r || !r.enabled || !childCaps(r).includes('children.read')) throw notFound();