403通过AEM Service路由的Edge Delivery GraphQL端点禁止出现错误

向AEM as a Cloud Service中的本机GraphQL端点发出POST请求 — 通过Adobe Edge交付服务路由的站点导致​ 403禁止访问 ​错误。 解决办法包括更新反向链接OSGi配置以明确允许GraphQL路径、受信任的主机模式和HTTP方法。

描述 description

环境

  • Adobe Experience Manager (AEM) as a Cloud Service — 站点
  • Adobe Edge Delivery Service (EDS)

问题/症状

在以下条件下,GraphQL POST请求成功:

  • 使用Postman或curl等工具直接访问发布域时。
  • 当请求源自本地前端开发环境时。

但是,通过Adobe Edge Delivery Service路由时,相同的请求会失败,并出现​ 403 Forbidden ​响应。 观察结果包括:

  • OPTIONS调用返回​ 200确定
  • POST调用返回​ 403禁止访问

配置已验证

已确认正确设置了以下配置:

  1. Dispatcher筛选器允许路径/content/cq:graphql/.*使用GET、POST和OPTIONS方法。
  2. 已将ReferrerFilterCORSFilterCSRFPreventionFilter的OSGi配置设置为允许GraphQL请求。
  3. 必需的标头(OriginHostContent-Type)存在且未清除。

解决方法 resolution

要解决此问题,请使用以下设置更新反向链接OSGi配置(org.apache.sling.security.impl.ReferrerFilter.cfg.json):

  1. 添加应允许的路径(allow.paths):

    • /content/cq:graphql/.*
  2. 使用正则表达式配置允许的主机以匹配域(allow.hosts.regexp):

    • https://.*\.adobe\.com(:443)?
    • https://.*\.adobe\.net(:443)?
    • https://.*\.workfront\.com(:443)?
    • https://.*\.workfront-dev\.com(:443)?
    • https://.*\.dev\.workfront\.tech(:443)?
    • https://.*\.aem\.live(:443)?
  3. 通过将filter.enabled设置为​ true ​启用筛选。

  4. 通过将allow.empty设置为​ true ​允许空反向链接。

  5. 指定允许的HTTP方法:

    • GET
    • POST
    • OPTIONS

示例反向链接OSGi配置

{
  "allow.paths": [
    "/content/cq:graphql/.*",

  ] ,
  "allow.hosts.regexp": [
    "https://.*\\.adobe\\.com(:443)?",
    "https://.*\\.adobe\\.net(:443)?",
    "https://.*\\.workfront\\.com(:443)?",
    "https://.*\\.workfront-dev\\.com(:443)?",
    "https://.*\\.dev\\.workfront\\.tech(:443)?",
    "https://.*\\.aem\\.live(:443)?"
  ] ,
  "filter.enabled": true,
  "allow.empty": true,
  "allow.methods": [ "GET", "POST", "OPTIONS"]
}

有关其他内容,请参阅此处的此社区讨论。

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f