vortex-cli 8.4.1__tar.gz → 8.5.0__tar.gz

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 (62) hide show
  1. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/PKG-INFO +29 -3
  2. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/README.md +28 -2
  3. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/pyproject.toml +1 -1
  4. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/cli.py +2 -1
  5. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/servers.py +10 -1
  6. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/watch.py +1 -0
  7. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/models.py +63 -5
  8. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/server_options.py +10 -1
  9. vortex_cli-8.5.0/vortex/session_store.py +67 -0
  10. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/webdesign.py +38 -9
  11. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/workspace.py +60 -2
  12. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex_cli.egg-info/PKG-INFO +29 -3
  13. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex_cli.egg-info/SOURCES.txt +1 -0
  14. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/LICENSE +0 -0
  15. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/setup.cfg +0 -0
  16. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/__init__.py +0 -0
  17. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/__main__.py +0 -0
  18. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/colour.py +0 -0
  19. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/__init__.py +0 -0
  20. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/agenda.py +0 -0
  21. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/app.py +0 -0
  22. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/clean.py +0 -0
  23. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/clone.py +0 -0
  24. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/code.py +0 -0
  25. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/compile.py +0 -0
  26. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/db.py +0 -0
  27. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/diff.py +0 -0
  28. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/docs.py +0 -0
  29. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/execute.py +0 -0
  30. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/fetch.py +0 -0
  31. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/file.py +0 -0
  32. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/info.py +0 -0
  33. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/keyword.py +0 -0
  34. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/libs.py +0 -0
  35. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/log.py +0 -0
  36. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/object_.py +0 -0
  37. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/pull.py +0 -0
  38. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/search.py +0 -0
  39. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/stats.py +0 -0
  40. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/use.py +0 -0
  41. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/commands/weblog.py +0 -0
  42. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/constants.py +0 -0
  43. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/docs/Blackbook v2.md +0 -0
  44. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/docs/Blackbook.pdf +0 -0
  45. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/docs/index.html +0 -0
  46. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/docs/marked.min.js +0 -0
  47. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/git.py +0 -0
  48. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/lib/puakma-6.0.40.jar +0 -0
  49. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/libs.py +0 -0
  50. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/logging.py +0 -0
  51. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/main.py +0 -0
  52. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/output.py +0 -0
  53. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/registry.py +0 -0
  54. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/schedule.py +0 -0
  55. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/soap.py +0 -0
  56. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/spinner.py +0 -0
  57. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/sync.py +0 -0
  58. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex/util.py +0 -0
  59. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex_cli.egg-info/dependency_links.txt +0 -0
  60. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex_cli.egg-info/entry_points.txt +0 -0
  61. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex_cli.egg-info/requires.txt +0 -0
  62. {vortex_cli-8.4.1 → vortex_cli-8.5.0}/vortex_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vortex_cli
3
- Version: 8.4.1
3
+ Version: 8.5.0
4
4
  Summary: Vortex CLI
5
5
  Author-email: Jordan Amos <jordan.amos@gmail.com>
6
6
  License: MIT License
@@ -87,14 +87,15 @@ While it is possible to use without it, this software has been purposefully desi
87
87
 
88
88
  ```
89
89
  [DEFAULT] ; This section is optional and only useful if you have multiple definitions
90
- port = 80 ; Options provided under DEFAULT will be applied to all definitions if not provided
90
+ scheme = https ; Options provided under DEFAULT will be applied to all definitions if not provided
91
91
  soap_path = system/SOAPDesigner.pma
92
92
  default = server1 ; Useful when you have multiple definitions
93
93
 
94
94
 
95
95
  [server1] ; This can be called whatever you want and can be referenced using the '--server' flag
96
96
  host = example.com
97
- port = 8080 ; we can overwrite the DEFAULT value
97
+ scheme = http ; Optional - https (the default) or http, for a server that only speaks plain HTTP. We can overwrite the DEFAULT value
98
+ port = 8080 ; Optional - unset = the scheme's port: 443 for https, 80 for http
98
99
  username = myuser ; Optional - Prompted at runtime if not provided
99
100
  password = mypassword ; Optional - Prompted at runtime if not provided
100
101
  ; Optional
@@ -106,6 +107,26 @@ While it is possible to use without it, this software has been purposefully desi
106
107
  java_environment_name = JavaSE-17 ; Java Execution Environment name https://docs.osgi.org/reference/eenames.html
107
108
  ```
108
109
 
