@strapi/admin 5.50.2 → 5.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/admin/admin/src/pages/Settings/pages/Roles/components/Permissions.js +14 -6
  2. package/dist/admin/admin/src/pages/Settings/pages/Roles/components/Permissions.js.map +1 -1
  3. package/dist/admin/admin/src/pages/Settings/pages/Roles/components/Permissions.mjs +14 -6
  4. package/dist/admin/admin/src/pages/Settings/pages/Roles/components/Permissions.mjs.map +1 -1
  5. package/dist/admin/admin/src/utils/cookies.js +77 -2
  6. package/dist/admin/admin/src/utils/cookies.js.map +1 -1
  7. package/dist/admin/admin/src/utils/cookies.mjs +76 -3
  8. package/dist/admin/admin/src/utils/cookies.mjs.map +1 -1
  9. package/dist/admin/shared/utils/auth-cookie-domain.js +41 -0
  10. package/dist/admin/shared/utils/auth-cookie-domain.js.map +1 -0
  11. package/dist/admin/shared/utils/auth-cookie-domain.mjs +38 -0
  12. package/dist/admin/shared/utils/auth-cookie-domain.mjs.map +1 -0
  13. package/dist/admin/shared/utils/auth-cookie-name.js +2 -2
  14. package/dist/admin/shared/utils/auth-cookie-name.js.map +1 -1
  15. package/dist/admin/shared/utils/auth-cookie-name.mjs +2 -2
  16. package/dist/admin/shared/utils/auth-cookie-name.mjs.map +1 -1
  17. package/dist/admin/shared/utils/auth-cookie-path.js +39 -0
  18. package/dist/admin/shared/utils/auth-cookie-path.js.map +1 -0
  19. package/dist/admin/shared/utils/auth-cookie-path.mjs +36 -0
  20. package/dist/admin/shared/utils/auth-cookie-path.mjs.map +1 -0
  21. package/dist/admin/src/utils/cookies.d.ts +21 -0
  22. package/dist/ee/server/src/controllers/admin.d.ts.map +1 -1
  23. package/dist/ee/server/src/controllers/authentication-utils/middlewares.d.ts.map +1 -1
  24. package/dist/ee/server/src/services/auth.d.ts.map +1 -1
  25. package/dist/ee/server/src/services/user.d.ts.map +1 -1
  26. package/dist/server/ee/server/src/controllers/admin.js.map +1 -1
  27. package/dist/server/ee/server/src/controllers/admin.mjs.map +1 -1
  28. package/dist/server/ee/server/src/controllers/authentication-utils/middlewares.js +9 -3
  29. package/dist/server/ee/server/src/controllers/authentication-utils/middlewares.js.map +1 -1
  30. package/dist/server/ee/server/src/controllers/authentication-utils/middlewares.mjs +10 -4
  31. package/dist/server/ee/server/src/controllers/authentication-utils/middlewares.mjs.map +1 -1
  32. package/dist/server/ee/server/src/services/auth.js +5 -5
  33. package/dist/server/ee/server/src/services/auth.js.map +1 -1
  34. package/dist/server/ee/server/src/services/auth.mjs +5 -5
  35. package/dist/server/ee/server/src/services/auth.mjs.map +1 -1
  36. package/dist/server/ee/server/src/services/user.js +1 -0
  37. package/dist/server/ee/server/src/services/user.js.map +1 -1
  38. package/dist/server/ee/server/src/services/user.mjs +1 -0
  39. package/dist/server/ee/server/src/services/user.mjs.map +1 -1
  40. package/dist/server/server/src/content-types/User.js +6 -0
  41. package/dist/server/server/src/content-types/User.js.map +1 -1
  42. package/dist/server/server/src/content-types/User.mjs +6 -0
  43. package/dist/server/server/src/content-types/User.mjs.map +1 -1
  44. package/dist/server/server/src/controllers/authentication.js +12 -10
  45. package/dist/server/server/src/controllers/authentication.js.map +1 -1
  46. package/dist/server/server/src/controllers/authentication.mjs +10 -8
  47. package/dist/server/server/src/controllers/authentication.mjs.map +1 -1
  48. package/dist/server/server/src/routes/serve-admin-panel.js +17 -4
  49. package/dist/server/server/src/routes/serve-admin-panel.js.map +1 -1
  50. package/dist/server/server/src/routes/serve-admin-panel.mjs +17 -4
  51. package/dist/server/server/src/routes/serve-admin-panel.mjs.map +1 -1
  52. package/dist/server/server/src/services/auth.js +51 -6
  53. package/dist/server/server/src/services/auth.js.map +1 -1
  54. package/dist/server/server/src/services/auth.mjs +46 -6
  55. package/dist/server/server/src/services/auth.mjs.map +1 -1
  56. package/dist/server/server/src/services/index.js +1 -1
  57. package/dist/server/server/src/services/index.js.map +1 -1
  58. package/dist/server/server/src/services/user.js +1 -0
  59. package/dist/server/server/src/services/user.js.map +1 -1
  60. package/dist/server/server/src/services/user.mjs +1 -0
  61. package/dist/server/server/src/services/user.mjs.map +1 -1
  62. package/dist/server/shared/utils/auth-cookie-domain.js +41 -0
  63. package/dist/server/shared/utils/auth-cookie-domain.js.map +1 -0
  64. package/dist/server/shared/utils/auth-cookie-domain.mjs +38 -0
  65. package/dist/server/shared/utils/auth-cookie-domain.mjs.map +1 -0
  66. package/dist/server/shared/utils/auth-cookie-name.js +2 -2
  67. package/dist/server/shared/utils/auth-cookie-name.js.map +1 -1
  68. package/dist/server/shared/utils/auth-cookie-name.mjs +2 -2
  69. package/dist/server/shared/utils/auth-cookie-name.mjs.map +1 -1
  70. package/dist/server/shared/utils/auth-cookie-path.js +39 -0
  71. package/dist/server/shared/utils/auth-cookie-path.js.map +1 -0
  72. package/dist/server/shared/utils/auth-cookie-path.mjs +36 -0
  73. package/dist/server/shared/utils/auth-cookie-path.mjs.map +1 -0
  74. package/dist/server/shared/utils/session-auth.js +54 -3
  75. package/dist/server/shared/utils/session-auth.js.map +1 -1
  76. package/dist/server/shared/utils/session-auth.mjs +51 -4
  77. package/dist/server/shared/utils/session-auth.mjs.map +1 -1
  78. package/dist/server/src/content-types/User.d.ts +6 -0
  79. package/dist/server/src/content-types/User.d.ts.map +1 -1
  80. package/dist/server/src/content-types/index.d.ts +6 -0
  81. package/dist/server/src/content-types/index.d.ts.map +1 -1
  82. package/dist/server/src/controllers/authentication.d.ts.map +1 -1
  83. package/dist/server/src/domain/user.d.ts +1 -0
  84. package/dist/server/src/domain/user.d.ts.map +1 -1
  85. package/dist/server/src/index.d.ts +6 -0
  86. package/dist/server/src/index.d.ts.map +1 -1
  87. package/dist/server/src/routes/serve-admin-panel.d.ts.map +1 -1
  88. package/dist/server/src/services/auth.d.ts +18 -0
  89. package/dist/server/src/services/auth.d.ts.map +1 -1
  90. package/dist/server/src/services/index.d.ts.map +1 -1
  91. package/dist/server/src/services/user.d.ts.map +1 -1
  92. package/dist/shared/contracts/shared.d.ts +2 -1
  93. package/dist/shared/contracts/shared.d.ts.map +1 -1
  94. package/dist/shared/utils/__tests__/auth-cookie-domain.test.d.ts +1 -0
  95. package/dist/shared/utils/__tests__/auth-cookie-domain.test.d.ts.map +1 -0
  96. package/dist/shared/utils/__tests__/auth-cookie-path.test.d.ts +1 -0
  97. package/dist/shared/utils/__tests__/auth-cookie-path.test.d.ts.map +1 -0
  98. package/dist/shared/utils/auth-cookie-domain.d.ts +21 -0
  99. package/dist/shared/utils/auth-cookie-domain.d.ts.map +1 -0
  100. package/dist/shared/utils/auth-cookie-name.d.ts +1 -1
  101. package/dist/shared/utils/auth-cookie-name.d.ts.map +1 -1
  102. package/dist/shared/utils/auth-cookie-path.d.ts +17 -0
  103. package/dist/shared/utils/auth-cookie-path.d.ts.map +1 -0
  104. package/dist/shared/utils/session-auth.d.ts +15 -0
  105. package/dist/shared/utils/session-auth.d.ts.map +1 -1
  106. package/package.json +8 -8
@@ -1,11 +1,54 @@
1
1
  'use strict';
2
2
 
3
+ var authCookieDomain = require('../../../shared/utils/auth-cookie-domain.js');
3
4
  var authCookieName = require('../../../shared/utils/auth-cookie-name.js');
5
+ var authCookiePath = require('../../../shared/utils/auth-cookie-path.js');
4
6
 
5
7
  /**
6
8
  * Resolved once at module load: the build inlines `admin.auth.cookie.name`
7
9
  * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_NAME`.
8
10
  */ const AUTH_COOKIE_NAME = authCookieName.resolveAuthCookieName(process.env.STRAPI_ADMIN_AUTH_COOKIE_NAME);
