Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 50 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,59 @@ Browse to `http://localhost:8787/list` to ensure you see the expected buckets.

### Helix 6 request handling

Site-scoped requests, including config and version APIs, return `410 Gone` for
sites listed in `HLX6_MIGRATED_SITES`, an array of `org/site` entries (or a
JSON-encoded array). These sites must use `https://api.aem.live`; requests for
these sites do not access their legacy content. The check is a local
configuration lookup; no network probe is made.

Org-level requests, authentication, logout, and CORS preflight remain available.
Sites listed in `HLX6_MIGRATED_SITES`, an array of `org/site` entries (or a
JSON-encoded array or comma/newline-separated string), use a synchronous
compatibility bridge to `AEM_API` (`https://api.aem.live` by default). The site
check is local; no network probe is made.

The bridge supports:

- Source GET/HEAD, streaming bodies and returning ETag/Last-Modified. Matching
`If-None-Match` returns 304; `If-Match` read failures return 412.
- Site/folder GET listings, converted to DA item fields and hidden-file
filtering. HLX6 listings are unpaginated; a legacy continuation token on a
migrated site's listing is rejected.
- Org GET listings, merging legacy DA sites with the org's bridged HLX6 sites:
entries of `GET /{org}/source/` (caller token, 3s timeout) that are also in
`HLX6_MIGRATED_SITES`, filtered by DA ACLs. If the HLX6 listing fails
(outage, timeout, missing HLX6 role), the DA listing is still returned.
Only the first legacy page adds HLX6 sites; subsequent pages preserve the
DA continuation token without repeating them.
- Site editor-config GET and multipart PUT/POST (`config` field), converting
between DA sheet wrappers and `config/editor/da.json` row arrays. The whole
AEM site configuration is never replaced.
- Source multipart PUT/POST (`data` field) and raw uploads, converted to HLX6
POST, including its image-import behavior and validation. String `data`
fields are accepted for `.html`, `.json` and `.svg` only (415 otherwise).
Successful saves return DA's source/edit/preview/live URL envelope and the
upstream ETag. Bodyless folder writes become trailing-slash POSTs.
Upstream redirects are rejected with 502.

All requests retain existing DA ACL checks and require the caller's Bearer
token and the corresponding HLX6 permissions. There is no service-token
elevation, mutation retry, or fallback to writable legacy storage. Responses
are private/no-store. Legacy UUID and permission-hint headers are not invented:
`x-da-id`, `x-da-actions`, and `x-da-child-actions` are unavailable on bridged
site responses. DA ACLs and HLX6 roles must be configured separately.

Version/history APIs, copy/move/delete, dedicated media uploads, GUID-specified
uploads, collaborative writes, and extensionless file uploads remain
unsupported and return 410. Raw `/.versions` and `/.history` access through
source/list is blocked. Multiple-author token headers are rejected rather
than silently selecting an author. HTML transformations, validation, request
limits, and empty-document restore points are not identical to DA.

Org config, authentication, logout, and CORS preflight remain available locally.
The bridge does not change the HLX6 editor's org-config inheritance behavior.
Sites configured for dual write in `HLX6_DUAL_WRITES` retain normal DA behavior
during migration, even if they also appear in `HLX6_MIGRATED_SITES`.

The companion da-content change routes migrated sites through its `daadmin`
binding before direct-R2 allowlists and asset opt-outs. Configure the same
migration variables on both workers, and deploy the da-admin bridge first.
Content path/cookie handling remains on the legacy host; no browser redirect
or Library URL rewrite is required for supported source reads.

### Helix 6 migration (dual write)
Sites listed in the `HLX6_DUAL_WRITES` env variable are being migrated to Helix 6. Every successful modification on those sites (source create/update/delete, folder creation, copy, move, version creation) is also propagated, in the background, to the Helix 6 source bus at `AEM_API` (`https://api.aem.live`) using the caller's IMS token. Failures are logged but do not affect the DA response.

Expand Down
3 changes: 2 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export interface Env {
DA_OPS_IMS_BOT_EMAIL: string;
// hlx6 api service base URL (eg https://api.aem.live)
AEM_API?: string;
// migrated hlx6 sites, as "org/site". Legacy requests return 410 unless dual-writing.
// migrated hlx6 sites, as "org/site". Reads and saves use the hlx6 bridge;
// unsupported operations return 410 unless dual-writing.
HLX6_MIGRATED_SITES?: string[] | string;
// sites dual-writing to hlx6, as "org/site" or "org/site -> org2/site2".
// Modifications on these sites are propagated to the hlx6 source bus.
Expand Down
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import headHandler from './handlers/head.js';
import getHandler from './handlers/get.js';
import postHandler from './handlers/post.js';
import deleteHandler from './handlers/delete.js';
import { HLX6_GONE, initHlx6, isHlx6Site } from './utils/hlx6.js';
import { hasHlx6Sites, initHlx6, isHlx6Site } from './utils/hlx6.js';
import hlx6Handler, { listHlx6Org } from './routes/hlx6.js';

export default {
/**
Expand Down Expand Up @@ -76,7 +77,10 @@ export default {
// The key also identifies bare site roots, where daCtx.site is undefined.
const [site] = (key || '').split('/');
if (api !== 'login' && api !== 'logout' && isHlx6Site(env, org, site)) {
return daResp({ ...HLX6_GONE, body: req.method === 'HEAD' ? undefined : HLX6_GONE.body });
return await hlx6Handler({ req, env, daCtx });
}
if (api === 'list' && org && !key && req.method === 'GET' && hasHlx6Sites(env, org)) {
return await listHlx6Org({ req, env, daCtx });
}

switch (req.method) {
Expand Down
13 changes: 8 additions & 5 deletions src/routes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ import putKv from '../storage/kv/put.js';
import getKv from '../storage/kv/get.js';
import { configPermissionPath, hasPermission } from '../utils/auth.js';

// Config access is granted if the user has the action on the resource's own keyword
// (the per-site `/{site}/CONFIG`, or `CONFIG` for org config) OR on the org-level
// `CONFIG` keyword. The latter lets org admins manage any site's config; site rules
// (including `/{site}/**` wildcards) can grant additional access but never restrict it.
function hasConfigPermission(daCtx, action) {
/**
* Grants config access through either the resource CONFIG keyword or the org CONFIG keyword.
* Site rules can grant additional access but cannot restrict an org config administrator.
* @param {Object} daCtx DA context with the resource key, users and org-scoped ACLs.
* @param {string} action Required config action.
* @returns {boolean} Whether either config permission grants the action.
*/
export function hasConfigPermission(daCtx, action) {
return hasPermission(daCtx, configPermissionPath(daCtx), action, true)
|| hasPermission(daCtx, 'CONFIG', action, true);
}
Expand Down
3 changes: 2 additions & 1 deletion src/routes/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
import copyObject from '../storage/object/copy.js';
import copyHelper from '../helpers/copy.js';
import { hasPermission } from '../utils/auth.js';
import { syncCopy } from '../utils/hlx6.js';
import { HLX6_GONE, isHlx6Site, syncCopy } from '../utils/hlx6.js';

export default async function copyHandler({ req, env, daCtx }) {
const details = await copyHelper(req, daCtx);
if (details.error) return details.error;
if (!hasPermission(daCtx, details.source, 'read')
|| !hasPermission(daCtx, details.destination, 'write')) return { status: 403 };
if (isHlx6Site(env, daCtx.org, details.destination.split('/')[0])) return HLX6_GONE;
const resp = await copyObject(env, daCtx, details, false);
syncCopy({
req, env, daCtx, details, resp,
Expand Down
Loading
Loading