@nocobase/cli 2.3.0-beta.8 → 2.3.0-beta.9

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;
@@ -510,6 +510,19 @@ function buildNginxManagedConfigBlock(context) {
510
510
  ` include ${context.snippetsDir}/mime-types.conf;`,
511
511
  ` include ${context.snippetsDir}/gzip.conf;`,
512
512
  '',
513
+ ' location = /_nocobase_legacy_file_auth {',
514
+ ' internal;',
515
+ ` proxy_pass ${context.backendUrl}${context.apiBasePath}auth:checkLegacyFileAccess;`,
516
+ ' proxy_pass_request_body off;',
517
+ ' proxy_set_header Content-Length "";',
518
+ ' proxy_set_header Cookie $http_cookie;',
519
+ ' proxy_set_header Authorization $http_authorization;',
520
+ ' proxy_set_header X-App $legacy_file_app;',
521
+ ' proxy_set_header X-Original-URI $request_uri;',
522
+ ' proxy_set_header Host $final_host;',
523
+ ' proxy_set_header X-Forwarded-Proto $upstream_x_forwarded_proto;',
524
+ ' }',
525
+ '',
513
526
  ` location ${context.appPublicPath}storage/uploads/ {`,
514
527
  ` alias ${context.uploadsDir}/;`,
515
528
  ` include ${context.snippetsDir}/uploads-location.conf;`,
@@ -1010,10 +1023,26 @@ function renderNginxLocationTemplate(context) {
1010
1023
  const proxyPassBlock = buildNginxProxyPassBlock(context.proxyHost, context.apiPort);
1011
1024
  const wsProxyPassTarget = `http://${context.proxyHost}:${context.apiPort}${context.wsPath}`;
1012
1025
  const apiBasePathNoTrailingSlash = trimTrailingSlash(context.apiBasePath);
1013
- return ` location ~* ^${context.appPublicPath}storage/uploads/(.*\\.md)$ {
1026
+ return ` location = /_nocobase_legacy_file_auth {
1027
+ internal;
1028
+ proxy_pass http://${context.proxyHost}:${context.apiPort}${context.apiBasePath}auth:checkLegacyFileAccess;
1029
+ proxy_pass_request_body off;
1030
+ proxy_set_header Content-Length "";
1031
+ proxy_set_header Cookie $http_cookie;
1032
+ proxy_set_header Authorization $http_authorization;
1033
+ proxy_set_header X-App $legacy_file_app;
1034
+ proxy_set_header X-Original-URI $request_uri;
1035
+ proxy_set_header Host $final_host;
1036
+ proxy_set_header X-Forwarded-Proto $upstream_x_forwarded_proto;
1037
+ }
1038
+
1039
+ location ~* ^${context.appPublicPath}storage/uploads/(.*\\.md)$ {
1014
1040
  alias ${context.uploadsPath}/$1;
1015
1041
  default_type text/markdown;
1016
- add_header Cache-Control "public";
1042
+ auth_request /_nocobase_legacy_file_auth;
1043
+ auth_request_set $legacy_auth_set_cookie $upstream_http_set_cookie;
1044
+ add_header Cache-Control "private, no-store" always;
1045
+ add_header Set-Cookie $legacy_auth_set_cookie always;
1017
1046
  add_header Content-Disposition "inline";
1018
1047
  add_header Content-Security-Policy "sandbox" always;
1019
1048
  add_header X-Content-Type-Options "nosniff" always;
@@ -1023,7 +1052,10 @@ function renderNginxLocationTemplate(context) {
1023
1052
 
1024
1053
  location ~* ^${context.appPublicPath}storage/uploads/(.*\\.(?:htm|html|pdf|svg|svgz|xht|xhtml|xml|xsl|xslt))$ {
1025
1054
  alias ${context.uploadsPath}/$1;
1026
- add_header Cache-Control "public";
1055
+ auth_request /_nocobase_legacy_file_auth;
1056
+ auth_request_set $legacy_auth_set_cookie $upstream_http_set_cookie;
1057
+ add_header Cache-Control "private, no-store" always;
1058
+ add_header Set-Cookie $legacy_auth_set_cookie always;
1027
1059
  add_header Content-Disposition "attachment" always;
1028
1060
  add_header Content-Security-Policy "sandbox" always;
1029
1061
  add_header X-Content-Type-Options "nosniff" always;
@@ -1033,7 +1065,10 @@ function renderNginxLocationTemplate(context) {
1033
1065
 
1034
1066
  location ${context.appPublicPath}storage/uploads/ {
1035
1067
  alias ${context.uploadsPath}/;
1036
- add_header Cache-Control "public";
1068
+ auth_request /_nocobase_legacy_file_auth;
1069
+ auth_request_set $legacy_auth_set_cookie $upstream_http_set_cookie;
1070
+ add_header Cache-Control "private, no-store" always;
1071
+ add_header Set-Cookie $legacy_auth_set_cookie always;
1037
1072
  add_header Content-Security-Policy "sandbox" always;
1038
1073
  add_header X-Content-Type-Options "nosniff" always;
1039
1074
  access_log off;
@@ -1083,7 +1118,12 @@ function renderNginxLocationTemplate(context) {
1083
1118
  `;
1084
1119
  }
1085
1120
  function renderLegacyEnvProxyAppTemplate(context) {
1086
- return `server {
1121
+ return `map $request_uri $legacy_file_app {
1122
+ default "";
1123
+ ~[?&]__appName=(?<legacy_file_app_name>[A-Za-z0-9_-]+)(?:&|$) $legacy_file_app_name;
1124
+ }
1125
+
1126
+ server {
1087
1127
  listen 80;
1088
1128
  server_name _;
1089
1129
  client_max_body_size 0;
@@ -1155,15 +1195,32 @@ function renderCaddyAppTemplate(siteAddress, context, publicDir) {
1155
1195
  `${siteAddress} {`,
1156
1196
  ` encode zstd gzip${rootRedirectBlock}${appPublicPathRedirectBlock}${modernClientRedirectBlock}${shorthandModernClientRedirectBlock}`,
1157
1197
  '',
1158
- ' @activeUploadedContent path_regexp activeUploadedContent (?i)\\.(?:htm|html|pdf|svg|svgz|xht|xhtml|xml|xsl|xslt)$',
1159
- '',
1160
1198
  ` handle_path ${uploadsPathMatcher} {`,
1161
- ` root * ${context.uploadsPath}`,
1162
- ' header Cache-Control public',
1163
- ' header Content-Security-Policy sandbox',
1164
- ' header X-Content-Type-Options nosniff',
1165
- ' header @activeUploadedContent Content-Disposition attachment',
1166
- ' file_server',
1199
+ ' route {',
1200
+ ' request_header -X-NocoBase-Auth-Set-Cookie',
1201
+ ` forward_auth ${context.proxyHost}:${context.apiPort} {`,
1202
+ ` uri ${context.apiBasePath}auth:checkLegacyFileAccess`,
1203
+ ' header_up X-App {query.__appName}',
1204
+ ' copy_headers Set-Cookie>X-NocoBase-Auth-Set-Cookie',
1205
+ ' }',
1206
+ '',
1207
+ ' @refreshedAuth header X-NocoBase-Auth-Set-Cookie *',
1208
+ ' header @refreshedAuth Set-Cookie {header.X-NocoBase-Auth-Set-Cookie}',
1209
+ ' header Cache-Control "private, no-store"',
1210
+ ' header Content-Security-Policy sandbox',
1211
+ ' header X-Content-Type-Options nosniff',
1212
+ ' header Content-Disposition inline',
1213
+ '',
1214
+ ' @activeUploadedContent path_regexp activeUploadedContent (?i)\\.(?:htm|html|pdf|svg|svgz|xht|xhtml|xml|xsl|xslt)$',
1215
+ ' header @activeUploadedContent Content-Disposition attachment',
1216
+ ' @download query download=1',
1217
+ ' header @download Content-Disposition attachment',
1218
+ ' @markdown path_regexp markdown (?i)\\.md$',
1219
+ ' header @markdown Content-Type text/markdown',
1220
+ '',
1221
+ ` root * ${context.uploadsPath}`,
1222
+ ' file_server',
1223
+ ' }',
1167
1224
  ' }',
1168
1225
  '',
1169
1226
  ` handle_path ${distPathMatcher} {`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.3.0-beta.8",
3
+ "version": "2.3.0-beta.9",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",
@@ -144,5 +144,5 @@
144
144
  "type": "git",
145
145
  "url": "git+https://github.com/nocobase/nocobase.git"
146
146
  },
147
- "gitHead": "5d458884528593b2d3142a6a33de93bf0ad96543"
147
+ "gitHead": "c215e60ed704afe6c086bd96304f4b0d3b46d02e"
148
148
  }