connect-link ("Połącz z IWSN") is a panel action: only from the site's own origin (adminSameOrigin), like connect and disconnect
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9ca563e2af
commit
be30812423
+1
-1
@@ -422,7 +422,7 @@ Routes (all four need the `admin` role: not logged in → 401, other role → 40
|
||||
| `GET /api/iapl/mail-relay/status` | the transport and the stored state; `?refresh=1` asks the service |
|
||||
| `POST /api/iapl/mail-relay/connect` | enrol now; with `{ token }` store a token issued by hand — only with `accessKeyField: true`, otherwise `403` |
|
||||
| `POST /api/iapl/mail-relay/disconnect` | give the token up |
|
||||
| `POST /api/iapl/mail-relay/connect-link` | "Połącz z IWSN": asks the service for the confirmation link (`POST /v1/connect`, enrolling first when there is no token) and answers it as `connectUrl` + `expiresAt`, `Cache-Control: no-store`; nothing is stored. Absent with `connectButton: false` (`RELAY_CONNECT_LINK_PATH`) |
|
||||
| `POST /api/iapl/mail-relay/connect-link` | "Połącz z IWSN": asks the service for the confirmation link (`POST /v1/connect`, enrolling first when there is no token) and answers it as `connectUrl` + `expiresAt`, `Cache-Control: no-store`; nothing is stored. Admin only, from the site's own origin (`adminSameOrigin`). Absent with `connectButton: false` (`RELAY_CONNECT_LINK_PATH`) |
|
||||
| `POST /api/iapl/mail-relay/confirm` | **public** — the service's call-back. `404` and no change unless the site itself started an enrolment in the last 5 minutes; **refused** calls are rate-limited (10 a minute per address, `mail.relay.confirmRateLimit`) — a call that carries the nonce is never turned away by the limit, so junk from the same address cannot keep the site from enrolling |
|
||||
|
||||
These are the first routes under `/api/iapl/`; the others stay under `/api/ipal/` until 2.0. The confirm path is
|
||||
|
||||
+2
-1
@@ -435,7 +435,8 @@ addition to real safeguards, not a replacement for them.
|
||||
## Panel actions only from the site's own origin (`adminSameOrigin`, 1.17.2)
|
||||
|
||||
The plugin's panel actions act with the panel's login cookie and read their body whatever its `Content-Type`
|
||||
says: `POST /api/iapl/mail-relay/connect` and `/disconnect` (the mail service), `/api/ipal/test-email`,
|
||||
says: `POST /api/iapl/mail-relay/connect`, `/connect-link` ("Połącz z IWSN", 1.18.0) and `/disconnect` (the mail
|
||||
service), `/api/ipal/test-email`,
|
||||
`/api/ipal/cookie-scan`, `/api/ipal/cookie-approval`, `/api/ipal/cookie-crawl`. A `text/plain` POST needs no CORS
|
||||
preflight, a page on a sibling subdomain is "same site" (the browser sends the `SameSite=Lax` cookie), and
|
||||
Payload's own CSRF list is empty unless `serverURL` or `csrf` is set. So before 1.17.2 such a page could make a
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { Config, Endpoint, PayloadRequest } from 'payload'
|
||||
import { COOKIE_APPROVAL_PATH } from '../consent/scanner/approval.js'
|
||||
import { COOKIE_CRAWL_PATH } from '../consent/scanner/crawl/config.js'
|
||||
import { COOKIE_SCAN_PATH } from '../consent/scanner/endpoint.js'
|
||||
import { RELAY_CONNECT_PATH, RELAY_DISCONNECT_PATH } from '../email/relay/constants.js'
|
||||
import { RELAY_CONNECT_LINK_PATH, RELAY_CONNECT_PATH, RELAY_DISCONNECT_PATH } from '../email/relay/constants.js'
|
||||
import { reportRefusedOrigin, requestFromOwnOrigin } from './totp/sameOrigin.js'
|
||||
|
||||
/**
|
||||
@@ -26,6 +26,7 @@ export type AdminSameOriginOption = {
|
||||
/** The panel actions the rule covers: method and path (relative to the API route). */
|
||||
export const ADMIN_POST_ENDPOINTS: ReadonlyArray<readonly ['post', string]> = [
|
||||
['post', RELAY_CONNECT_PATH],
|
||||
['post', RELAY_CONNECT_LINK_PATH],
|
||||
['post', RELAY_DISCONNECT_PATH],
|
||||
['post', '/ipal/test-email'],
|
||||
['post', COOKIE_SCAN_PATH],
|
||||
|
||||
@@ -21,7 +21,7 @@ const SECRET = 'JBSWY3DPEHPK3PXP'
|
||||
const PASSWORD = 'a-long-test-password-1'
|
||||
export const SIBLING = { origin: 'https://blog.site.example', 'sec-fetch-site': 'same-site' }
|
||||
/** Every panel action the rule covers (path under /api). */
|
||||
export const ACTIONS = ['/iapl/mail-relay/connect', '/iapl/mail-relay/disconnect', '/ipal/test-email', '/ipal/cookie-scan', '/ipal/cookie-approval', '/ipal/cookie-crawl']
|
||||
export const ACTIONS = ['/iapl/mail-relay/connect', '/iapl/mail-relay/connect-link', '/iapl/mail-relay/disconnect', '/ipal/test-email', '/ipal/cookie-scan', '/ipal/cookie-approval', '/ipal/cookie-crawl']
|
||||
|
||||
export function adminSite(adminSameOrigin?: false) {
|
||||
const state = {} as { cookie: string; payload: Payload; server: TestServer; warn: string[] }
|
||||
|
||||
Reference in New Issue
Block a user