|
| 1 | +/* |
| 2 | + * Copyright 2026 MA 01 - Wien Digital |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.cloudflight.pgk.proxy.invitation.adapter.inbound |
| 18 | + |
| 19 | +import org.springframework.http.HttpStatus |
| 20 | +import org.springframework.http.MediaType |
| 21 | +import org.springframework.http.ResponseEntity |
| 22 | +import org.springframework.web.bind.annotation.PathVariable |
| 23 | +import org.springframework.web.bind.annotation.PutMapping |
| 24 | +import org.springframework.web.bind.annotation.RequestMapping |
| 25 | +import org.springframework.web.bind.annotation.RestController |
| 26 | + |
| 27 | +/** |
| 28 | + * Disables the legacy federation invite endpoint (`/_matrix/federation/v1/invite`). Invitations |
| 29 | + * are only accepted via `/_matrix/federation/v2/invite` (see [InvitationController]); the v1 |
| 30 | + * route is permanently retired and always answers with 403 so no federated invite can reach |
| 31 | + * Synapse through it. |
| 32 | + */ |
| 33 | +@RestController |
| 34 | +@RequestMapping("/_matrix/federation/v1") |
| 35 | +class LegacyInviteController { |
| 36 | + |
| 37 | + @PutMapping("/invite/{roomId}/{eventId}") |
| 38 | + fun disabledInvitation( |
| 39 | + @PathVariable roomId: String, |
| 40 | + @PathVariable eventId: String, |
| 41 | + ): ResponseEntity<String> = |
| 42 | + ResponseEntity |
| 43 | + .status(HttpStatus.FORBIDDEN) |
| 44 | + .contentType(MediaType.APPLICATION_JSON) |
| 45 | + .body("""{"errcode": "M_FORBIDDEN", "error": "Legacy federation invite endpoint (v1) is disabled."}""") |
| 46 | +} |
0 commit comments