110
+ ## Upgrading to 8.5
111
+
112
+ - **HTTPS is the default.** A new per-server option `scheme` (`https`, the default, or
113
+ `http`) picks how vortex talks to the server, and an unset `port` now follows it: 443 for
114
+ https, 80 for http (`port` is no longer required). An explicit `port` is always honoured.
115
+ - **Action needed for plain-HTTP servers:** add `scheme = http` to each one. A config that
116
+ only says `port = 80` (often under `[DEFAULT]`) would now mean https on port 80, which
117
+ cannot work, so vortex refuses it with the fix: *"server 'x' uses https (the default since
118
+ 8.5) on port 80 (from [DEFAULT]) ... add 'scheme = http' to [x]; for HTTPS remove 'port'
119
+ ... or set 'port = 443'"*. For an HTTPS server, drop `port = 80` from `[DEFAULT]` (or
120
+ override it with `port = 443`).
121
+ - **A redirect to https says so.** A server that redirects plain HTTP to HTTPS (e.g. behind
122
+ Cloudflare) used to be reported as *"answered ... with a page instead of JSON - the
123
+ credentials were not accepted"*. It now reads *"HTTP 301 from <url>: the server redirects
124
+ to https (...) - set 'scheme = https' (port 443, or remove 'port') for '<server>' in
125
+ servers.ini"*. A real 401/403 still gives the credentials hint.
126
+ - `app list --open-urls` / `--open-dev-urls` and `clone --open-urls` open `https://` links.
127
+ - `vortex server list` shows each server's scheme; `vortex server get` shows the port an unset
128
+ `port` resolves to (`https default` / `http default`).
129
+
109
130
  ## Upgrading to 8.4
110
131
 
111
132
  - **`vortex stats` shows the server's disk space** after the statistics: each mounted local
@@ -116,6 +137,11 @@ While it is possible to use without it, this software has been purposefully desi
116
137
  - **8.4.1: `vortex clone` ignores case in a TemplateName or `group/name`.** `vortex clone
117
138
  ui20complete/mastercustom` clones `ui20Complete/MasterCustom`; the name must still match in
118
139
  full. If two applications differ only in case, the one typed exactly wins.
140
+ - **8.4.2: vortex reuses one server session.** Every command used to start a new Puakma
141
+ session, and parallel requests each started their own, leaving thousands of idle sessions
142
+ on the server until SessionTimeout. Session cookies are now kept per server in
143
+ `config/.sessions/` (owner-only; treat them like a login) and parallel requests share one
144
+ session. Delete the file to start a new session.
119
145
 
120
146
  ## Upgrading to 8.3
121
147
 
@@ -43,14 +43,15 @@ While it is possible to use without it, this software has been purposefully desi
43
43
 
44
44
  ```
45
45
  [DEFAULT] ; This section is optional and only useful if you have multiple definitions
46
- port = 80 ; Options provided under DEFAULT will be applied to all definitions if not provided
46
+ scheme = https ; Options provided under DEFAULT will be applied to all definitions if not provided
47
47
  soap_path = system/SOAPDesigner.pma
48
48
  default = server1 ; Useful when you have multiple definitions
49
49
 
50
50
 
51
51
  [server1] ; This can be called whatever you want and can be referenced using the '--server' flag
52
52
  host = example.com
53
- port = 8080 ; we can overwrite the DEFAULT value
53
+ scheme = http ; Optional - https (the default) or http, for a server that only speaks plain HTTP. We can overwrite the DEFAULT value
54
+ port = 8080 ; Optional - unset = the scheme's port: 443 for https, 80 for http
54
55
  username = myuser ; Optional - Prompted at runtime if not provided
55
56
  password = mypassword ; Optional - Prompted at runtime if not provided
56
57
  ; Optional
@@ -62,6 +63,26 @@ While it is possible to use without it, this software has been purposefully desi
62
63
  java_environment_name = JavaSE-17 ; Java Execution Environment name https://docs.osgi.org/reference/eenames.html
63
64
  ```
64
65
 
66
+ ## Upgrading to 8.5
67
+
68
+ - **HTTPS is the default.** A new per-server option `scheme` (`https`, the default, or
69
+ `http`) picks how vortex talks to the server, and an unset `port` now follows it: 443 for
70
+ https, 80 for http (`port` is no longer required). An explicit `port` is always honoured.
71
+ - **Action needed for plain-HTTP servers:** add `scheme = http` to each one. A config that
72
+ only says `port = 80` (often under `[DEFAULT]`) would now mean https on port 80, which
73
+ cannot work, so vortex refuses it with the fix: *"server 'x' uses https (the default since
74
+ 8.5) on port 80 (from [DEFAULT]) ... add 'scheme = http' to [x]; for HTTPS remove 'port'
75
+ ... or set 'port = 443'"*. For an HTTPS server, drop `port = 80` from `[DEFAULT]` (or
76
+ override it with `port = 443`).
77
+ - **A redirect to https says so.** A server that redirects plain HTTP to HTTPS (e.g. behind
78
+ Cloudflare) used to be reported as *"answered ... with a page instead of JSON - the
79
+ credentials were not accepted"*. It now reads *"HTTP 301 from <url>: the server redirects
80
+ to https (...) - set 'scheme = https' (port 443, or remove 'port') for '<server>' in
81
+ servers.ini"*. A real 401/403 still gives the credentials hint.
82
+ - `app list --open-urls` / `--open-dev-urls` and `clone --open-urls` open `https://` links.
83
+ - `vortex server list` shows each server's scheme; `vortex server get` shows the port an unset
84
+ `port` resolves to (`https default` / `http default`).
85
+
65
86
  ## Upgrading to 8.4