11
+ /**
12
+ * Resolved once at module load: the build inlines `admin.auth.cookie.path`
13
+ * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_PATH`.
14
+ */ const AUTH_COOKIE_PATH = authCookiePath.resolveAuthCookiePath(process.env.STRAPI_ADMIN_AUTH_COOKIE_PATH);
15
+ /**
16
+ * Resolved once at module load: the build inlines `admin.auth.cookie.domain`
17
+ * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN`. `undefined` means the
18
+ * cookie is host-only.
19
+ */ const AUTH_COOKIE_DOMAIN = authCookieDomain.resolveAuthCookieDomain(process.env.STRAPI_ADMIN_AUTH_COOKIE_DOMAIN);
20
+ /** Paths previously used by the client for the access cookie; cleared on set/delete. */ const LEGACY_AUTH_COOKIE_PATHS = [
21
+ '/'
22
+ ];
23
+ const expireCookieAt = (name, path, domain)=>{
24
+ const domainAttr = domain ? `; Domain=${domain}` : '';
25
+ document.cookie = `${name}=; Path=${path}${domainAttr}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
26
+ };
27
+ /**
28
+ * Every `(path, domain)` key the access cookie may live under: the configured
29
+ * key plus the legacy-path and host-only variants written by older versions or
30
+ * previous configs. The browser cookie store keys entries by
31
+ * `(name, domain, path)`, so each combination is a distinct entry.
32
+ */ const cookieKeyMatrix = ()=>{
33
+ const paths = new Set([
34
+ AUTH_COOKIE_PATH,
35
+ ...LEGACY_AUTH_COOKIE_PATHS
36
+ ]);
37
+ const domains = new Set([
38
+ undefined,
39
+ AUTH_COOKIE_DOMAIN
40
+ ]);
41
+ const matrix = [];
42
+ for (const path of paths){
43
+ for (const domain of domains){
44
+ matrix.push({
45
+ path,
46
+ domain
47
+ });
48
+ }
49
+ }
50
+ return matrix;
51
+ };
9
52
  /**
10
53
  * Retrieves the value of a specified cookie.
11
54
  *
@@ -24,23 +67,55 @@ var authCookieName = require('../../../shared/utils/auth-cookie-name.js');
24
67
  };
25
68
  /**
26
69
  * Sets a cookie with the given name, value, and optional expiration time.
70
+ * Uses `admin.auth.cookie.path` and `admin.auth.cookie.domain` (both inlined
71
+ * at build time) so the access cookie stays scoped to the same path and domain
72
+ * as the httpOnly refresh cookie and the EE SSO access cookie. The cookie is
73
+ * marked `Secure` whenever the page is served over TLS.
27
74
  *
28
75
  * @param name - The name of the cookie.
29
76
  * @param value - The value of the cookie.
30
77
  * @param days - (Optional) Number of days until the cookie expires. If omitted, the cookie is a session cookie.
31
78
  */ const setCookie = (name, value, days)=>{
32
79
  let expires = '';
33
- document.cookie = `${name}=${encodeURIComponent(value)}; Path=/${expires}`;
80
+ // Expire every other key the cookie may live under (legacy Path=/, host-only
81
+ // copies written before a domain was configured). A stale same-name entry at
82
+ // an equal-length path sorts first in document.cookie by creation time
83
+ // (RFC 6265 §5.4), so leaving one behind would shadow the token written below.
84
+ for (const { path, domain } of cookieKeyMatrix()){
85
+ if (path !== AUTH_COOKIE_PATH || domain !== AUTH_COOKIE_DOMAIN) {
86
+ expireCookieAt(name, path, domain);
87
+ }
88
+ }
89
+ const domainAttr = AUTH_COOKIE_DOMAIN ? `; Domain=${AUTH_COOKIE_DOMAIN}` : '';
90
+ // Mark the token Secure when the page itself is served over TLS — the
91
+ // browser's own criterion — so it is never attached to plain-http requests.
92
+ // Expiry writes stay flag-free on purpose: deletion targets the (name,
93
+ // domain, path) key regardless of Secure, and from an http origin a
94
+ // flag-free write can still clear non-Secure entries (no origin can carry
95
+ // the Secure flag over http, and Secure entries are untouchable from there
96
+ // either way).
97
+ const secureAttr = window.location.protocol === 'https:' ? '; Secure' : '';
98
+ document.cookie = `${name}=${encodeURIComponent(value)}; Path=${AUTH_COOKIE_PATH}${domainAttr}${expires}${secureAttr}`;
34
99
  };
35
100
  /**
36
101
  * Deletes a cookie by setting its expiration date to a past date.
37
102
  *
103
+ * Expires every combination of {configured path, legacy Path=/} and
104
+ * {configured domain, host-only}. A `Domain`-scoped cookie is a distinct entry
105
+ * from a host-only one in the browser cookie store, so both must be cleared or
106
+ * remote logout leaves the EE SSO cookie (written with `Domain` by the server)
107
+ * behind, rehydrating a dead session into an infinite login redirect.
108
+ *
38
109
  * @param name - The name of the cookie to delete.
39
110
  */ const deleteCookie = (name)=>{
40
- document.cookie = `${name}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
111
+ for (const { path, domain } of cookieKeyMatrix()){
112
+ expireCookieAt(name, path, domain);
113
+ }
41
114
  };
42
115
 
116
+ exports.AUTH_COOKIE_DOMAIN = AUTH_COOKIE_DOMAIN;
43
117
  exports.AUTH_COOKIE_NAME = AUTH_COOKIE_NAME;
118
+ exports.AUTH_COOKIE_PATH = AUTH_COOKIE_PATH;
44
119
  exports.deleteCookie = deleteCookie;
45
120
  exports.getCookieValue = getCookieValue;
