@nocobase/cli 2.4.0-alpha.4 → 2.4.0-alpha.6

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.
@@ -12,3 +12,8 @@ map $http_host $final_host {
12
12
  default $http_host;
13
13
  "" $host;
14
14
  }
15
+
16
+ map $request_uri $legacy_file_app {
17
+ default "";
18
+ ~[?&]__appName=(?<legacy_file_app_name>[A-Za-z0-9_-]+)(?:&|$) $legacy_file_app_name;
19
+ }
@@ -1,4 +1,8 @@
1
- add_header Cache-Control "public" always;
1
+ auth_request /_nocobase_legacy_file_auth;
2
+ auth_request_set $legacy_auth_set_cookie $upstream_http_set_cookie;
3
+
4
+ add_header Cache-Control "private, no-store" always;
5
+ add_header Set-Cookie $legacy_auth_set_cookie always;
2
6
  add_header Content-Security-Policy "sandbox" always;
3
7
  add_header X-Content-Type-Options "nosniff" always;
4
8
 
@@ -7,7 +11,8 @@ autoindex off;
7
11
 
8
12
  # Force potentially renderable uploaded files to download.
9
13
  location ~* \.(?:htm|html|pdf|svg|svgz|xht|xhtml|xml|xsl|xslt)$ {
10
- add_header Cache-Control "public" always;
14
+ add_header Cache-Control "private, no-store" always;
15
+ add_header Set-Cookie $legacy_auth_set_cookie always;
11
16
  add_header Content-Security-Policy "sandbox" always;
12
17
  add_header X-Content-Type-Options "nosniff" always;
13
18
  add_header Content-Disposition "attachment" always;
@@ -17,7 +22,8 @@ location ~* \.(?:htm|html|pdf|svg|svgz|xht|xhtml|xml|xsl|xslt)$ {
17
22
  location ~* \.md$ {
18
23
  default_type text/markdown;
19
24
 
20
- add_header Cache-Control "public" always;
25
+ add_header Cache-Control "private, no-store" always;
26
+ add_header Set-Cookie $legacy_auth_set_cookie always;
21
27
  add_header Content-Security-Policy "sandbox" always;
22
28
  add_header X-Content-Type-Options "nosniff" always;
23
29
  add_header Content-Disposition "inline" always;
@@ -527,6 +527,19 @@ function buildNginxManagedConfigBlock(context) {
527
527
  ` include ${context.snippetsDir}/mime-types.conf;`,
528
528
  ` include ${context.snippetsDir}/gzip.conf;`,
529
529
  '',
530
+ ' location = /_nocobase_legacy_file_auth {',
531
+ ' internal;',
532
+ ` proxy_pass ${context.backendUrl}${context.apiBasePath}auth:checkLegacyFileAccess;`,
533
+ ' proxy_pass_request_body off;',
534
+ ' proxy_set_header Content-Length "";',
535
+ ' proxy_set_header Cookie $http_cookie;',
536
+ ' proxy_set_header Authorization $http_authorization;',
537
+ ' proxy_set_header X-App $legacy_file_app;',
538
+ ' proxy_set_header X-Original-URI $request_uri;',
539
+ ' proxy_set_header Host $final_host;',
540
+ ' proxy_set_header X-Forwarded-Proto $upstream_x_forwarded_proto;',
541
+ ' }',
542
+ '',
530
543
  ` location ${context.appPublicPath}storage/uploads/ {`,
531
544
  ` alias ${context.uploadsDir}/;`,
532
545
  ` include ${context.snippetsDir}/uploads-location.conf;`,
@@ -1129,10 +1142,26 @@ function renderNginxLocationTemplate(context) {
1129
1142
  const proxyPassBlock = buildNginxProxyPassBlock(context.proxyHost, context.apiPort);
1130
1143
  const wsProxyPassTarget = `http://${context.proxyHost}:${context.apiPort}${context.wsPath}`;
1131
1144
  const apiBasePathNoTrailingSlash = trimTrailingSlash(context.apiBasePath);
1132
- return ` location ~* ^${context.appPublicPath}storage/uploads/(.*\\.md)$ {
1145
+ return ` location = /_nocobase_legacy_file_auth {
1146
+ internal;
1147
+ proxy_pass http://${context.proxyHost}:${context.apiPort}${context.apiBasePath}auth:checkLegacyFileAccess;
1148
+ proxy_pass_request_body off;
1149
+ proxy_set_header Content-Length "";
1150
+ proxy_set_header Cookie $http_cookie;
1151
+ proxy_set_header Authorization $http_authorization;
1152
+ proxy_set_header X-App $legacy_file_app;
1153
+ proxy_set_header X-Original-URI $request_uri;
1154
+ proxy_set_header Host $final_host;
1155
+ proxy_set_header X-Forwarded-Proto $upstream_x_forwarded_proto;
1156
+ }
1157
+
1158
+ location ~* ^${context.appPublicPath}storage/uploads/(.*\\.md)$ {
1133
1159
  alias ${context.uploadsPath}/$1;
1134
1160
  default_type text/markdown;
1135
- add_header Cache-Control "public";
1161
+ auth_request /_nocobase_legacy_file_auth;
1162
+ auth_request_set $legacy_auth_set_cookie $upstream_http_set_cookie;
1163
+ add_header Cache-Control "private, no-store" always;
1164
+ add_header Set-Cookie $legacy_auth_set_cookie always;
1136
1165
  add_header Content-Disposition "inline";
1137
1166
  add_header Content-Security-Policy "sandbox" always;
1138
1167
  add_header X-Content-Type-Options "nosniff" always;
@@ -1142,7 +1171,10 @@ function renderNginxLocationTemplate(context) {
1142
1171
 
1143
1172
  location ~* ^${context.appPublicPath}storage/uploads/(.*\\.(?:htm|html|pdf|svg|svgz|xht|xhtml|xml|xsl|xslt))$ {
1144
1173
  alias ${context.uploadsPath}/$1;
1145
- add_header Cache-Control "public";
1174
+ auth_request /_nocobase_legacy_file_auth;
1175
+ auth_request_set $legacy_auth_set_cookie $upstream_http_set_cookie;
1176
+ add_header Cache-Control "private, no-store" always;
1177
+ add_header Set-Cookie $legacy_auth_set_cookie always;
1146
1178
  add_header Content-Disposition "attachment" always;
1147
1179
  add_header Content-Security-Policy "sandbox" always;
1148
1180
  add_header X-Content-Type-Options "nosniff" always;
@@ -1152,7 +1184,10 @@ function renderNginxLocationTemplate(context) {
1152
1184
 
1153
1185
  location ${context.appPublicPath}storage/uploads/ {
1154
1186
  alias ${context.uploadsPath}/;
1155
- add_header Cache-Control "public";
1187
+ auth_request /_nocobase_legacy_file_auth;
1188
+ auth_request_set $legacy_auth_set_cookie $upstream_http_set_cookie;
1189
+ add_header Cache-Control "private, no-store" always;
1190
+ add_header Set-Cookie $legacy_auth_set_cookie always;
1156
1191
  add_header Content-Security-Policy "sandbox" always;
1157
1192
  add_header X-Content-Type-Options "nosniff" always;
1158
1193
  access_log off;
@@ -1202,7 +1237,12 @@ function renderNginxLocationTemplate(context) {
1202
1237
  `;
1203
1238
  }
1204
1239
  function renderLegacyEnvProxyAppTemplate(context) {
1205
- return `server {
1240
+ return `map $request_uri $legacy_file_app {
1241
+ default "";
1242
+ ~[?&]__appName=(?<legacy_file_app_name>[A-Za-z0-9_-]+)(?:&|$) $legacy_file_app_name;
1243
+ }
1244
+
1245
+ server {
1206
1246
  listen 80;
1207
1247
  server_name _;
1208
1248
  client_max_body_size 0;
@@ -1278,15 +1318,32 @@ function renderCaddyAppTemplate(siteAddress, context, publicDir) {
1278
1318
  `${siteAddress} {`,
1279
1319
  ` encode zstd gzip${rootRedirectBlock}${appPublicPathRedirectBlock}${modernClientRedirectBlock}${shorthandModernClientRedirectBlock}`,
1280
1320
  '',
1281
- ' @activeUploadedContent path_regexp activeUploadedContent (?i)\\.(?:htm|html|pdf|svg|svgz|xht|xhtml|xml|xsl|xslt)$',
1282
- '',
1283
1321
  ` handle_path ${uploadsPathMatcher} {`,
1284
- ` root * ${context.uploadsPath}`,
1285
- ' header Cache-Control public',
1286
- ' header Content-Security-Policy sandbox',
1287
- ' header X-Content-Type-Options nosniff',
1288
- ' header @activeUploadedContent Content-Disposition attachment',
1289
- ' file_server',
1322
+ ' route {',
1323
+ ' request_header -X-NocoBase-Auth-Set-Cookie',
1324
+ ` forward_auth ${context.proxyHost}:${context.apiPort} {`,
1325
+ ` uri ${context.apiBasePath}auth:checkLegacyFileAccess`,
1326
+ ' header_up X-App {query.__appName}',
1327
+ ' copy_headers Set-Cookie>X-NocoBase-Auth-Set-Cookie',
1328
+ ' }',
1329
+ '',
1330
+ ' @refreshedAuth header X-NocoBase-Auth-Set-Cookie *',
1331
+ ' header @refreshedAuth Set-Cookie {header.X-NocoBase-Auth-Set-Cookie}',
1332
+ ' header Cache-Control "private, no-store"',
1333
+ ' header Content-Security-Policy sandbox',
1334
+ ' header X-Content-Type-Options nosniff',
1335
+ ' header Content-Disposition inline',
1336
+ '',
1337
+ ' @activeUploadedContent path_regexp activeUploadedContent (?i)\\.(?:htm|html|pdf|svg|svgz|xht|xhtml|xml|xsl|xslt)$',
1338
+ ' header @activeUploadedContent Content-Disposition attachment',
1339
+ ' @download query download=1',
1340
+ ' header @download Content-Disposition attachment',
1341
+ ' @markdown path_regexp markdown (?i)\\.md$',
1342
+ ' header @markdown Content-Type text/markdown',
1343
+ '',
1344
+ ` root * ${context.uploadsPath}`,
1345
+ ' file_server',
1346
+ ' }',
1290
1347
  ' }',
1291
1348
  '',
1292
1349
  ` handle_path ${distPathMatcher} {`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.4.0-alpha.4",
3
+ "version": "2.4.0-alpha.6",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",
@@ -147,5 +147,5 @@
147
147
  "type": "git",
148
148
  "url": "git+https://github.com/nocobase/nocobase.git"
149
149
  },
150
- "gitHead": "527910882037ce1558ee6b0ef748208b8d6996bb"
150
+ "gitHead": "1fc4fcd17a0cd79912a642600bdc2103e2104bdb"
151
151
  }