66
87
 
67
88
  - **`vortex stats` shows the server's disk space** after the statistics: each mounted local
@@ -72,6 +93,11 @@ While it is possible to use without it, this software has been purposefully desi
72
93
  - **8.4.1: `vortex clone` ignores case in a TemplateName or `group/name`.** `vortex clone
73
94
  ui20complete/mastercustom` clones `ui20Complete/MasterCustom`; the name must still match in
74
95
  full. If two applications differ only in case, the one typed exactly wins.
96
+ - **8.4.2: vortex reuses one server session.** Every command used to start a new Puakma
97
+ session, and parallel requests each started their own, leaving thousands of idle sessions
98
+ on the server until SessionTimeout. Session cookies are now kept per server in
99
+ `config/.sessions/` (owner-only; treat them like a login) and parallel requests share one
100
+ session. Delete the file to start a new session.
75
101
 
76
102
  ## Upgrading to 8.3
77
103
 
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "vortex_cli"
8
- version = "8.4.1"
8
+ version = "8.5.0"
9
9
  description = "Vortex CLI"
10
10
  requires-python = ">=3.10"
11
11
  readme = { file = "README.md", content-type = "text/markdown" }
@@ -862,7 +862,8 @@ def add_server_parser(command_parser: _SubParsersAction[ArgumentParser]) -> None
862
862
  "get",
863
863
  help=(
864
864
  "Show a server's every option, its value and where it comes from "
865
- "(no request)"
865
+ "(no request). scheme defaults to https, and an unset port to the "
866
+ "scheme's (443 / 80)"
866
867
  ),
867
868
  )