46
121
  exports.setCookie = setCookie;
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.js","sources":["../../../../../admin/src/utils/cookies.ts"],"sourcesContent":["import { resolveAuthCookieName } from '../../../shared/utils/auth-cookie-name';\n\n/**\n * Resolved once at module load: the build inlines `admin.auth.cookie.name`\n * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_NAME`.\n */\nexport const AUTH_COOKIE_NAME = resolveAuthCookieName(process.env.STRAPI_ADMIN_AUTH_COOKIE_NAME);\n\n/**\n * Retrieves the value of a specified cookie.\n *\n * @param name - The name of the cookie to retrieve.\n * @returns The decoded cookie value if found, otherwise null.\n */\nexport const getCookieValue = (name: string): string | null => {\n let result = null;\n const cookieArray = document.cookie.split(';');\n cookieArray.forEach((cookie) => {\n const [key, value] = cookie.split('=').map((item) => item.trim());\n if (key === name) {\n result = decodeURIComponent(value);\n }\n });\n return result;\n};\n\n/**\n * Sets a cookie with the given name, value, and optional expiration time.\n *\n * @param name - The name of the cookie.\n * @param value - The value of the cookie.\n * @param days - (Optional) Number of days until the cookie expires. If omitted, the cookie is a session cookie.\n */\nexport const setCookie = (name: string, value: string, days?: number): void => {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = `; Expires=${date.toUTCString()}`;\n }\n document.cookie = `${name}=${encodeURIComponent(value)}; Path=/${expires}`;\n};\n\n/**\n * Deletes a cookie by setting its expiration date to a past date.\n *\n * @param name - The name of the cookie to delete.\n */\nexport const deleteCookie = (name: string): void => {\n document.cookie = `${name}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;\n};\n"],"names":["AUTH_COOKIE_NAME","resolveAuthCookieName","process","env","STRAPI_ADMIN_AUTH_COOKIE_NAME","getCookieValue","name","result","cookieArray","document","cookie","split","forEach","key","value","map","item","trim","decodeURIComponent","setCookie","days","expires","encodeURIComponent","deleteCookie"],"mappings":";;;;AAEA;;;UAIaA,gBAAAA,GAAmBC,oCAAAA,CAAsBC,QAAQC,GAAG,CAACC,6BAA6B;AAE/F;;;;;IAMO,MAAMC,cAAAA,GAAiB,CAACC,IAAAA,GAAAA;AAC7B,IAAA,IAAIC,MAAAA,GAAS,IAAA;AACb,IAAA,MAAMC,WAAAA,GAAcC,QAAAA,CAASC,MAAM,CAACC,KAAK,CAAC,GAAA,CAAA;IAC1CH,WAAAA,CAAYI,OAAO,CAAC,CAACF,MAAAA,GAAAA;AACnB,QAAA,MAAM,CAACG,GAAAA,EAAKC,KAAAA,CAAM,GAAGJ,MAAAA,CAAOC,KAAK,CAAC,GAAA,CAAA,CAAKI,GAAG,CAAC,CAACC,IAAAA,GAASA,KAAKC,IAAI,EAAA,CAAA;AAC9D,QAAA,IAAIJ,QAAQP,IAAAA,EAAM;AAChBC,YAAAA,MAAAA,GAASW,kBAAAA,CAAmBJ,KAAAA,CAAAA;AAC9B,QAAA;AACF,IAAA,CAAA,CAAA;IACA,OAAOP,MAAAA;AACT;AAEA;;;;;;AAMC,IACM,MAAMY,SAAAA,GAAY,CAACb,MAAcQ,KAAAA,EAAeM,IAAAA,GAAAA;AACrD,IAAA,IAAIC,OAAAA,GAAU,EAAA;IAMdZ,QAAAA,CAASC,MAAM,GAAG,CAAA,EAAGJ,IAAAA,CAAK,CAAC,EAAEgB,kBAAAA,CAAmBR,KAAAA,CAAAA,CAAO,QAAQ,EAAEO,OAAAA,CAAAA,CAAS;AAC5E;AAEA;;;;IAKO,MAAME,YAAAA,GAAe,CAACjB,IAAAA,GAAAA;AAC3BG,IAAAA,QAAAA,CAASC,MAAM,GAAG,CAAA,EAAGJ,IAAAA,CAAK,iDAAiD,CAAC;AAC9E;;;;;;;"}
1
+ {"version":3,"file":"cookies.js","sources":["../../../../../admin/src/utils/cookies.ts"],"sourcesContent":["import { resolveAuthCookieDomain } from '../../../shared/utils/auth-cookie-domain';\nimport { resolveAuthCookieName } from '../../../shared/utils/auth-cookie-name';\nimport { resolveAuthCookiePath } from '../../../shared/utils/auth-cookie-path';\n\n/**\n * Resolved once at module load: the build inlines `admin.auth.cookie.name`\n * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_NAME`.\n */\nexport const AUTH_COOKIE_NAME = resolveAuthCookieName(process.env.STRAPI_ADMIN_AUTH_COOKIE_NAME);\n\n/**\n * Resolved once at module load: the build inlines `admin.auth.cookie.path`\n * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_PATH`.\n */\nexport const AUTH_COOKIE_PATH = resolveAuthCookiePath(process.env.STRAPI_ADMIN_AUTH_COOKIE_PATH);\n\n/**\n * Resolved once at module load: the build inlines `admin.auth.cookie.domain`\n * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN`. `undefined` means the\n * cookie is host-only.\n */\nexport const AUTH_COOKIE_DOMAIN = resolveAuthCookieDomain(\n process.env.STRAPI_ADMIN_AUTH_COOKIE_DOMAIN\n);\n\n/** Paths previously used by the client for the access cookie; cleared on set/delete. */\nconst LEGACY_AUTH_COOKIE_PATHS = ['/'] as const;\n\nconst expireCookieAt = (name: string, path: string, domain?: string): void => {\n const domainAttr = domain ? `; Domain=${domain}` : '';\n document.cookie = `${name}=; Path=${path}${domainAttr}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;\n};\n\n/**\n * Every `(path, domain)` key the access cookie may live under: the configured\n * key plus the legacy-path and host-only variants written by older versions or\n * previous configs. The browser cookie store keys entries by\n * `(name, domain, path)`, so each combination is a distinct entry.\n */\nconst cookieKeyMatrix = (): Array<{ path: string; domain: string | undefined }> => {\n const paths = new Set<string>([AUTH_COOKIE_PATH, ...LEGACY_AUTH_COOKIE_PATHS]);\n const domains = new Set<string | undefined>([undefined, AUTH_COOKIE_DOMAIN]);\n\n const matrix: Array<{ path: string; domain: string | undefined }> = [];\n for (const path of paths) {\n for (const domain of domains) {\n matrix.push({ path, domain });\n }\n }\n return matrix;\n};\n\n/**\n * Retrieves the value of a specified cookie.\n *\n * @param name - The name of the cookie to retrieve.\n * @returns The decoded cookie value if found, otherwise null.\n */\nexport const getCookieValue = (name: string): string | null => {\n let result = null;\n const cookieArray = document.cookie.split(';');\n cookieArray.forEach((cookie) => {\n const [key, value] = cookie.split('=').map((item) => item.trim());\n if (key === name) {\n result = decodeURIComponent(value);\n }\n });\n return result;\n};\n\n/**\n * Sets a cookie with the given name, value, and optional expiration time.\n * Uses `admin.auth.cookie.path` and `admin.auth.cookie.domain` (both inlined\n * at build time) so the access cookie stays scoped to the same path and domain\n * as the httpOnly refresh cookie and the EE SSO access cookie. The cookie is\n * marked `Secure` whenever the page is served over TLS.\n *\n * @param name - The name of the cookie.\n * @param value - The value of the cookie.\n * @param days - (Optional) Number of days until the cookie expires. If omitted, the cookie is a session cookie.\n */\nexport const setCookie = (name: string, value: string, days?: number): void => {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = `; Expires=${date.toUTCString()}`;\n }\n\n // Expire every other key the cookie may live under (legacy Path=/, host-only\n // copies written before a domain was configured). A stale same-name entry at\n // an equal-length path sorts first in document.cookie by creation time\n // (RFC 6265 §5.4), so leaving one behind would shadow the token written below.\n for (const { path, domain } of cookieKeyMatrix()) {\n if (path !== AUTH_COOKIE_PATH || domain !== AUTH_COOKIE_DOMAIN) {\n expireCookieAt(name, path, domain);\n }\n }\n\n const domainAttr = AUTH_COOKIE_DOMAIN ? `; Domain=${AUTH_COOKIE_DOMAIN}` : '';\n // Mark the token Secure when the page itself is served over TLS — the\n // browser's own criterion — so it is never attached to plain-http requests.\n // Expiry writes stay flag-free on purpose: deletion targets the (name,\n // domain, path) key regardless of Secure, and from an http origin a\n // flag-free write can still clear non-Secure entries (no origin can carry\n // the Secure flag over http, and Secure entries are untouchable from there\n // either way).\n const secureAttr = window.location.protocol === 'https:' ? '; Secure' : '';\n document.cookie = `${name}=${encodeURIComponent(value)}; Path=${AUTH_COOKIE_PATH}${domainAttr}${expires}${secureAttr}`;\n};\n\n/**\n * Deletes a cookie by setting its expiration date to a past date.\n *\n * Expires every combination of {configured path, legacy Path=/} and\n * {configured domain, host-only}. A `Domain`-scoped cookie is a distinct entry\n * from a host-only one in the browser cookie store, so both must be cleared or\n * remote logout leaves the EE SSO cookie (written with `Domain` by the server)\n * behind, rehydrating a dead session into an infinite login redirect.\n *\n * @param name - The name of the cookie to delete.\n */\nexport const deleteCookie = (name: string): void => {\n for (const { path, domain } of cookieKeyMatrix()) {\n expireCookieAt(name, path, domain);\n }\n};\n"],"names":["AUTH_COOKIE_NAME","resolveAuthCookieName","process","env","STRAPI_ADMIN_AUTH_COOKIE_NAME","AUTH_COOKIE_PATH","resolveAuthCookiePath","STRAPI_ADMIN_AUTH_COOKIE_PATH","AUTH_COOKIE_DOMAIN","resolveAuthCookieDomain","STRAPI_ADMIN_AUTH_COOKIE_DOMAIN","LEGACY_AUTH_COOKIE_PATHS","expireCookieAt","name","path","domain","domainAttr","document","cookie","cookieKeyMatrix","paths","Set","domains","undefined","matrix","push","getCookieValue","result","cookieArray","split","forEach","key","value","map","item","trim","decodeURIComponent","setCookie","days","expires","secureAttr","window","location","protocol","encodeURIComponent","deleteCookie"],"mappings":"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"}
@@ -1,9 +1,52 @@
1
+ import { resolveAuthCookieDomain } from '../../../shared/utils/auth-cookie-domain.mjs';
1
2
  import { resolveAuthCookieName } from '../../../shared/utils/auth-cookie-name.mjs';
3
+ import { resolveAuthCookiePath } from '../../../shared/utils/auth-cookie-path.mjs';
2
4
 
3
5
  /**
4
6
  * Resolved once at module load: the build inlines `admin.auth.cookie.name`
5
7
  * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_NAME`.
6
8
  */ const AUTH_COOKIE_NAME = resolveAuthCookieName(process.env.STRAPI_ADMIN_AUTH_COOKIE_NAME);
9
+ /**
10
+ * Resolved once at module load: the build inlines `admin.auth.cookie.path`
11
+ * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_PATH`.
12
+ */ const AUTH_COOKIE_PATH = resolveAuthCookiePath(process.env.STRAPI_ADMIN_AUTH_COOKIE_PATH);
13
+ /**
14
+ * Resolved once at module load: the build inlines `admin.auth.cookie.domain`
15
+ * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN`. `undefined` means the
16
+ * cookie is host-only.
17
+ */ const AUTH_COOKIE_DOMAIN = resolveAuthCookieDomain(process.env.STRAPI_ADMIN_AUTH_COOKIE_DOMAIN);
18
+ /** Paths previously used by the client for the access cookie; cleared on set/delete. */ const LEGACY_AUTH_COOKIE_PATHS = [
19
+ '/'
20
+ ];
21
+ const expireCookieAt = (name, path, domain)=>{
22
+ const domainAttr = domain ? `; Domain=${domain}` : '';
23
+ document.cookie = `${name}=; Path=${path}${domainAttr}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
24
+ };
25
+ /**
26
+ * Every `(path, domain)` key the access cookie may live under: the configured
27
+ * key plus the legacy-path and host-only variants written by older versions or
28
+ * previous configs. The browser cookie store keys entries by
29
+ * `(name, domain, path)`, so each combination is a distinct entry.
30
+ */ const cookieKeyMatrix = ()=>{
31
+ const paths = new Set([
32
+ AUTH_COOKIE_PATH,
33
+ ...LEGACY_AUTH_COOKIE_PATHS
34
+ ]);
35
+ const domains = new Set([
36
+ undefined,
37
+ AUTH_COOKIE_DOMAIN
38
+ ]);
39
+ const matrix = [];
40
+ for (const path of paths){
41
+ for (const domain of domains){
42
+ matrix.push({
43
+ path,
44
+ domain
45
+ });
46
+ }
47
+ }
48
+ return matrix;
49
+ };
7
50
  /**
8
51
  * Retrieves the value of a specified cookie.
9
52
  *
@@ -22,21 +65,51 @@ import { resolveAuthCookieName } from '../../../shared/utils/auth-cookie-name.mj
22
65
  };
23
66
  /**
24
67
  * Sets a cookie with the given name, value, and optional expiration time.
68
+ * Uses `admin.auth.cookie.path` and `admin.auth.cookie.domain` (both inlined
69
+ * at build time) so the access cookie stays scoped to the same path and domain
70
+ * as the httpOnly refresh cookie and the EE SSO access cookie. The cookie is
71
+ * marked `Secure` whenever the page is served over TLS.
25
72
  *
26
73
  * @param name - The name of the cookie.
27
74
  * @param value - The value of the cookie.
28
75
  * @param days - (Optional) Number of days until the cookie expires. If omitted, the cookie is a session cookie.
29
76
  */ const setCookie = (name, value, days)=>{
30
77
  let expires = '';
31
- document.cookie = `${name}=${encodeURIComponent(value)}; Path=/${expires}`;
78
+ // Expire every other key the cookie may live under (legacy Path=/, host-only
79
+ // copies written before a domain was configured). A stale same-name entry at
80
+ // an equal-length path sorts first in document.cookie by creation time
81
+ // (RFC 6265 §5.4), so leaving one behind would shadow the token written below.
82
+ for (const { path, domain } of cookieKeyMatrix()){
83
+ if (path !== AUTH_COOKIE_PATH || domain !== AUTH_COOKIE_DOMAIN) {
84
+ expireCookieAt(name, path, domain);
85
+ }
86
+ }
87
+ const domainAttr = AUTH_COOKIE_DOMAIN ? `; Domain=${AUTH_COOKIE_DOMAIN}` : '';
88
+ // Mark the token Secure when the page itself is served over TLS — the
89
+ // browser's own criterion — so it is never attached to plain-http requests.
90
+ // Expiry writes stay flag-free on purpose: deletion targets the (name,
91
+ // domain, path) key regardless of Secure, and from an http origin a
92
+ // flag-free write can still clear non-Secure entries (no origin can carry
93
+ // the Secure flag over http, and Secure entries are untouchable from there
94
+ // either way).
95
+ const secureAttr = window.location.protocol === 'https:' ? '; Secure' : '';
96
+ document.cookie = `${name}=${encodeURIComponent(value)}; Path=${AUTH_COOKIE_PATH}${domainAttr}${expires}${secureAttr}`;
32
97
  };
33
98
  /**
34
99
  * Deletes a cookie by setting its expiration date to a past date.
35
100
  *
101
+ * Expires every combination of {configured path, legacy Path=/} and
102
+ * {configured domain, host-only}. A `Domain`-scoped cookie is a distinct entry
103
+ * from a host-only one in the browser cookie store, so both must be cleared or
104
+ * remote logout leaves the EE SSO cookie (written with `Domain` by the server)
105
+ * behind, rehydrating a dead session into an infinite login redirect.
106
+ *
36
107
  * @param name - The name of the cookie to delete.
37
108
  */ const deleteCookie = (name)=>{
38
- document.cookie = `${name}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
109
+ for (const { path, domain } of cookieKeyMatrix()){
110
+ expireCookieAt(name, path, domain);
111
+ }
39
112
  };
40
113
 
41
- export { AUTH_COOKIE_NAME, deleteCookie, getCookieValue, setCookie };
114
+ export { AUTH_COOKIE_DOMAIN, AUTH_COOKIE_NAME, AUTH_COOKIE_PATH, deleteCookie, getCookieValue, setCookie };
42
115
  //# sourceMappingURL=cookies.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookies.mjs","sources":["../../../../../admin/src/utils/cookies.ts"],"sourcesContent":["import { resolveAuthCookieName } from '../../../shared/utils/auth-cookie-name';\n\n/**\n * Resolved once at module load: the build inlines `admin.auth.cookie.name`\n * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_NAME`.\n */\nexport const AUTH_COOKIE_NAME = resolveAuthCookieName(process.env.STRAPI_ADMIN_AUTH_COOKIE_NAME);\n\n/**\n * Retrieves the value of a specified cookie.\n *\n * @param name - The name of the cookie to retrieve.\n * @returns The decoded cookie value if found, otherwise null.\n */\nexport const getCookieValue = (name: string): string | null => {\n let result = null;\n const cookieArray = document.cookie.split(';');\n cookieArray.forEach((cookie) => {\n const [key, value] = cookie.split('=').map((item) => item.trim());\n if (key === name) {\n result = decodeURIComponent(value);\n }\n });\n return result;\n};\n\n/**\n * Sets a cookie with the given name, value, and optional expiration time.\n *\n * @param name - The name of the cookie.\n * @param value - The value of the cookie.\n * @param days - (Optional) Number of days until the cookie expires. If omitted, the cookie is a session cookie.\n */\nexport const setCookie = (name: string, value: string, days?: number): void => {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = `; Expires=${date.toUTCString()}`;\n }\n document.cookie = `${name}=${encodeURIComponent(value)}; Path=/${expires}`;\n};\n\n/**\n * Deletes a cookie by setting its expiration date to a past date.\n *\n * @param name - The name of the cookie to delete.\n */\nexport const deleteCookie = (name: string): void => {\n document.cookie = `${name}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;\n};\n"],"names":["AUTH_COOKIE_NAME","resolveAuthCookieName","process","env","STRAPI_ADMIN_AUTH_COOKIE_NAME","getCookieValue","name","result","cookieArray","document","cookie","split","forEach","key","value","map","item","trim","decodeURIComponent","setCookie","days","expires","encodeURIComponent","deleteCookie"],"mappings":";;AAEA;;;UAIaA,gBAAAA,GAAmBC,qBAAAA,CAAsBC,QAAQC,GAAG,CAACC,6BAA6B;AAE/F;;;;;IAMO,MAAMC,cAAAA,GAAiB,CAACC,IAAAA,GAAAA;AAC7B,IAAA,IAAIC,MAAAA,GAAS,IAAA;AACb,IAAA,MAAMC,WAAAA,GAAcC,QAAAA,CAASC,MAAM,CAACC,KAAK,CAAC,GAAA,CAAA;IAC1CH,WAAAA,CAAYI,OAAO,CAAC,CAACF,MAAAA,GAAAA;AACnB,QAAA,MAAM,CAACG,GAAAA,EAAKC,KAAAA,CAAM,GAAGJ,MAAAA,CAAOC,KAAK,CAAC,GAAA,CAAA,CAAKI,GAAG,CAAC,CAACC,IAAAA,GAASA,KAAKC,IAAI,EAAA,CAAA;AAC9D,QAAA,IAAIJ,QAAQP,IAAAA,EAAM;AAChBC,YAAAA,MAAAA,GAASW,kBAAAA,CAAmBJ,KAAAA,CAAAA;AAC9B,QAAA;AACF,IAAA,CAAA,CAAA;IACA,OAAOP,MAAAA;AACT;AAEA;;;;;;AAMC,IACM,MAAMY,SAAAA,GAAY,CAACb,MAAcQ,KAAAA,EAAeM,IAAAA,GAAAA;AACrD,IAAA,IAAIC,OAAAA,GAAU,EAAA;IAMdZ,QAAAA,CAASC,MAAM,GAAG,CAAA,EAAGJ,IAAAA,CAAK,CAAC,EAAEgB,kBAAAA,CAAmBR,KAAAA,CAAAA,CAAO,QAAQ,EAAEO,OAAAA,CAAAA,CAAS;AAC5E;AAEA;;;;IAKO,MAAME,YAAAA,GAAe,CAACjB,IAAAA,GAAAA;AAC3BG,IAAAA,QAAAA,CAASC,MAAM,GAAG,CAAA,EAAGJ,IAAAA,CAAK,iDAAiD,CAAC;AAC9E;;;;"}
1
+ {"version":3,"file":"cookies.mjs","sources":["../../../../../admin/src/utils/cookies.ts"],"sourcesContent":["import { resolveAuthCookieDomain } from '../../../shared/utils/auth-cookie-domain';\nimport { resolveAuthCookieName } from '../../../shared/utils/auth-cookie-name';\nimport { resolveAuthCookiePath } from '../../../shared/utils/auth-cookie-path';\n\n/**\n * Resolved once at module load: the build inlines `admin.auth.cookie.name`\n * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_NAME`.\n */\nexport const AUTH_COOKIE_NAME = resolveAuthCookieName(process.env.STRAPI_ADMIN_AUTH_COOKIE_NAME);\n\n/**\n * Resolved once at module load: the build inlines `admin.auth.cookie.path`\n * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_PATH`.\n */\nexport const AUTH_COOKIE_PATH = resolveAuthCookiePath(process.env.STRAPI_ADMIN_AUTH_COOKIE_PATH);\n\n/**\n * Resolved once at module load: the build inlines `admin.auth.cookie.domain`\n * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN`. `undefined` means the\n * cookie is host-only.\n */\nexport const AUTH_COOKIE_DOMAIN = resolveAuthCookieDomain(\n process.env.STRAPI_ADMIN_AUTH_COOKIE_DOMAIN\n);\n\n/** Paths previously used by the client for the access cookie; cleared on set/delete. */\nconst LEGACY_AUTH_COOKIE_PATHS = ['/'] as const;\n\nconst expireCookieAt = (name: string, path: string, domain?: string): void => {\n const domainAttr = domain ? `; Domain=${domain}` : '';\n document.cookie = `${name}=; Path=${path}${domainAttr}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;\n};\n\n/**\n * Every `(path, domain)` key the access cookie may live under: the configured\n * key plus the legacy-path and host-only variants written by older versions or\n * previous configs. The browser cookie store keys entries by\n * `(name, domain, path)`, so each combination is a distinct entry.\n */\nconst cookieKeyMatrix = (): Array<{ path: string; domain: string | undefined }> => {\n const paths = new Set<string>([AUTH_COOKIE_PATH, ...LEGACY_AUTH_COOKIE_PATHS]);\n const domains = new Set<string | undefined>([undefined, AUTH_COOKIE_DOMAIN]);\n\n const matrix: Array<{ path: string; domain: string | undefined }> = [];\n for (const path of paths) {\n for (const domain of domains) {\n matrix.push({ path, domain });\n }\n }\n return matrix;\n};\n\n/**\n * Retrieves the value of a specified cookie.\n *\n * @param name - The name of the cookie to retrieve.\n * @returns The decoded cookie value if found, otherwise null.\n */\nexport const getCookieValue = (name: string): string | null => {\n let result = null;\n const cookieArray = document.cookie.split(';');\n cookieArray.forEach((cookie) => {\n const [key, value] = cookie.split('=').map((item) => item.trim());\n if (key === name) {\n result = decodeURIComponent(value);\n }\n });\n return result;\n};\n\n/**\n * Sets a cookie with the given name, value, and optional expiration time.\n * Uses `admin.auth.cookie.path` and `admin.auth.cookie.domain` (both inlined\n * at build time) so the access cookie stays scoped to the same path and domain\n * as the httpOnly refresh cookie and the EE SSO access cookie. The cookie is\n * marked `Secure` whenever the page is served over TLS.\n *\n * @param name - The name of the cookie.\n * @param value - The value of the cookie.\n * @param days - (Optional) Number of days until the cookie expires. If omitted, the cookie is a session cookie.\n */\nexport const setCookie = (name: string, value: string, days?: number): void => {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = `; Expires=${date.toUTCString()}`;\n }\n\n // Expire every other key the cookie may live under (legacy Path=/, host-only\n // copies written before a domain was configured). A stale same-name entry at\n // an equal-length path sorts first in document.cookie by creation time\n // (RFC 6265 §5.4), so leaving one behind would shadow the token written below.\n for (const { path, domain } of cookieKeyMatrix()) {\n if (path !== AUTH_COOKIE_PATH || domain !== AUTH_COOKIE_DOMAIN) {\n expireCookieAt(name, path, domain);\n }\n }\n\n const domainAttr = AUTH_COOKIE_DOMAIN ? `; Domain=${AUTH_COOKIE_DOMAIN}` : '';\n // Mark the token Secure when the page itself is served over TLS — the\n // browser's own criterion — so it is never attached to plain-http requests.\n // Expiry writes stay flag-free on purpose: deletion targets the (name,\n // domain, path) key regardless of Secure, and from an http origin a\n // flag-free write can still clear non-Secure entries (no origin can carry\n // the Secure flag over http, and Secure entries are untouchable from there\n // either way).\n const secureAttr = window.location.protocol === 'https:' ? '; Secure' : '';\n document.cookie = `${name}=${encodeURIComponent(value)}; Path=${AUTH_COOKIE_PATH}${domainAttr}${expires}${secureAttr}`;\n};\n\n/**\n * Deletes a cookie by setting its expiration date to a past date.\n *\n * Expires every combination of {configured path, legacy Path=/} and\n * {configured domain, host-only}. A `Domain`-scoped cookie is a distinct entry\n * from a host-only one in the browser cookie store, so both must be cleared or\n * remote logout leaves the EE SSO cookie (written with `Domain` by the server)\n * behind, rehydrating a dead session into an infinite login redirect.\n *\n * @param name - The name of the cookie to delete.\n */\nexport const deleteCookie = (name: string): void => {\n for (const { path, domain } of cookieKeyMatrix()) {\n expireCookieAt(name, path, domain);\n }\n};\n"],"names":["AUTH_COOKIE_NAME","resolveAuthCookieName","process","env","STRAPI_ADMIN_AUTH_COOKIE_NAME","AUTH_COOKIE_PATH","resolveAuthCookiePath","STRAPI_ADMIN_AUTH_COOKIE_PATH","AUTH_COOKIE_DOMAIN","resolveAuthCookieDomain","STRAPI_ADMIN_AUTH_COOKIE_DOMAIN","LEGACY_AUTH_COOKIE_PATHS","expireCookieAt","name","path","domain","domainAttr","document","cookie","cookieKeyMatrix","paths","Set","domains","undefined","matrix","push","getCookieValue","result","cookieArray","split","forEach","key","value","map","item","trim","decodeURIComponent","setCookie","days","expires","secureAttr","window","location","protocol","encodeURIComponent","deleteCookie"],"mappings":"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"}
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Domain attribute of the admin auth (access) token cookie, configurable
5
+ * through `admin.auth.cookie.domain` (falling back to `admin.auth.domain`) so
6
+ * multiple Strapi instances under the same parent domain share, or stay
7
+ * isolated to, the intended host.
8
+ *
9
+ * Browser-safe single source for both sides of the handoff: the admin panel
10
+ * cannot read server config, so the build transports the config value into
11
+ * the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN` variable
12
+ * (see create-build-context.ts in @strapi/strapi); the server resolves the
13
+ * same config at runtime. Changing the domain requires an admin rebuild, like
14
+ * any other admin config change.
15
+ *
16
+ * Defaults to `undefined` (host-only cookie) to match the browser default and
17
+ * the refresh-cookie behaviour in `getRefreshCookieOptions` when no domain is
18
+ * configured. A host-only cookie and a `Domain`-scoped cookie are distinct
19
+ * entries in the browser cookie store, so set and delete must agree on the
20
+ * domain or logout leaves a colliding copy behind.
21
+ */ const DEFAULT_AUTH_COOKIE_DOMAIN = undefined;
22
+ const isValidCookieDomain = (domain)=>{
23
+ // RFC 6265 domain-av: a host name. No leading dot required, no scheme, no
24
+ // path, no port, and none of the control/attribute-separator characters.
25
+ return !/[\x00-\x1F\x7F;,\s/:]/.test(domain);
26
+ };
27
+ const resolveAuthCookieDomain = (configuredDomain, warn = console.warn)=>{
28
+ const cookieDomain = (configuredDomain || '').trim();
29
+ if (!cookieDomain) {
30
+ return DEFAULT_AUTH_COOKIE_DOMAIN;
31
+ }
32
+ if (!isValidCookieDomain(cookieDomain)) {
33
+ warn(`Ignoring invalid admin auth cookie domain "${cookieDomain}" (must be a bare host name); using a host-only cookie instead.`);
34
+ return DEFAULT_AUTH_COOKIE_DOMAIN;
35
+ }
36
+ return cookieDomain;
37
+ };
38
+
39
+ exports.DEFAULT_AUTH_COOKIE_DOMAIN = DEFAULT_AUTH_COOKIE_DOMAIN;
40
+ exports.resolveAuthCookieDomain = resolveAuthCookieDomain;
41
+ //# sourceMappingURL=auth-cookie-domain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-cookie-domain.js","sources":["../../../../shared/utils/auth-cookie-domain.ts"],"sourcesContent":["/**\n * Domain attribute of the admin auth (access) token cookie, configurable\n * through `admin.auth.cookie.domain` (falling back to `admin.auth.domain`) so\n * multiple Strapi instances under the same parent domain share, or stay\n * isolated to, the intended host.\n *\n * Browser-safe single source for both sides of the handoff: the admin panel\n * cannot read server config, so the build transports the config value into\n * the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN` variable\n * (see create-build-context.ts in @strapi/strapi); the server resolves the\n * same config at runtime. Changing the domain requires an admin rebuild, like\n * any other admin config change.\n *\n * Defaults to `undefined` (host-only cookie) to match the browser default and\n * the refresh-cookie behaviour in `getRefreshCookieOptions` when no domain is\n * configured. A host-only cookie and a `Domain`-scoped cookie are distinct\n * entries in the browser cookie store, so set and delete must agree on the\n * domain or logout leaves a colliding copy behind.\n */\nexport const DEFAULT_AUTH_COOKIE_DOMAIN = undefined;\n\nconst isValidCookieDomain = (domain: string): boolean => {\n // RFC 6265 domain-av: a host name. No leading dot required, no scheme, no\n // path, no port, and none of the control/attribute-separator characters.\n return !/[\\x00-\\x1F\\x7F;,\\s/:]/.test(domain);\n};\n\nexport const resolveAuthCookieDomain = (\n configuredDomain?: string,\n warn: (message: string) => void = console.warn\n): string | undefined => {\n const cookieDomain = (configuredDomain || '').trim();\n\n if (!cookieDomain) {\n return DEFAULT_AUTH_COOKIE_DOMAIN;\n }\n\n if (!isValidCookieDomain(cookieDomain)) {\n warn(\n `Ignoring invalid admin auth cookie domain \"${cookieDomain}\" (must be a bare host name); using a host-only cookie instead.`\n );\n return DEFAULT_AUTH_COOKIE_DOMAIN;\n }\n\n return cookieDomain;\n};\n"],"names":["DEFAULT_AUTH_COOKIE_DOMAIN","undefined","isValidCookieDomain","domain","test","resolveAuthCookieDomain","configuredDomain","warn","console","cookieDomain","trim"],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;IAmBO,MAAMA,0BAAAA,GAA6BC;AAE1C,MAAMC,sBAAsB,CAACC,MAAAA,GAAAA;;;IAG3B,OAAO,CAAC,uBAAA,CAAwBC,IAAI,CAACD,MAAAA,CAAAA;AACvC,CAAA;MAEaE,uBAAAA,GAA0B,CACrCC,gBAAAA,EACAC,IAAAA,GAAkCC,QAAQD,IAAI,GAAA;AAE9C,IAAA,MAAME,eAAe,CAACH,gBAAAA,IAAoB,EAAC,EAAGI,IAAI,EAAA;AAElD,IAAA,IAAI,CAACD,YAAAA,EAAc;QACjB,OAAOT,0BAAAA;AACT,IAAA;IAEA,IAAI,CAACE,oBAAoBO,YAAAA,CAAAA,EAAe;AACtCF,QAAAA,IAAAA,CACE,CAAC,2CAA2C,EAAEE,YAAAA,CAAa,+DAA+D,CAAC,CAAA;QAE7H,OAAOT,0BAAAA;AACT,IAAA;IAEA,OAAOS,YAAAA;AACT;;;;;"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Domain attribute of the admin auth (access) token cookie, configurable
3
+ * through `admin.auth.cookie.domain` (falling back to `admin.auth.domain`) so
4
+ * multiple Strapi instances under the same parent domain share, or stay
5
+ * isolated to, the intended host.
6
+ *
7
+ * Browser-safe single source for both sides of the handoff: the admin panel
8
+ * cannot read server config, so the build transports the config value into
9
+ * the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN` variable
10
+ * (see create-build-context.ts in @strapi/strapi); the server resolves the
11
+ * same config at runtime. Changing the domain requires an admin rebuild, like
12
+ * any other admin config change.
13
+ *
14
+ * Defaults to `undefined` (host-only cookie) to match the browser default and
15
+ * the refresh-cookie behaviour in `getRefreshCookieOptions` when no domain is
16
+ * configured. A host-only cookie and a `Domain`-scoped cookie are distinct
17
+ * entries in the browser cookie store, so set and delete must agree on the
18
+ * domain or logout leaves a colliding copy behind.
19
+ */ const DEFAULT_AUTH_COOKIE_DOMAIN = undefined;
20
+ const isValidCookieDomain = (domain)=>{
21
+ // RFC 6265 domain-av: a host name. No leading dot required, no scheme, no
22
+ // path, no port, and none of the control/attribute-separator characters.
23
+ return !/[\x00-\x1F\x7F;,\s/:]/.test(domain);
24
+ };
25
+ const resolveAuthCookieDomain = (configuredDomain, warn = console.warn)=>{
26
+ const cookieDomain = (configuredDomain || '').trim();
27
+ if (!cookieDomain) {
28
+ return DEFAULT_AUTH_COOKIE_DOMAIN;
29
+ }
30
+ if (!isValidCookieDomain(cookieDomain)) {
31
+ warn(`Ignoring invalid admin auth cookie domain "${cookieDomain}" (must be a bare host name); using a host-only cookie instead.`);
32
+ return DEFAULT_AUTH_COOKIE_DOMAIN;
33
+ }
34
+ return cookieDomain;
35
+ };
36
+
37
+ export { DEFAULT_AUTH_COOKIE_DOMAIN, resolveAuthCookieDomain };
38
+ //# sourceMappingURL=auth-cookie-domain.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-cookie-domain.mjs","sources":["../../../../shared/utils/auth-cookie-domain.ts"],"sourcesContent":["/**\n * Domain attribute of the admin auth (access) token cookie, configurable\n * through `admin.auth.cookie.domain` (falling back to `admin.auth.domain`) so\n * multiple Strapi instances under the same parent domain share, or stay\n * isolated to, the intended host.\n *\n * Browser-safe single source for both sides of the handoff: the admin panel\n * cannot read server config, so the build transports the config value into\n * the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN` variable\n * (see create-build-context.ts in @strapi/strapi); the server resolves the\n * same config at runtime. Changing the domain requires an admin rebuild, like\n * any other admin config change.\n *\n * Defaults to `undefined` (host-only cookie) to match the browser default and\n * the refresh-cookie behaviour in `getRefreshCookieOptions` when no domain is\n * configured. A host-only cookie and a `Domain`-scoped cookie are distinct\n * entries in the browser cookie store, so set and delete must agree on the\n * domain or logout leaves a colliding copy behind.\n */\nexport const DEFAULT_AUTH_COOKIE_DOMAIN = undefined;\n\nconst isValidCookieDomain = (domain: string): boolean => {\n // RFC 6265 domain-av: a host name. No leading dot required, no scheme, no\n // path, no port, and none of the control/attribute-separator characters.\n return !/[\\x00-\\x1F\\x7F;,\\s/:]/.test(domain);\n};\n\nexport const resolveAuthCookieDomain = (\n configuredDomain?: string,\n warn: (message: string) => void = console.warn\n): string | undefined => {\n const cookieDomain = (configuredDomain || '').trim();\n\n if (!cookieDomain) {\n return DEFAULT_AUTH_COOKIE_DOMAIN;\n }\n\n if (!isValidCookieDomain(cookieDomain)) {\n warn(\n `Ignoring invalid admin auth cookie domain \"${cookieDomain}\" (must be a bare host name); using a host-only cookie instead.`\n );\n return DEFAULT_AUTH_COOKIE_DOMAIN;\n }\n\n return cookieDomain;\n};\n"],"names":["DEFAULT_AUTH_COOKIE_DOMAIN","undefined","isValidCookieDomain","domain","test","resolveAuthCookieDomain","configuredDomain","warn","console","cookieDomain","trim"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;IAmBO,MAAMA,0BAAAA,GAA6BC;AAE1C,MAAMC,sBAAsB,CAACC,MAAAA,GAAAA;;;IAG3B,OAAO,CAAC,uBAAA,CAAwBC,IAAI,CAACD,MAAAA,CAAAA;AACvC,CAAA;MAEaE,uBAAAA,GAA0B,CACrCC,gBAAAA,EACAC,IAAAA,GAAkCC,QAAQD,IAAI,GAAA;AAE9C,IAAA,MAAME,eAAe,CAACH,gBAAAA,IAAoB,EAAC,EAAGI,IAAI,EAAA;AAElD,IAAA,IAAI,CAACD,YAAAA,EAAc;QACjB,OAAOT,0BAAAA;AACT,IAAA;IAEA,IAAI,CAACE,oBAAoBO,YAAAA,CAAAA,EAAe;AACtCF,QAAAA,IAAAA,CACE,CAAC,2CAA2C,EAAEE,YAAAA,CAAa,+DAA+D,CAAC,CAAA;QAE7H,OAAOT,0BAAAA;AACT,IAAA;IAEA,OAAOS,YAAAA;AACT;;;;"}
@@ -14,13 +14,13 @@
14
14
  */ const DEFAULT_AUTH_COOKIE_NAME = 'jwtToken';
15
15
  // RFC 6265 cookie-name token characters.
16
16
  const VALID_COOKIE_NAME = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
17
- const resolveAuthCookieName = (configuredName)=>{
17
+ const resolveAuthCookieName = (configuredName, warn = console.warn)=>{
18
18
  const cookieName = (configuredName || '').trim();
19
19
  if (!cookieName) {
20
20
  return DEFAULT_AUTH_COOKIE_NAME;
21
21
  }
22
22
  if (!VALID_COOKIE_NAME.test(cookieName)) {
23
- console.warn(`Ignoring invalid admin auth cookie name "${cookieName}" (must only contain RFC 6265 cookie-name characters); using "${DEFAULT_AUTH_COOKIE_NAME}" instead.`);
23
+ warn(`Ignoring invalid admin auth cookie name "${cookieName}" (must only contain RFC 6265 cookie-name characters); using "${DEFAULT_AUTH_COOKIE_NAME}" instead.`);
24
24
  return DEFAULT_AUTH_COOKIE_NAME;
25
25
  }
26
26
  return cookieName;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-cookie-name.js","sources":["../../../../shared/utils/auth-cookie-name.ts"],"sourcesContent":["/**\n * Name of the cookie holding the admin auth (access) token, configurable\n * through `admin.auth.cookie.name` so it cannot collide with a same-named\n * cookie set by another application on a shared parent domain.\n *\n * Browser-safe single source for both sides of the SSO handoff: the admin\n * panel cannot read server config, so the build transports the config value\n * into the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_NAME`\n * variable (see create-build-context.ts in @strapi/strapi); the server\n * resolves the same config at runtime. Renaming the cookie requires an admin\n * rebuild, like any other admin config change.\n */\nexport const DEFAULT_AUTH_COOKIE_NAME = 'jwtToken';\n\n// RFC 6265 cookie-name token characters.\nconst VALID_COOKIE_NAME = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\nexport const resolveAuthCookieName = (configuredName?: string): string => {\n const cookieName = (configuredName || '').trim();\n\n if (!cookieName) {\n return DEFAULT_AUTH_COOKIE_NAME;\n }\n\n if (!VALID_COOKIE_NAME.test(cookieName)) {\n console.warn(\n `Ignoring invalid admin auth cookie name \"${cookieName}\" (must only contain RFC 6265 cookie-name characters); using \"${DEFAULT_AUTH_COOKIE_NAME}\" instead.`\n );\n return DEFAULT_AUTH_COOKIE_NAME;\n }\n\n return cookieName;\n};\n"],"names":["DEFAULT_AUTH_COOKIE_NAME","VALID_COOKIE_NAME","resolveAuthCookieName","configuredName","cookieName","trim","test","console","warn"],"mappings":";;AAAA;;;;;;;;;;;IAYO,MAAMA,wBAAAA,GAA2B;AAExC;AACA,MAAMC,iBAAAA,GAAoB,gCAAA;AAEnB,MAAMC,wBAAwB,CAACC,cAAAA,GAAAA;AACpC,IAAA,MAAMC,aAAa,CAACD,cAAAA,IAAkB,EAAC,EAAGE,IAAI,EAAA;AAE9C,IAAA,IAAI,CAACD,UAAAA,EAAY;QACf,OAAOJ,wBAAAA;AACT,IAAA;AAEA,IAAA,IAAI,CAACC,iBAAAA,CAAkBK,IAAI,CAACF,UAAAA,CAAAA,EAAa;QACvCG,OAAAA,CAAQC,IAAI,CACV,CAAC,yCAAyC,EAAEJ,WAAW,8DAA8D,EAAEJ,wBAAAA,CAAyB,UAAU,CAAC,CAAA;QAE7J,OAAOA,wBAAAA;AACT,IAAA;IAEA,OAAOI,UAAAA;AACT;;;;;"}
1
+ {"version":3,"file":"auth-cookie-name.js","sources":["../../../../shared/utils/auth-cookie-name.ts"],"sourcesContent":["/**\n * Name of the cookie holding the admin auth (access) token, configurable\n * through `admin.auth.cookie.name` so it cannot collide with a same-named\n * cookie set by another application on a shared parent domain.\n *\n * Browser-safe single source for both sides of the SSO handoff: the admin\n * panel cannot read server config, so the build transports the config value\n * into the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_NAME`\n * variable (see create-build-context.ts in @strapi/strapi); the server\n * resolves the same config at runtime. Renaming the cookie requires an admin\n * rebuild, like any other admin config change.\n */\nexport const DEFAULT_AUTH_COOKIE_NAME = 'jwtToken';\n\n// RFC 6265 cookie-name token characters.\nconst VALID_COOKIE_NAME = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\nexport const resolveAuthCookieName = (\n configuredName?: string,\n warn: (message: string) => void = console.warn\n): string => {\n const cookieName = (configuredName || '').trim();\n\n if (!cookieName) {\n return DEFAULT_AUTH_COOKIE_NAME;\n }\n\n if (!VALID_COOKIE_NAME.test(cookieName)) {\n warn(\n `Ignoring invalid admin auth cookie name \"${cookieName}\" (must only contain RFC 6265 cookie-name characters); using \"${DEFAULT_AUTH_COOKIE_NAME}\" instead.`\n );\n return DEFAULT_AUTH_COOKIE_NAME;\n }\n\n return cookieName;\n};\n"],"names":["DEFAULT_AUTH_COOKIE_NAME","VALID_COOKIE_NAME","resolveAuthCookieName","configuredName","warn","console","cookieName","trim","test"],"mappings":";;AAAA;;;;;;;;;;;IAYO,MAAMA,wBAAAA,GAA2B;AAExC;AACA,MAAMC,iBAAAA,GAAoB,gCAAA;MAEbC,qBAAAA,GAAwB,CACnCC,cAAAA,EACAC,IAAAA,GAAkCC,QAAQD,IAAI,GAAA;AAE9C,IAAA,MAAME,aAAa,CAACH,cAAAA,IAAkB,EAAC,EAAGI,IAAI,EAAA;AAE9C,IAAA,IAAI,CAACD,UAAAA,EAAY;QACf,OAAON,wBAAAA;AACT,IAAA;AAEA,IAAA,IAAI,CAACC,iBAAAA,CAAkBO,IAAI,CAACF,UAAAA,CAAAA,EAAa;QACvCF,IAAAA,CACE,CAAC,yCAAyC,EAAEE,UAAAA,CAAW,8DAA8D,EAAEN,wBAAAA,CAAyB,UAAU,CAAC,CAAA;QAE7J,OAAOA,wBAAAA;AACT,IAAA;IAEA,OAAOM,UAAAA;AACT;;;;;"}
@@ -12,13 +12,13 @@
12
12
  */ const DEFAULT_AUTH_COOKIE_NAME = 'jwtToken';
13
13
  // RFC 6265 cookie-name token characters.
14
14
  const VALID_COOKIE_NAME = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
15
- const resolveAuthCookieName = (configuredName)=>{
15
+ const resolveAuthCookieName = (configuredName, warn = console.warn)=>{
16
16
  const cookieName = (configuredName || '').trim();
17
17
  if (!cookieName) {
18
18
  return DEFAULT_AUTH_COOKIE_NAME;
19
19
  }
20
20
  if (!VALID_COOKIE_NAME.test(cookieName)) {
21
- console.warn(`Ignoring invalid admin auth cookie name "${cookieName}" (must only contain RFC 6265 cookie-name characters); using "${DEFAULT_AUTH_COOKIE_NAME}" instead.`);
21
+ warn(`Ignoring invalid admin auth cookie name "${cookieName}" (must only contain RFC 6265 cookie-name characters); using "${DEFAULT_AUTH_COOKIE_NAME}" instead.`);
22
22
  return DEFAULT_AUTH_COOKIE_NAME;
23
23
  }
24
24
  return cookieName;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-cookie-name.mjs","sources":["../../../../shared/utils/auth-cookie-name.ts"],"sourcesContent":["/**\n * Name of the cookie holding the admin auth (access) token, configurable\n * through `admin.auth.cookie.name` so it cannot collide with a same-named\n * cookie set by another application on a shared parent domain.\n *\n * Browser-safe single source for both sides of the SSO handoff: the admin\n * panel cannot read server config, so the build transports the config value\n * into the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_NAME`\n * variable (see create-build-context.ts in @strapi/strapi); the server\n * resolves the same config at runtime. Renaming the cookie requires an admin\n * rebuild, like any other admin config change.\n */\nexport const DEFAULT_AUTH_COOKIE_NAME = 'jwtToken';\n\n// RFC 6265 cookie-name token characters.\nconst VALID_COOKIE_NAME = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\nexport const resolveAuthCookieName = (configuredName?: string): string => {\n const cookieName = (configuredName || '').trim();\n\n if (!cookieName) {\n return DEFAULT_AUTH_COOKIE_NAME;\n }\n\n if (!VALID_COOKIE_NAME.test(cookieName)) {\n console.warn(\n `Ignoring invalid admin auth cookie name \"${cookieName}\" (must only contain RFC 6265 cookie-name characters); using \"${DEFAULT_AUTH_COOKIE_NAME}\" instead.`\n );\n return DEFAULT_AUTH_COOKIE_NAME;\n }\n\n return cookieName;\n};\n"],"names":["DEFAULT_AUTH_COOKIE_NAME","VALID_COOKIE_NAME","resolveAuthCookieName","configuredName","cookieName","trim","test","console","warn"],"mappings":"AAAA;;;;;;;;;;;IAYO,MAAMA,wBAAAA,GAA2B;AAExC;AACA,MAAMC,iBAAAA,GAAoB,gCAAA;AAEnB,MAAMC,wBAAwB,CAACC,cAAAA,GAAAA;AACpC,IAAA,MAAMC,aAAa,CAACD,cAAAA,IAAkB,EAAC,EAAGE,IAAI,EAAA;AAE9C,IAAA,IAAI,CAACD,UAAAA,EAAY;QACf,OAAOJ,wBAAAA;AACT,IAAA;AAEA,IAAA,IAAI,CAACC,iBAAAA,CAAkBK,IAAI,CAACF,UAAAA,CAAAA,EAAa;QACvCG,OAAAA,CAAQC,IAAI,CACV,CAAC,yCAAyC,EAAEJ,WAAW,8DAA8D,EAAEJ,wBAAAA,CAAyB,UAAU,CAAC,CAAA;QAE7J,OAAOA,wBAAAA;AACT,IAAA;IAEA,OAAOI,UAAAA;AACT;;;;"}
1
+ {"version":3,"file":"auth-cookie-name.mjs","sources":["../../../../shared/utils/auth-cookie-name.ts"],"sourcesContent":["/**\n * Name of the cookie holding the admin auth (access) token, configurable\n * through `admin.auth.cookie.name` so it cannot collide with a same-named\n * cookie set by another application on a shared parent domain.\n *\n * Browser-safe single source for both sides of the SSO handoff: the admin\n * panel cannot read server config, so the build transports the config value\n * into the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_NAME`\n * variable (see create-build-context.ts in @strapi/strapi); the server\n * resolves the same config at runtime. Renaming the cookie requires an admin\n * rebuild, like any other admin config change.\n */\nexport const DEFAULT_AUTH_COOKIE_NAME = 'jwtToken';\n\n// RFC 6265 cookie-name token characters.\nconst VALID_COOKIE_NAME = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\nexport const resolveAuthCookieName = (\n configuredName?: string,\n warn: (message: string) => void = console.warn\n): string => {\n const cookieName = (configuredName || '').trim();\n\n if (!cookieName) {\n return DEFAULT_AUTH_COOKIE_NAME;\n }\n\n if (!VALID_COOKIE_NAME.test(cookieName)) {\n warn(\n `Ignoring invalid admin auth cookie name \"${cookieName}\" (must only contain RFC 6265 cookie-name characters); using \"${DEFAULT_AUTH_COOKIE_NAME}\" instead.`\n );\n return DEFAULT_AUTH_COOKIE_NAME;\n }\n\n return cookieName;\n};\n"],"names":["DEFAULT_AUTH_COOKIE_NAME","VALID_COOKIE_NAME","resolveAuthCookieName","configuredName","warn","console","cookieName","trim","test"],"mappings":"AAAA;;;;;;;;;;;IAYO,MAAMA,wBAAAA,GAA2B;AAExC;AACA,MAAMC,iBAAAA,GAAoB,gCAAA;MAEbC,qBAAAA,GAAwB,CACnCC,cAAAA,EACAC,IAAAA,GAAkCC,QAAQD,IAAI,GAAA;AAE9C,IAAA,MAAME,aAAa,CAACH,cAAAA,IAAkB,EAAC,EAAGI,IAAI,EAAA;AAE9C,IAAA,IAAI,CAACD,UAAAA,EAAY;QACf,OAAON,wBAAAA;AACT,IAAA;AAEA,IAAA,IAAI,CAACC,iBAAAA,CAAkBO,IAAI,CAACF,UAAAA,CAAAA,EAAa;QACvCF,IAAAA,CACE,CAAC,yCAAyC,EAAEE,UAAAA,CAAW,8DAA8D,EAAEN,wBAAAA,CAAyB,UAAU,CAAC,CAAA;QAE7J,OAAOA,wBAAAA;AACT,IAAA;IAEA,OAAOM,UAAAA;AACT;;;;"}
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Path attribute of the admin auth (access) token cookie, configurable
5
+ * through `admin.auth.cookie.path` so multiple Strapi instances on the same
6
+ * parent domain can keep separate cookies (e.g. `/strapi-de/admin`).
7
+ *
8
+ * Browser-safe single source for both sides of the handoff: the admin panel
9
+ * cannot read server config, so the build transports the config value into
10
+ * the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_PATH` variable
11
+ * (see create-build-context.ts in @strapi/strapi); the server resolves the
12
+ * same config at runtime. Changing the path requires an admin rebuild, like
13
+ * any other admin config change.
14
+ *
15
+ * Defaults to `/admin` to match the refresh-cookie path used by
16
+ * `getRefreshCookieOptions`.
17
+ */ const DEFAULT_AUTH_COOKIE_PATH = '/admin';
18
+ const isValidCookiePath = (path)=>{
19
+ if (!path.startsWith('/')) {
20
+ return false;
21
+ }
22
+ // RFC 6265 path-av: any CHAR except CTLs or ";".
23
+ return !/[\x00-\x1F\x7F;]/.test(path);
24
+ };
25
+ const resolveAuthCookiePath = (configuredPath, warn = console.warn)=>{
26
+ const cookiePath = (configuredPath || '').trim();
27
+ if (!cookiePath) {
28
+ return DEFAULT_AUTH_COOKIE_PATH;
29
+ }
30
+ if (!isValidCookiePath(cookiePath)) {
31
+ warn(`Ignoring invalid admin auth cookie path "${cookiePath}" (must be an absolute path without ";"); using "${DEFAULT_AUTH_COOKIE_PATH}" instead.`);
32
+ return DEFAULT_AUTH_COOKIE_PATH;
33
+ }
34
+ return cookiePath;
35
+ };
36
+
37
+ exports.DEFAULT_AUTH_COOKIE_PATH = DEFAULT_AUTH_COOKIE_PATH;
38
+ exports.resolveAuthCookiePath = resolveAuthCookiePath;
39
+ //# sourceMappingURL=auth-cookie-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-cookie-path.js","sources":["../../../../shared/utils/auth-cookie-path.ts"],"sourcesContent":["/**\n * Path attribute of the admin auth (access) token cookie, configurable\n * through `admin.auth.cookie.path` so multiple Strapi instances on the same\n * parent domain can keep separate cookies (e.g. `/strapi-de/admin`).\n *\n * Browser-safe single source for both sides of the handoff: the admin panel\n * cannot read server config, so the build transports the config value into\n * the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_PATH` variable\n * (see create-build-context.ts in @strapi/strapi); the server resolves the\n * same config at runtime. Changing the path requires an admin rebuild, like\n * any other admin config change.\n *\n * Defaults to `/admin` to match the refresh-cookie path used by\n * `getRefreshCookieOptions`.\n */\nexport const DEFAULT_AUTH_COOKIE_PATH = '/admin';\n\nconst isValidCookiePath = (path: string): boolean => {\n if (!path.startsWith('/')) {\n return false;\n }\n\n // RFC 6265 path-av: any CHAR except CTLs or \";\".\n return !/[\\x00-\\x1F\\x7F;]/.test(path);\n};\n\nexport const resolveAuthCookiePath = (\n configuredPath?: string,\n warn: (message: string) => void = console.warn\n): string => {\n const cookiePath = (configuredPath || '').trim();\n\n if (!cookiePath) {\n return DEFAULT_AUTH_COOKIE_PATH;\n }\n\n if (!isValidCookiePath(cookiePath)) {\n warn(\n `Ignoring invalid admin auth cookie path \"${cookiePath}\" (must be an absolute path without \";\"); using \"${DEFAULT_AUTH_COOKIE_PATH}\" instead.`\n );\n return DEFAULT_AUTH_COOKIE_PATH;\n }\n\n return cookiePath;\n};\n"],"names":["DEFAULT_AUTH_COOKIE_PATH","isValidCookiePath","path","startsWith","test","resolveAuthCookiePath","configuredPath","warn","console","cookiePath","trim"],"mappings":";;AAAA;;;;;;;;;;;;;;IAeO,MAAMA,wBAAAA,GAA2B;AAExC,MAAMC,oBAAoB,CAACC,IAAAA,GAAAA;AACzB,IAAA,IAAI,CAACA,IAAAA,CAAKC,UAAU,CAAC,GAAA,CAAA,EAAM;QACzB,OAAO,KAAA;AACT,IAAA;;IAGA,OAAO,CAAC,kBAAA,CAAmBC,IAAI,CAACF,IAAAA,CAAAA;AAClC,CAAA;MAEaG,qBAAAA,GAAwB,CACnCC,cAAAA,EACAC,IAAAA,GAAkCC,QAAQD,IAAI,GAAA;AAE9C,IAAA,MAAME,aAAa,CAACH,cAAAA,IAAkB,EAAC,EAAGI,IAAI,EAAA;AAE9C,IAAA,IAAI,CAACD,UAAAA,EAAY;QACf,OAAOT,wBAAAA;AACT,IAAA;IAEA,IAAI,CAACC,kBAAkBQ,UAAAA,CAAAA,EAAa;QAClCF,IAAAA,CACE,CAAC,yCAAyC,EAAEE,UAAAA,CAAW,iDAAiD,EAAET,wBAAAA,CAAyB,UAAU,CAAC,CAAA;QAEhJ,OAAOA,wBAAAA;AACT,IAAA;IAEA,OAAOS,UAAAA;AACT;;;;;"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Path attribute of the admin auth (access) token cookie, configurable
3
+ * through `admin.auth.cookie.path` so multiple Strapi instances on the same
4
+ * parent domain can keep separate cookies (e.g. `/strapi-de/admin`).
5
+ *
6
+ * Browser-safe single source for both sides of the handoff: the admin panel
7
+ * cannot read server config, so the build transports the config value into
8
+ * the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_PATH` variable
9
+ * (see create-build-context.ts in @strapi/strapi); the server resolves the
10
+ * same config at runtime. Changing the path requires an admin rebuild, like
11
+ * any other admin config change.
12
+ *
13
+ * Defaults to `/admin` to match the refresh-cookie path used by
14
+ * `getRefreshCookieOptions`.
15
+ */ const DEFAULT_AUTH_COOKIE_PATH = '/admin';
16
+ const isValidCookiePath = (path)=>{
17
+ if (!path.startsWith('/')) {
18
+ return false;
19
+ }
20
+ // RFC 6265 path-av: any CHAR except CTLs or ";".
21
+ return !/[\x00-\x1F\x7F;]/.test(path);
22
+ };
23
+ const resolveAuthCookiePath = (configuredPath, warn = console.warn)=>{
24
+ const cookiePath = (configuredPath || '').trim();
25
+ if (!cookiePath) {
26
+ return DEFAULT_AUTH_COOKIE_PATH;
27
+ }
28
+ if (!isValidCookiePath(cookiePath)) {
29
+ warn(`Ignoring invalid admin auth cookie path "${cookiePath}" (must be an absolute path without ";"); using "${DEFAULT_AUTH_COOKIE_PATH}" instead.`);
30
+ return DEFAULT_AUTH_COOKIE_PATH;
31
+ }
32
+ return cookiePath;
33
+ };
34
+
35
+ export { DEFAULT_AUTH_COOKIE_PATH, resolveAuthCookiePath };
36
+ //# sourceMappingURL=auth-cookie-path.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-cookie-path.mjs","sources":["../../../../shared/utils/auth-cookie-path.ts"],"sourcesContent":["/**\n * Path attribute of the admin auth (access) token cookie, configurable\n * through `admin.auth.cookie.path` so multiple Strapi instances on the same\n * parent domain can keep separate cookies (e.g. `/strapi-de/admin`).\n *\n * Browser-safe single source for both sides of the handoff: the admin panel\n * cannot read server config, so the build transports the config value into\n * the bundle through the internal `STRAPI_ADMIN_AUTH_COOKIE_PATH` variable\n * (see create-build-context.ts in @strapi/strapi); the server resolves the\n * same config at runtime. Changing the path requires an admin rebuild, like\n * any other admin config change.\n *\n * Defaults to `/admin` to match the refresh-cookie path used by\n * `getRefreshCookieOptions`.\n */\nexport const DEFAULT_AUTH_COOKIE_PATH = '/admin';\n\nconst isValidCookiePath = (path: string): boolean => {\n if (!path.startsWith('/')) {\n return false;\n }\n\n // RFC 6265 path-av: any CHAR except CTLs or \";\".\n return !/[\\x00-\\x1F\\x7F;]/.test(path);\n};\n\nexport const resolveAuthCookiePath = (\n configuredPath?: string,\n warn: (message: string) => void = console.warn\n): string => {\n const cookiePath = (configuredPath || '').trim();\n\n if (!cookiePath) {\n return DEFAULT_AUTH_COOKIE_PATH;\n }\n\n if (!isValidCookiePath(cookiePath)) {\n warn(\n `Ignoring invalid admin auth cookie path \"${cookiePath}\" (must be an absolute path without \";\"); using \"${DEFAULT_AUTH_COOKIE_PATH}\" instead.`\n );\n return DEFAULT_AUTH_COOKIE_PATH;\n }\n\n return cookiePath;\n};\n"],"names":["DEFAULT_AUTH_COOKIE_PATH","isValidCookiePath","path","startsWith","test","resolveAuthCookiePath","configuredPath","warn","console","cookiePath","trim"],"mappings":"AAAA;;;;;;;;;;;;;;IAeO,MAAMA,wBAAAA,GAA2B;AAExC,MAAMC,oBAAoB,CAACC,IAAAA,GAAAA;AACzB,IAAA,IAAI,CAACA,IAAAA,CAAKC,UAAU,CAAC,GAAA,CAAA,EAAM;QACzB,OAAO,KAAA;AACT,IAAA;;IAGA,OAAO,CAAC,kBAAA,CAAmBC,IAAI,CAACF,IAAAA,CAAAA;AAClC,CAAA;MAEaG,qBAAAA,GAAwB,CACnCC,cAAAA,EACAC,IAAAA,GAAkCC,QAAQD,IAAI,GAAA;AAE9C,IAAA,MAAME,aAAa,CAACH,cAAAA,IAAkB,EAAC,EAAGI,IAAI,EAAA;AAE9C,IAAA,IAAI,CAACD,UAAAA,EAAY;QACf,OAAOT,wBAAAA;AACT,IAAA;IAEA,IAAI,CAACC,kBAAkBQ,UAAAA,CAAAA,EAAa;QAClCF,IAAAA,CACE,CAAC,yCAAyC,EAAEE,UAAAA,CAAW,iDAAiD,EAAET,wBAAAA,CAAyB,UAAU,CAAC,CAAA;QAEhJ,OAAOA,wBAAAA;AACT,IAAA;IAEA,OAAOS,UAAAA;AACT;;;;"}
@@ -3,6 +3,17 @@
3
3
  * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_NAME`.
4
4
  */
5
5
  export declare const AUTH_COOKIE_NAME: string;
6
+ /**
7
+ * Resolved once at module load: the build inlines `admin.auth.cookie.path`
8
+ * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_PATH`.
9
+ */
10
+ export declare const AUTH_COOKIE_PATH: string;
11
+ /**
12
+ * Resolved once at module load: the build inlines `admin.auth.cookie.domain`
13
+ * into the bundle as `STRAPI_ADMIN_AUTH_COOKIE_DOMAIN`. `undefined` means the
14
+ * cookie is host-only.
15
+ */
16
+ export declare const AUTH_COOKIE_DOMAIN: string | undefined;
6
17
  /**
7
18
  * Retrieves the value of a specified cookie.
8
19
  *
@@ -12,6 +23,10 @@ export declare const AUTH_COOKIE_NAME: string;
12
23
  export declare const getCookieValue: (name: string) => string | null;
13
24
  /**
14
25
  * Sets a cookie with the given name, value, and optional expiration time.
26
+ * Uses `admin.auth.cookie.path` and `admin.auth.cookie.domain` (both inlined
27
+ * at build time) so the access cookie stays scoped to the same path and domain
28
+ * as the httpOnly refresh cookie and the EE SSO access cookie. The cookie is
29
+ * marked `Secure` whenever the page is served over TLS.
15
30
  *
16
31
  * @param name - The name of the cookie.
17
32
  * @param value - The value of the cookie.
@@ -21,6 +36,12 @@ export declare const setCookie: (name: string, value: string, days?: number) =>
21
36
  /**
22
37
  * Deletes a cookie by setting its expiration date to a past date.
23
38
  *
39
+ * Expires every combination of {configured path, legacy Path=/} and
40
+ * {configured domain, host-only}. A `Domain`-scoped cookie is a distinct entry
41
+ * from a host-only one in the browser cookie store, so both must be cleared or
42
+ * remote logout leaves the EE SSO cookie (written with `Domain` by the server)
43
+ * behind, rehydrating a dead session into an infinite login redirect.
44
+ *
24
45
  * @param name - The name of the cookie to delete.
25
46
  */
26
47
  export declare const deleteCookie: (name: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../../ee/server/src/controllers/admin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wBAoEE"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../../ee/server/src/controllers/admin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wBAoEE"}
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.d.ts","sourceRoot":"","sources":["../../../../../../ee/server/src/controllers/authentication-utils/middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAc1C,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,iBA0B/B,CAAC;AA4DF,eAAO,MAAM,gBAAgB,EAAE,IAAI,CAAC,iBA0DnC,CAAC;;;;;AAEF,wBAGE"}
1
+ {"version":3,"file":"middlewares.d.ts","sourceRoot":"","sources":["../../../../../../ee/server/src/controllers/authentication-utils/middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAiB1C,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,iBA0B/B,CAAC;AA4DF,eAAO,MAAM,gBAAgB,EAAE,IAAI,CAAC,iBAiEnC,CAAC;;;;;AAEF,wBAGE"}
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../ee/server/src/services/auth.ts"],"names":[],"mappings":";iCAayC,GAAG;uDAyCmB,GAAG;;AAelE,wBAGE"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../ee/server/src/services/auth.ts"],"names":[],"mappings":";iCAiByC,GAAG;uDAwCmB,GAAG;;AAkBlE,wBAGE"}
@@ -1 +1 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../../../ee/server/src/services/user.ts"],"names":[],"mappings":";oCAmB6C,MAAM,SAAS,GAAG;yCAwBb,OAAO;;uBA8HzB,GAAG;qBAzCL,OAAO;qBAzDP,GAAG,cAAc,GAAG;;AA4KlD,wBAOE"}
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../../../ee/server/src/services/user.ts"],"names":[],"mappings":";oCAmB6C,MAAM,SAAS,GAAG;yCAwBb,OAAO;;uBA8HzB,GAAG;qBAzCL,OAAO;qBAzDP,GAAG,cAAc,GAAG;;AAkLlD,wBAOE"}