Merge pull request 'fix(jitsi): read session from stalwart auth context (OAuth mode)' (#1) from jitsi-oauth-session-fix into main
Publish Docker Image / prepare (push) Successful in 0s
Publish Docker Image / build (linux/amd64, ubuntu-latest) (push) Failing after 8s
Publish Docker Image / build (linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Publish Docker Image / merge (push) Canceled after 0s
Publish Docker Image / prepare (push) Successful in 0s
Publish Docker Image / build (linux/amd64, ubuntu-latest) (push) Failing after 8s
Publish Docker Image / build (linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Publish Docker Image / merge (push) Canceled after 0s
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
import { cookies } from 'next/headers';
|
|
||||||
import { createHmac } from 'node:crypto';
|
import { createHmac } from 'node:crypto';
|
||||||
import { decryptSession } from '@/lib/auth/crypto';
|
import { readStalwartAuthContext } from '@/lib/stalwart/auth-context';
|
||||||
import { sessionCookieName } from '@/lib/auth/session-cookie';
|
|
||||||
import { logger } from '@/lib/logger';
|
import { logger } from '@/lib/logger';
|
||||||
|
|
||||||
const JITSI_URL = (process.env.JITSI_URL || 'https://meet.src-advisory.com').replace(/\/+$/, '');
|
const JITSI_URL = (process.env.JITSI_URL || 'https://meet.src-advisory.com').replace(/\/+$/, '');
|
||||||
@@ -23,16 +21,14 @@ export async function POST(request: NextRequest) {
|
|||||||
return NextResponse.json({ error: 'Jitsi is not configured' }, { status: 503 });
|
return NextResponse.json({ error: 'Jitsi is not configured' }, { status: 503 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const cookieStore = await cookies();
|
// In OAuth/OIDC mode the session lives in the `jmap_stalwart_ctx` cookie
|
||||||
const sessionToken = cookieStore.get(sessionCookieName(0))?.value;
|
// (written by /api/auth/stalwart-context), not the basic-auth session
|
||||||
if (!sessionToken) {
|
// cookie. The username there is the primary identity email.
|
||||||
|
const ctx = await readStalwartAuthContext(0);
|
||||||
|
const email = ctx?.username;
|
||||||
|
if (!email) {
|
||||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||||
}
|
}
|
||||||
const session = decryptSession(sessionToken);
|
|
||||||
if (!session) {
|
|
||||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
||||||
}
|
|
||||||
const email = session.username;
|
|
||||||
|
|
||||||
const body = await request.json().catch(() => ({}));
|
const body = await request.json().catch(() => ({}));
|
||||||
const room = typeof body.room === 'string' ? body.room.trim() : '';
|
const room = typeof body.room === 'string' ? body.room.trim() : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user