868
869
  get_parser.add_argument(
@@ -22,6 +22,7 @@ from vortex.output import envelope
22
22
  from vortex.output import render_kv
23
23
  from vortex.output import render_table
24
24
  from vortex.output import report_error
25
+ from vortex.server_options import DEFAULT_PORTS
25
26
  from vortex.server_options import DEFAULT_SERVER_OPTION
26
27
  from vortex.server_options import LEGACY_OPTIONS
27
28
  from vortex.server_options import OPTIONS_BY_NAME
@@ -110,6 +111,8 @@ def server_rows(workspace: Workspace) -> list[dict[str, Any]]:
110
111
  else:
111
112
  row.update(
112
113
  {
114
+ "scheme": server.scheme,
115
+ "port": str(server.port),
113
116
  "backend": server.backend_label,
114
117
  "gateway_path": server.gateway_path,
115
118
  "webdesign_path": server.webdesign_path,
@@ -157,7 +160,8 @@ def servers(workspace: Workspace, *, json_output: bool = False) -> int:
157
160
  table.append(
158
161
  [
159
162
  row["name"] + (" *" if row["default"] else ""),
160
- f"{row['host']}:{row['port']}" if row["port"] else row["host"],
163
+ (f"{row['scheme']}://" if row.get("scheme") else "")
164
+ + (f"{row['host']}:{row['port']}" if row["port"] else row["host"]),
161
165
  backend,
162
166
  "yes" if protected is True else "no" if protected is False else "",
163
167
  row["clones"],
@@ -279,6 +283,11 @@ def show_data(workspace: Workspace, name: str | None) -> dict[str, Any]:
279
283
  if opt.secret
280
284
  else f"{opt.name}: {e}"
281
285
  )
286
+ if opt.name == "port" and source == "unset":
287
+ # an unset port follows the scheme
288
+ scheme = _value(config, name, "scheme").strip().lower() or "https"
289
+ if scheme in DEFAULT_PORTS:
290
+ source, value = f"{scheme} default", str(DEFAULT_PORTS[scheme])
282
291
  if opt.required and not value.strip():
283
292
  problems.append(f"{opt.name} is required")
284
293
  shown = ("<set>" if value else "") if opt.secret else _one_line(value)
@@ -45,6 +45,7 @@ _CLASS_EXT = ".class"
45
45
  _CONNECTION_OPTIONS = (
46
46
  "host",
47
47
  "port",
48
+ "scheme",
48
49
  "username",
49
50
  "password",
50
51
  "gateway_path",
@@ -21,6 +21,7 @@ from typing import NamedTuple
21
21
 
22
22
  import httpx
23
23
 
24
+ from vortex.session_store import SessionStore
24
25
  from vortex.soap import ServerDesigner
25
26
 
26
27
  if TYPE_CHECKING:
@@ -232,10 +233,14 @@ class PuakmaServer:
232
233
  password: str | None = None,
233
234
  protected: bool = False,
234
235
  gateway_path: str | None = None,
236
+ scheme: str = "https",
235
237
  ) -> None:
236
238
  self.name = name
237
239
  self._host = host
238
240
  self._port = port
241
+ # A server that redirects http -> https answers a redirect page, not
242
+ # the gateway's JSON, so the scheme must be right up front
243
+ self.scheme = scheme
239
244
  self.soap_path = soap_path
240
245
  self.webdesign_path = webdesign_path
241
246
  # Protected servers are skipped by 'vortex watch' unless
@@ -253,6 +258,12 @@ class PuakmaServer:
253
258
  self._sync_client: httpx.Client | None = None
254
259
  self._async_client: httpx.AsyncClient | None = None
255
260
  self.server_designer = ServerDesigner(self)
261
+ # Set by Workspace: where this server's session cookies are kept
262
+ # between runs. Puakma creates a session for every request that
263
+ # arrives without one and keeps it for SessionTimeout (prod: 30
264
+ # days), so a fresh session per command - or per parallel request -
265
+ # piles up tens of thousands of idle sessions on the server
266
+ self.session_store: SessionStore | None = None
256
267
 
257
268
  @property
258
269
  def host(self) -> str:
@@ -333,15 +344,59 @@ class PuakmaServer:
333
344
  @property
334
345
  def _client(self) -> httpx.Client:
335
346
  if self._sync_client is None:
336
- self._sync_client = httpx.Client(auth=self.auth)
347
+ cookies = (
348
+ self.session_store.load(self.username) if self.session_store else None
349
+ )
350
+ self._sync_client = httpx.Client(
351
+ auth=self.auth,
352
+ cookies=cookies,
353
+ event_hooks={"response": [self._save_session]},
354
+ )
337
355
  return self._sync_client
338
356
 
339
357
  @property
340
358
  def _aclient(self) -> httpx.AsyncClient:
341
359
  if self._async_client is None:
342
- self._async_client = httpx.AsyncClient(auth=self.auth)
360
+ # Requests sent in parallel before the server has issued a
361
+ # session cookie each get a session of their own. Get one first
362
+ # on the sync client, so the async client starts with it
363
+ self._prime_session()
364
+ self._async_client = httpx.AsyncClient(
365
+ auth=self.auth,
366
+ cookies=self._client.cookies,
367
+ event_hooks={"response": [self._asave_session]},
368
+ )
343
369
  return self._async_client
344
370
 
371
+ def _prime_session(self) -> None:
372
+ if self._client.cookies.get(SessionStore.SESSION_COOKIE) is not None:
373
+ return
374
+ if not self.gateway_path:
375
+ # webdesign has no cheap endpoint to ask for one
376
+ return
377
+ url = f"{self.base_gateway_url}/api/whoami"
378
+ try:
379
+ self._client.get(url, timeout=10)
380
+ except httpx.HTTPError as e:
381
+ # Not fatal: the real requests report their own errors
382
+ logger.debug(f"Unable to get a session before parallel requests: {e}")
383
+
384
+ def _save_session(self, response: httpx.Response) -> None:
385
+ if self.session_store is None or "set-cookie" not in response.headers:
386
+ return
387
+ client = self._sync_client
388
+ if client is not None:
389
+ client.cookies.extract_cookies(response)
390
+ self.session_store.save(self.username, client.cookies)
391
+
392
+ async def _asave_session(self, response: httpx.Response) -> None:
393
+ if self.session_store is None or "set-cookie" not in response.headers:
394
+ return
395
+ client = self._async_client
396
+ if client is not None:
397
+ client.cookies.extract_cookies(response)
398
+ self.session_store.save(self.username, client.cookies)
399
+
345
400
  @property
346
401
  def base_soap_url(self) -> str:
347
402
  return f"{self}/{self.soap_path}"
@@ -355,7 +410,7 @@ class PuakmaServer:
355
410
  return f"{self}/{self.gateway_path}"
356
411
 
357
412
  def __str__(self) -> str:
358
- return f"http://{self.host}:{self.port}"
413
+ return f"{self.scheme}://{self.host}:{self.port}"
359
414
 
360
415
  def __enter__(self) -> PuakmaServer:
361
416
  self.ensure_credentials()
@@ -466,11 +521,14 @@ class PuakmaApplication:
466
521
  @property
467
522
  def url(self) -> str:
468
523
  base = f"{self.host}/{self.group}" if self.group else self.host
469
- return f"http://{base}/{self.name}.pma"
524
+ # Browser links: https, the default scheme. An app only knows its
525
+ # host, not its server's scheme - an http-only server redirects or
526
+ # refuses, so the user sees why
527
+ return f"https://{base}/{self.name}.pma"
470
528
 
471
529
  @property
472
530
  def web_design_url(self) -> str:
473
- base_url = f"http://{self.host}/system/webdesign.pma"
531
+ base_url = f"https://{self.host}/system/webdesign.pma"
474
532
  return f"{base_url}/DesignList?OpenPage&AppID={self.id}"
475
533
 
476
534
  @classmethod
@@ -25,7 +25,12 @@ SERVER_OPTIONS: tuple[ServerOption, ...] = (
25
25
  ServerOption(
26
26
  "host", "The server's host name, unique across servers", required=True
27
27
  ),
28
- ServerOption("port", "The HTTP port", required=True),
28
+ ServerOption("port", "The port; unset = the scheme's (443 for https, 80 for http)"),
29
+ ServerOption(
30
+ "scheme",
31
+ "https (the default) or http, for a server that only speaks plain HTTP",
32
+ default="https",
33
+ ),
29
34
  ServerOption(
30
35
  "username",
31
36
  "Else VORTEX_USERNAME_<NAME>, VORTEX_USERNAME, or a prompt",
@@ -67,6 +72,10 @@ SERVER_OPTIONS: tuple[ServerOption, ...] = (
67
72
 
68
73
  OPTIONS_BY_NAME = {o.name: o for o in SERVER_OPTIONS}
69
74
 
75
+ SCHEMES = ("https", "http")
76
+ # the port an unset 'port' means for each scheme
77
+ DEFAULT_PORTS = {"https": 443, "http": 80}
78
+
70
79
  # [DEFAULT]-only: the server 'vortex use' set
71
80
  DEFAULT_SERVER_OPTION = "default"
72
81
 
@@ -0,0 +1,67 @@
1
+ """
2
+ The server's session cookies, kept between vortex runs.
3
+
4
+ Puakma gives every request that arrives without a session cookie a new
5
+ session, and keeps a logged-in session until it has been idle for the
6
+ server's SessionTimeout - 30 days on some servers. Every vortex command
7
+ used to start without cookies, and parallel requests (clone, fetch, weblog
8
+ --all...) each started their own, so a busy agent left tens of thousands
9
+ of idle 'Vortex Agent' sessions in the server's session list.
10
+
11
+ The cookies are written per server and per user, readable only by the
12
+ owner: the session cookie and LtpaToken are as good as a login until the
13
+ session expires.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import json
19
+ import logging
20
+ import os
21
+ from pathlib import Path
22
+
23
+ import httpx
24
+
25
+ logger = logging.getLogger("vortex")
26
+
27
+
28
+ class SessionStore:
29
+ SESSION_COOKIE = "_pma_sess_id"
30
+
31
+ def __init__(self, path: Path) -> None:
32
+ self.path = path
33
+
34
+ def load(self, username: str) -> httpx.Cookies | None:
35
+ try:
36
+ data = json.loads(self.path.read_text())
37
+ except (OSError, ValueError):
38
+ return None
39
+ if not isinstance(data, dict) or data.get("username") != username:
40
+ return None
41
+ cookies = httpx.Cookies()
42
+ for c in data.get("cookies", []):
43
+ try:
44
+ cookies.set(c["name"], c["value"], domain=c["domain"], path=c["path"])
45
+ except (KeyError, TypeError):
46
+ continue
47
+ return cookies
48
+
49
+ def save(self, username: str, cookies: httpx.Cookies) -> None:
50
+ data = {
51
+ "username": username,
52
+ "cookies": [
53
+ {"name": c.name, "value": c.value, "domain": c.domain, "path": c.path}
54
+ for c in cookies.jar
55
+ ],
56
+ }
57
+ try:
58
+ self.path.parent.mkdir(parents=True, exist_ok=True)
59
+ # Per process: two vortex runs may save at the same time
60
+ tmp = self.path.with_suffix(f".{os.getpid()}.tmp")
61
+ fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
62
+ with os.fdopen(fd, "w") as f:
63
+ json.dump(data, f)
64
+ os.replace(tmp, self.path)
65
+ except OSError as e:
66
+ # Not fatal: the next run just starts a new session
67
+ logger.debug(f"Unable to save the session to '{self.path}': {e}")
@@ -281,7 +281,30 @@ def _refusal(resp: httpx.Response, url: str) -> GatewayRefused | None:
281
281
  )
282
282
 
283
283
 
284
- def _parse(resp: httpx.Response, url: str, access_hint: str) -> Any:
284
+ def _https_redirect(
285
+ resp: httpx.Response, url: str, server_name: str | None
286
+ ) -> str | None:
287
+ """
288
+ What to say when an http:// request was redirected to https:// (a
289
+ proxy such as Cloudflare upgrading plain HTTP), else None. Without it
290
+ the redirect read as "credentials not accepted", which they never were.
291
+ """
292
+ location = resp.headers.get("location", "")
293
+ where = f"'{server_name}'" if server_name else "this server"
294
+ if not url.lower().startswith("http://"):
295
+ return None
296
+ if not location.lower().startswith("https://"):
297
+ return None
298
+ return (
299
+ f"HTTP {resp.status_code} from {url}: the server redirects to https "
300
+ f"({location}) - set 'scheme = https' (port 443, or remove 'port') "
301
+ f"for {where} in servers.ini"
302
+ )
303
+
304
+
305
+ def _parse(
306
+ resp: httpx.Response, url: str, access_hint: str, server_name: str | None = None
307
+ ) -> Any:
285
308
  """
286
309
  The JSON body of a vortex reply, the string "Success" for a DELETE,
287
310
  or an exception that says which failure mode it was. A gateway
@@ -300,7 +323,13 @@ def _parse(resp: httpx.Response, url: str, access_hint: str) -> Any:
300
323
  "route (update system/webdesign)"
301
324
  )
302
325
  raise WebDesignError(text.strip() or f"HTTP 404 from {url}", "NOT_FOUND")
303
- if resp.status_code in (401, 403) or 300 <= resp.status_code < 400:
326
+ if 300 <= resp.status_code < 400:
327
+ redirect = _https_redirect(resp, url, server_name)
328
+ if redirect is not None:
329
+ raise WebDesignUnavailable(redirect, "UNAVAILABLE")
330
+ # Puakma redirects an unauthenticated request to its login page
331
+ raise WebDesignUnavailable(access_hint, "FORBIDDEN")
332
+ if resp.status_code in (401, 403):
304
333
  raise WebDesignUnavailable(access_hint, "FORBIDDEN")
305
334
  if resp.status_code != 200:
306
335
  raise WebDesignError(f"HTTP {resp.status_code} from {url}: {text.strip()}")
@@ -384,7 +413,7 @@ class WebDesignClient:
384
413
  )
385
414
  except httpx.HTTPError as e:
386
415
  raise WebDesignUnavailable(f"request failed: {e} ({url})") from e
387
- return _parse(resp, url, self._access_hint)
416
+ return _parse(resp, url, self._access_hint, self.server.name)
388
417
 
389
418
  async def _arequest(
390
419
  self,
@@ -401,7 +430,7 @@ class WebDesignClient:
401
430
  )
402
431
  except httpx.HTTPError as e:
403
432
  raise WebDesignUnavailable(f"request failed: {e} ({url})") from e
404
- return _parse(resp, url, self._access_hint)
433
+ return _parse(resp, url, self._access_hint, self.server.name)
405
434
 
406
435
  # -- applications --------------------------------------------------
407
436
 
@@ -862,7 +891,7 @@ class GatewayClient(WebDesignClient):
862
891
  resp = self.server._client.get(url, timeout=timeout)
863
892
  except httpx.HTTPError as e:
864
893
  raise WebDesignUnavailable(f"request failed: {e} ({url})") from e
865
- reply = _as_dict(_parse(resp, url, self._access_hint))
894
+ reply = _as_dict(_parse(resp, url, self._access_hint, self.server.name))
866
895
  try:
867
896
  gateway = reply.get("gateway") or {}
868
897
  server = reply.get("server") or {}
@@ -1154,7 +1183,7 @@ class GatewayClient(WebDesignClient):
1154
1183
  if resp.status_code == 200 and resp.content.startswith(_ZIP_MAGIC):
1155
1184
  return resp.content
1156
1185
  # a refusal/login page/error text - never an archive
1157
- _parse(resp, url, self._access_hint)
1186
+ _parse(resp, url, self._access_hint, self.server.name)
1158
1187
  raise WebDesignUnavailable(
1159
1188
  f"export on '{self.server.name}' did not return an archive for "
1160
1189
  f"application [{app_id}] (HTTP {resp.status_code})"
@@ -1196,7 +1225,7 @@ class GatewayClient(WebDesignClient):
1196
1225
  )
1197
1226
  except httpx.HTTPError as e:
1198
1227
  raise WebDesignUnavailable(f"request failed: {e} ({url})") from e
1199
- return _as_dict(_parse(resp, url, self._access_hint))
1228
+ return _as_dict(_parse(resp, url, self._access_hint, self.server.name))
1200
1229
 
1201
1230
  # -- files (Admin): the filesystem below the Puakma root -----------
1202
1231
 
@@ -1249,7 +1278,7 @@ class GatewayClient(WebDesignClient):
1249
1278
  ):
1250
1279
  # a refusal, a login page or an error - never the file
1251
1280
  resp.read()
1252
- _parse(resp, url, self._access_hint)
1281
+ _parse(resp, url, self._access_hint, self.server.name)
1253
1282
  raise WebDesignUnavailable(
1254
1283
  f"'{self.server.name}' did not send the file "
1255
1284
  f"(HTTP {resp.status_code}, {content_type or 'no content type'})"
@@ -1309,7 +1338,7 @@ class GatewayClient(WebDesignClient):
1309
1338
  )
1310
1339
  except httpx.HTTPError as e:
1311
1340
  raise WebDesignUnavailable(f"request failed: {e} ({url})") from e
1312
- reply = _as_dict(_parse(resp, url, self._access_hint))
1341
+ reply = _as_dict(_parse(resp, url, self._access_hint, self.server.name))
1313
1342
  if not isinstance(reply.get("files"), list):
1314
1343
  raise WebDesignUnavailable(f"Malformed files reply from {url}")
1315
1344
  reply.pop("ok", None)
@@ -24,9 +24,12 @@ from vortex.models import DesignObjectNotFound
24
24
  from vortex.models import DesignType
25
25
  from vortex.models import PuakmaApplication
26
26
  from vortex.models import PuakmaServer
27
+ from vortex.server_options import DEFAULT_PORTS
27
28
  from vortex.server_options import OPTIONS_BY_NAME
29
+ from vortex.server_options import SCHEMES
28
30
  from vortex.server_options import ServersConfig
29
31
  from vortex.server_options import secret_interpolation_error
32
+ from vortex.session_store import SessionStore
30
33
  from vortex.util import file_lock
31
34
  from vortex.util import locked_by_message
32
35
 
@@ -51,9 +54,12 @@ SAMPLE_CONFIG = """\
51
54
  # Each server's puakma.jar and shared libraries are downloaded from the
52
55
  # server itself (see 'vortex server libs') - 'lib_path' is only for extra local
53
56
  # jars to add to the classpath.
57
+ # 'scheme' is https by default; set 'scheme = http' for a server that only
58
+ # speaks plain HTTP. 'port' unset = the scheme's port (443 / 80).
54
59
  [dev]
55
60
  host =
56
- port = 80
61
+ scheme = https
62
+ port =
57
63
  username =
58
64
  password =
59
65
  soap_path = system/SOAPDesigner.pma
@@ -647,7 +653,7 @@ class Workspace:
647
653
  if cached is not None:
648
654
  return cached
649
655
  host = config.get(server_name, "host")
650
- port = config.getint(server_name, "port")
656
+ port_value = config.get(server_name, "port", fallback="").strip()
651
657
  soap_path = config.get(
652
658
  server_name, "soap_path", fallback=OPTIONS_BY_NAME["soap_path"].default
653
659
  )
@@ -664,7 +670,20 @@ class Workspace:
664
670
  "gateway_path",
665
671
  fallback=OPTIONS_BY_NAME["gateway_path"].default,
666
672
  ).strip()
673
+ scheme = (
674
+ config.get(
675
+ server_name, "scheme", fallback=OPTIONS_BY_NAME["scheme"].default
676
+ )
677
+ .strip()
678
+ .lower()
679
+ )
667
680
 
681
+ if scheme not in SCHEMES:
682
+ raise ValueError(
683
+ f"'scheme' for server '{server_name}' must be https or http, "
684
+ f"not '{scheme}'"
685
+ )
686
+ port = self._resolve_port(config, server_name, scheme, port_value)
668
687
  if not host:
669
688
  raise ValueError(f"Empty 'host' value for server '{server_name}'")
670
689
  if not soap_path:
@@ -683,12 +702,51 @@ class Workspace:
683
702
  password,
684
703
  protected,
685
704
  gateway_path or None,
705
+ scheme,
706
+ )
707
+ server.session_store = SessionStore(
708
+ self.config_dir / ".sessions" / f"{server_name}.json"
686
709
  )
687
710
  self._server_cache[server_name] = server
688
711
  return server
689
712
  except (configparser.Error, ValueError) as e:
690
713
  _error(f"Error reading server from config: {str(e)}")
691
714
 
715
+ @staticmethod
716
+ def _resolve_port(
717
+ config: configparser.ConfigParser,
718
+ server_name: str,
719
+ scheme: str,
720
+ value: str,
721
+ ) -> int:
722
+ """
723
+ The port: as set, else the scheme's own (443 / 80). https on port
724
+ 80 never works - TLS sent to a plain-HTTP port - and is what a
725
+ pre-8.5 config ('port = 80', no scheme) reads as now that https is
726
+ the default, so it is refused with the fix rather than guessed at.
727
+ """
728
+ if not value:
729
+ return DEFAULT_PORTS[scheme]
730
+ try:
731
+ port = int(value)
732
+ except ValueError:
733
+ raise ValueError(
734
+ f"'port' for server '{server_name}' must be a number, not '{value}'"
735
+ ) from None
736
+ if scheme == "https" and port == 80:
737
+ # configparser has no public "own options" view of a section
738
+ own = config._sections.get(server_name, {}) # type: ignore[attr-defined]
739
+ port_from = f"[{server_name}]" if "port" in own else "[DEFAULT]"
740
+ scheme_set = "scheme" in own or "scheme" in config.defaults()
741
+ why = "" if scheme_set else " (the default since 8.5)"
742
+ raise ValueError(
743
+ f"server '{server_name}' uses https{why} on port 80 (from "
744
+ f"{port_from}), which cannot work. For a plain-HTTP server add "
745
+ f"'scheme = http' to [{server_name}]; for HTTPS remove 'port' "
746
+ "(443 is the https default) or set 'port = 443'"
747
+ )
748
+ return port
749
+
692
750
  @staticmethod
693
751
  def app_folder_name(app: PuakmaApplication) -> str:
694
752
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vortex_cli
3
- Version: 8.4.1
3
+ Version: 8.5.0
4
4
  Summary: Vortex CLI
5
5
  Author-email: Jordan Amos <jordan.amos@gmail.com>
6
6
  License: MIT License
@@ -87,14 +87,15 @@ While it is possible to use without it, this software has been purposefully desi
87
87
 
88
88
  ```
89
89
  [DEFAULT] ; This section is optional and only useful if you have multiple definitions
90
- port = 80 ; Options provided under DEFAULT will be applied to all definitions if not provided
90
+ scheme = https ; Options provided under DEFAULT will be applied to all definitions if not provided
91
91
  soap_path = system/SOAPDesigner.pma
92
92
  default = server1 ; Useful when you have multiple definitions
93
93
 
94
94
 
95
95
  [server1] ; This can be called whatever you want and can be referenced using the '--server' flag
96
96
  host = example.com
97
- port = 8080 ; we can overwrite the DEFAULT value
97
+ scheme = http ; Optional - https (the default) or http, for a server that only speaks plain HTTP. We can overwrite the DEFAULT value
98
+ port = 8080 ; Optional - unset = the scheme's port: 443 for https, 80 for http
98
99
  username = myuser ; Optional - Prompted at runtime if not provided
99
100
  password = mypassword ; Optional - Prompted at runtime if not provided
100
101
  ; Optional
@@ -106,6 +107,26 @@ While it is possible to use without it, this software has been purposefully desi
106
107
  java_environment_name = JavaSE-17 ; Java Execution Environment name https://docs.osgi.org/reference/eenames.html
107
108
  ```
108
109
 
110
+ ## Upgrading to 8.5
111
+
112
+ - **HTTPS is the default.** A new per-server option `scheme` (`https`, the default, or
113
+ `http`) picks how vortex talks to the server, and an unset `port` now follows it: 443 for
114
+ https, 80 for http (`port` is no longer required). An explicit `port` is always honoured.
115
+ - **Action needed for plain-HTTP servers:** add `scheme = http` to each one. A config that
116
+ only says `port = 80` (often under `[DEFAULT]`) would now mean https on port 80, which
117
+ cannot work, so vortex refuses it with the fix: *"server 'x' uses https (the default since
118
+ 8.5) on port 80 (from [DEFAULT]) ... add 'scheme = http' to [x]; for HTTPS remove 'port'
119
+ ... or set 'port = 443'"*. For an HTTPS server, drop `port = 80` from `[DEFAULT]` (or
120
+ override it with `port = 443`).
121
+ - **A redirect to https says so.** A server that redirects plain HTTP to HTTPS (e.g. behind
122
+ Cloudflare) used to be reported as *"answered ... with a page instead of JSON - the
123
+ credentials were not accepted"*. It now reads *"HTTP 301 from <url>: the server redirects
124
+ to https (...) - set 'scheme = https' (port 443, or remove 'port') for '<server>' in
125
+ servers.ini"*. A real 401/403 still gives the credentials hint.
126
+ - `app list --open-urls` / `--open-dev-urls` and `clone --open-urls` open `https://` links.
127
+ - `vortex server list` shows each server's scheme; `vortex server get` shows the port an unset
128
+ `port` resolves to (`https default` / `http default`).
129
+
109
130
  ## Upgrading to 8.4
110
131
 
111
132
  - **`vortex stats` shows the server's disk space** after the statistics: each mounted local
@@ -116,6 +137,11 @@ While it is possible to use without it, this software has been purposefully desi
116
137
  - **8.4.1: `vortex clone` ignores case in a TemplateName or `group/name`.** `vortex clone
117
138
  ui20complete/mastercustom` clones `ui20Complete/MasterCustom`; the name must still match in
118
139
  full. If two applications differ only in case, the one typed exactly wins.
140
+ - **8.4.2: vortex reuses one server session.** Every command used to start a new Puakma
141
+ session, and parallel requests each started their own, leaving thousands of idle sessions
142
+ on the server until SessionTimeout. Session cookies are now kept per server in
143
+ `config/.sessions/` (owner-only; treat them like a login) and parallel requests share one
144
+ session. Delete the file to start a new session.
119
145
 
120
146
  ## Upgrading to 8.3
121
147
 
@@ -15,6 +15,7 @@ vortex/output.py
15
15
  vortex/registry.py
16
16
  vortex/schedule.py
17
17
  vortex/server_options.py
18
+ vortex/session_store.py
18
19
  vortex/soap.py
19
20
  vortex/spinner.py
20
21
  vortex/sync.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes