Skip to content

Commit 89df936

Browse files
committed
pair route middlewares with rc and matrix protocol
1 parent 00f58d9 commit 89df936

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

ee/packages/federation-matrix/src/api/_matrix/invite.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,18 @@ export const getMatrixInviteRoutes = (services: HomeserverServices) => {
355355
throw new Error('user not found not processing invite');
356356
}
357357

358-
const inviteEvent = await invite.processInvite(event, roomIdSchema.parse(roomId), eventIdSchema.parse(eventId), roomVersion);
358+
const authenticatedServer = c.get('authenticatedServer');
359+
if (!authenticatedServer) {
360+
throw new Error('Missing authenticated server from request');
361+
}
362+
363+
const inviteEvent = await invite.processInvite(
364+
event,
365+
roomIdSchema.parse(roomId),
366+
eventIdSchema.parse(eventId),
367+
roomVersion,
368+
authenticatedServer,
369+
);
359370

360371
setTimeout(
361372
() => {

ee/packages/federation-matrix/src/api/_matrix/rooms.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { HomeserverServices } from '@rocket.chat/federation-sdk';
22
import { Router } from '@rocket.chat/http-router';
33
import { ajv } from '@rocket.chat/rest-typings/dist/v1/Ajv';
44

5+
import { isAuthenticatedMiddleware } from '../middlewares/isAuthenticated';
6+
57
const PublicRoomsQuerySchema = {
68
type: 'object',
79
properties: {
@@ -122,9 +124,10 @@ const PublicRoomsPostBodySchema = {
122124
const isPublicRoomsPostBodyProps = ajv.compile(PublicRoomsPostBodySchema);
123125

124126
export const getMatrixRoomsRoutes = (services: HomeserverServices) => {
125-
const { state } = services;
127+
const { state, federationAuth } = services;
126128

127129
return new Router('/federation')
130+
.use(isAuthenticatedMiddleware(federationAuth))
128131
.get(
129132
'/v1/publicRooms',
130133
{

ee/packages/federation-matrix/src/api/_matrix/transactions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ export const getMatrixTransactionsRoutes = (services: HomeserverServices) => {
473473
tags: ['Federation'],
474474
license: ['federation'],
475475
},
476+
canAccessResourceMiddleware(federationAuth, 'room'),
476477
async (c) => {
477478
const roomId = c.req.param('roomId');
478479
const limit = Number(c.req.query('limit') || 100);

0 commit comments

Comments
 (0)