Commit Graph
100 Commits
Author SHA1 Message Date
YuryShkoda 398dfb515c docs(api): document the current authentication flow, comment non-obvious auth code
Add a new diagram covering the authentication mechanism: a
session-based /SASLogon/login + /SASLogon/authorize handshake that
mints a short-lived auth code, exchanged at /SASjsApi/auth/token for a
revocable JWT pair, with optional LDAP-backed credential verification.

Add WHY comments (not present before) at the handful of spots in the
auth code whose behaviour isn't obvious from reading them in isolation:
why /auth/token can return an existing token pair instead of rotating
it, why the auth-code exchange never checks a client's clientSecret,
how verifyTokenInDB turns self-verifying JWTs into revocable ones, why
two /SASjsApi/user routes stay reachable in desktop mode, why the
static authorized-route list exists on top of plain authentication,
and why /SASjsApi/client's real protection lives at its router mount
point in routes/api/index.ts rather than in client.ts itself.
2026-07-15 16:34:33 +03:00
YuryShkoda 850695024f fix(api): return 200 with embedded log on SAS session failure instead of 400
A failed session (e.g. SAS %abort;, or a non-zero JS/PY/R exit) is a
normal outcome of running arbitrary user code, not a request-shape or
server problem. The #388 fix stopped processProgram() from hanging
forever on a failed SAS session, but did so by throwing a
SessionExecutionError, which surfaced as an HTTP 400 with a bespoke
JSON shape - breaking Studio's log tab, which only renders on 2xx.

Align the SAS branch with the pre-existing JS/PY/R behaviour: resolve
instead of throwing, and let Execution.ts fold session.failureReason
into the log the same way it already does for a debug-mode run. This
removes the now-dead SessionExecutionError class and its try/catch
wrapper entirely.

Update the diagrams in api/docs/diagrams/ to match.
2026-07-15 13:59:01 +03:00
Yury ShkodaandGitHub 05768890a2 Merge pull request #366 from sasjs/cpr-fix
Fix API scripts
2026-07-14 16:50:34 +03:00
YuryShkoda 386185d1a0 Merge remote-tracking branch 'origin/main' into cpr-fix
# Conflicts:
#	api/package-lock.json
#	api/package.json
#	api/public/swagger.yaml
2026-07-14 16:28:10 +03:00
Yury ShkodaandGitHub 681f0123ad Merge pull request #387 from sasjs/fix/pin-axios-version
chore: pin axios versions
2026-07-14 15:45:40 +03:00
YuryShkoda daa5274fb0 Merge remote-tracking branch 'origin/main' into fix/pin-axios-version 2026-07-14 15:29:26 +03:00
YuryShkoda fd31fe94ea Merge remote-tracking branch 'origin/main' into issue-390
# Conflicts:
#	api/src/controllers/internal/spec/Execution.spec.ts
2026-07-14 11:58:24 +03:00
YuryShkoda dec5191491 fix(api): isolate drive.spec.ts's files folder from the real drive
drive.spec.ts already isolates itself into a unique, timestamped
tmpFolder for getSasjsRootFolder()/getUploadsFolder(), cleaned up via
afterAll(() => deleteFolder(tmpFolder)). But getFilesFolder() - what
nearly every test in this file actually writes to - resolves through
a separate, unmocked function (getSasjsDriveFolder()/process.driveLoc),
so every run left real files/folders (e.g. 'level1', 'my/path/...')
behind in the shared api/sasjs_root/drive/files, causing later runs
to fail: folder-listing tests saw stale entries, and file-creation
tests got 409 Conflict against files a previous run already created.

Mock getFilesFolder() the same way getUploadsFolder() already is, so
it resolves inside the same isolated tmpFolder and gets cleaned up
by the existing afterAll. Verified by running the suite twice in a
row from a clean slate: both runs pass, and the real sasjs_root/drive
is never touched.
2026-07-14 11:32:01 +03:00
YuryShkoda 4858245372 fix(api): stop overwriting a failed JS/PY/R session back to completed
For JS/PY/R, processProgram sets session.state = failed (with
failureReason) itself when the interpreter process exits non-zero,
without throwing. ExecutionController.executeProgram then
unconditionally set session.state = completed right after
processProgram returned, silently overwriting that - so anything
downstream inspecting session.state (e.g. scheduleSessionDestroy's
expiresAfterMins branch) would see a crashed session mis-reported as
successful.

Guard the assignment so a failed state is never overwritten. No
effect on SAS, which sets state independently via its own spawned
process lifecycle.

Added Execution.spec.ts covering both the failure case (state stays
failed) and the success case (state still becomes completed), to
guard against regressing in either direction.
2026-07-14 11:29:30 +03:00
YuryShkoda 0af6b63ffa fix: fix code.spec.ts failing on a fresh checkout (CI) 2026-07-14 09:20:35 +03:00
YuryShkoda 67fce475a3 fix(api): harden mock SAS executable and timeouts for CI
- wrap the file read/write in a small retry() helper instead of
  letting an uncaught exception (e.g. a rename racing an existsSync
  check) crash the process with a non-zero exit indistinguishable
  from a genuine SAS failure
- bump the internal give-up deadline from 1500ms to 8000ms
- bump the corresponding Jest test timeouts from 15000ms to 30000ms to match
2026-07-14 08:41:35 +03:00
YuryShkoda f84af4ac06 fix(api): return prompt error response instead of hanging when a SAS session fails
The SAS-runtime poll loop in processProgram only checked for
SessionState.completed, so a session that failed (e.g. via %abort;)
left the loop spinning on delay(50) forever - the request never
resolved, even though the SAS log had already been written. Split a single completed-on-either-outcome
flag into separate completed/failed states without updating this loop.

- processProgram now throws when session.state becomes 'failed'
- Execution.ts catches that, reads the complete log (guaranteed
  complete since the session's process has already exited by then),
  and throws a SessionExecutionError carrying it
- stp.ts/code.ts surface { ..., log } in the HTTP error response
- add unit tests for the poll loop and the log-enrichment logic, plus
  a mock SAS executable + end-to-end test exercising the real
  session/process pipeline without needing a SAS install
- add docs/diagrams covering the session lifecycle and the SAS
  execution handshake mechanism, for future context
2026-07-13 13:46:36 +03:00
Yury ShkodaandGitHub d6e527ecf2 Merge pull request #379 from sasjs/issue-378
Issue 378
2024-10-31 15:51:13 +03:00
Yury ShkodaandGitHub 832f1156e8 Merge pull request #377 from sasjs/issue-373-stp-fix
feat(api): enabled query params in stp/trigger endpoint
2024-10-30 12:22:10 +03:00
Yury ShkodaandGitHub a044176054 Merge pull request #375 from sasjs/issue-373-stp
Issue 373 stp
2024-10-29 17:08:38 +03:00
Yury ShkodaandGitHub 441f8b7726 Merge pull request #374 from sasjs/issue-373
feat(code): added code/trigger API endpoint
2024-10-29 13:29:08 +03:00
Yury ShkodaandGitHub 6f2c53555c Merge pull request #372 from sasjs/issue-371
fix(api): fixed env issue in MacOS executable
2024-01-15 16:18:10 +03:00
Yury Shkoda 66232aefd2 chore(lint): bumped prettier and fixed lint issues 2023-09-21 17:58:47 +03:00
Yury Shkoda bf35791655 chore(lint): fixed Session.ts 2023-09-21 17:52:28 +03:00
Yury Shkoda 2dc11630e4 chore(api): regenerated swagger.yaml 2023-09-21 17:45:52 +03:00
Yury Shkoda 1473925896 fix(jsonwebtoken): bumped version to avoid vulnerability 2023-09-21 17:45:21 +03:00
Yury Shkoda b472f1bd61 chore(scripts): used cpr package to improve coping 2023-09-21 17:44:31 +03:00
Yury ShkodaandGitHub 2f47a2213b Merge pull request #364 from sasjs/log-separator
fix(log-separator): log separator should always wrap log
2023-07-25 09:01:36 +03:00
Yury Shkoda 0f91395fbb lint: fixed linting issues 2023-07-24 18:36:08 +03:00
Yury Shkoda 167b14fed0 docs(log-separator): left comment 2023-07-24 18:29:20 +03:00
Yury Shkoda 8940f4dc47 fix(log-separator): log separator should always wrap log 2023-07-24 18:27:21 +03:00
Yury Shkoda d458b5bb81 chore: cleanup 2023-05-03 10:56:17 +03:00
Yury Shkoda 958ab9cad2 chore(execution): add includePrintOutput to ExecuteFileParams 2023-05-03 10:46:21 +03:00
Yury Shkoda 78ceed13e1 docs(code): updated execute endpoint info 2023-05-02 16:01:00 +03:00
Yury Shkoda a17814fc90 chore(stp): removed redundant argument 2023-05-02 15:53:13 +03:00
Yury Shkoda 9aaffce820 fix(execute): fixed adding print output 2023-05-02 15:49:44 +03:00
Yury Shkoda e78f87f5c0 fix(execute): added atribute indicating stp api 2023-05-02 15:18:05 +03:00
Yury Shkoda bd1b58086d docs: left a comment regarding payload parts 2023-05-02 12:10:17 +03:00
Yury Shkoda 9f521634d9 chore(webout): added comment 2023-05-02 11:30:55 +03:00
Yury Shkoda a696168443 Merge branch 'main' of github.com:sasjs/server into issue-354 2023-05-02 11:17:41 +03:00
Yury Shkoda 31df72ad88 fix(webout): fixed adding empty webout to response payload 2023-05-02 11:17:12 +03:00
Yury Shkoda eb42683fff feat(editor): parse print output in response payload 2023-05-01 08:18:49 +03:00
Yury Shkoda d2de9dc13e fix(editor): fixed log/webout/print tabs 2023-05-01 07:28:23 +03:00
Yury Shkoda 6dd2f4f876 fix(execution): removed empty webout from response 2023-04-28 17:25:30 +03:00
Yury Shkoda c0f38ba7c9 wip(print-output): added print output to response payload 2023-04-28 15:09:44 +03:00
Yury ShkodaandGitHub 5215633e96 Merge pull request #358 from sasjs/css-issue-fix
Css issue fix
2023-04-28 14:46:12 +03:00
Yury Shkoda 64b156f762 fix(log): fixed chunk collapsing 2023-04-28 13:30:25 +03:00
Yury Shkoda 9c5acd6de3 fix(css): fixed css loading 2023-04-28 13:29:31 +03:00
Yury Shkoda 3848bb0add feat(log): added time to downloaded log name 2023-04-27 18:53:45 +03:00
Yury Shkoda 56a522c07c fix(log): fixed scrolling issue 2023-04-27 17:53:45 +03:00
Yury Shkoda 87e9172cfc chore(log): used css module to declare classes 2023-04-27 17:52:57 +03:00
Yury Shkoda 777b3a55be feat(log): put download log icon into log tab 2023-04-26 16:10:04 +03:00
Yury Shkoda a38a9f9c3d feat(log): added download chunk and entire log 2023-04-21 17:21:09 +03:00
Yury Shkoda 57b7f954a1 fix(log): fixed single chunk scrolling 2023-04-18 16:16:58 +03:00
Yury Shkoda 8254b78955 fix(log): fixed single chunk display 2023-04-18 15:46:53 +03:00
Yury Shkoda 75f5a3c0b3 feat(log): split large log into chunks 2023-04-18 11:42:10 +03:00
Yury Shkoda c72ecc7e59 fix(log): fixing switching from SAS to other runtime 2023-04-11 16:52:36 +03:00
Yury Shkoda e04300ad2a fix(log): fixed default runtime 2023-04-11 16:42:24 +03:00
Yury Shkoda c7a73991a7 fix(log): fixed switching runtime 2023-04-11 16:10:52 +03:00
Yury Shkoda 02e2b060f9 fix(log): fixed checks for errors and warnings 2023-04-11 15:21:46 +03:00
Yury Shkoda 3b1e4a128b fix(log): fixed parsing log for different runtime 2023-04-11 14:45:38 +03:00
Yury Shkoda 7b12591595 feat(log): use improved log for SAS run time only 2023-04-11 14:18:42 +03:00
Yury Shkoda 3a887dec55 feat(log): added logComponent and LogTabWithIcons 2023-04-10 16:21:32 +03:00
Yury Shkoda 7c1c1e2410 feat(log): added parseErrorsAndWarnings utility 2023-04-10 15:45:54 +03:00
Yury Shkoda 15774eca34 chore(deps): added react-highlight 2023-04-10 15:40:27 +03:00
Yury ShkodaandGitHub 1933be15c2 Merge pull request #210 from sasjs/pr-template
chore(template): added pull request template
2022-06-21 19:11:19 +03:00
Yury Shkoda 56b20beb8c chore(template): added pull request template 2022-06-21 19:07:14 +03:00
Yury ShkodaandGitHub 8b83ccc4c2 Merge pull request #51 from sasjs/cli-issue-1108
feat: return json response with the log ob job execution
2022-02-15 11:08:17 +03:00
Yury Shkoda 556944b1d5 chore(git): Merge remote-tracking branch 'origin/main' into cli-issue-1108 2022-02-15 10:25:38 +03:00
Yury Shkoda fde4bc051d chore(execution): roll back changes related to returnLog var 2022-02-14 15:43:56 +03:00
Yury Shkoda f2000a1227 chore: fix typos and remove unused code 2022-02-10 09:07:14 +03:00
Yury Shkoda bf5767eadf feat(stp-execution): add returnLog option to execution query 2022-02-10 09:06:29 +03:00
Yury Shkoda 6c7a6b6c6a fix: fix web route 2021-10-28 15:04:34 +00:00
Yury ShkodaandGitHub f5e6b56abb Merge pull request #27 from sasjs/routes
feat(routes): separate routes into web and api
2021-10-28 15:30:50 +03:00
Yury Shkoda 48fe7994ec chore(routes): change files route with drive 2021-10-28 12:09:19 +00:00
Yury Shkoda 49c152a398 fix(routes): fix routes imports 2021-10-28 08:43:28 +00:00
Yury Shkoda dabef59728 feat(routes): separate routes into web and api 2021-10-28 08:25:36 +00:00
Yury ShkodaandGitHub c6c24da0e2 Merge pull request #25 from sasjs/deploy-fix
Fix payload processing within deploy end-point
2021-10-26 11:28:00 +03:00
Yury Shkoda 8f815b7874 test(deploy): fix payload 2021-10-26 08:22:44 +00:00
Yury Shkoda 361b539271 fix(deploy): fix payload processing 2021-10-26 08:18:02 +00:00
Yury Shkoda 4297285b26 chore(web): fix build warnings 2021-10-20 16:09:16 +03:00
Yury Shkoda 77cb7ef50f chore(web): cleaned package.json 2021-10-20 16:08:55 +03:00
Yury Shkoda c0ec406b2a chore(workflow): disable 'Run Unit Tests' step for web 2021-10-20 15:56:40 +03:00
Yury Shkoda 65a57acff6 chore(workflow): remove code style check step from build jobs 2021-10-20 15:52:53 +03:00
Yury Shkoda 6071b6c054 chore(web): fix linting 2021-10-20 15:51:11 +03:00
Yury Shkoda d97fd9b4d7 chore(npm): add package-lock 2021-10-20 15:49:28 +03:00
Yury Shkoda ba2c209fce chore(workflow): add lint step 2021-10-20 15:48:05 +03:00
Yury Shkoda 19c60c4c98 chore(workflow): remove 'package:lib' script 2021-10-20 15:32:35 +03:00
Yury Shkoda fd2092ecf3 chore(workflow): add working-directory for lint step 2021-10-20 15:25:28 +03:00
Yury Shkoda fda5680b0e chore(workflow): add working-directory 2021-10-20 15:23:45 +03:00
Yury Shkoda 6b23452d6a chore(workflow): check pwd 2021-10-20 15:18:31 +03:00
Yury Shkoda 174d94a23c fix(workflow): fix 'SASjs Server Build' 2021-10-20 15:15:24 +03:00
Yury ShkodaandGitHub a1de0ae888 Merge pull request #23 from sasjs/issue16-session
feat: uploading files in sas request
2021-10-19 13:45:13 +03:00
Yury Shkoda 00c7d2150c chore(git): add blank line to the file end 2021-10-14 07:40:01 +00:00
Yury Shkoda ba0722b98c chore(utils): add sleep export 2021-10-14 07:35:10 +00:00
Yury Shkoda 129cb7c128 chore(utils): add sleep util 2021-10-14 07:34:37 +00:00
Yury Shkoda 9cf02b25d0 refactor: improve types and imports 2021-10-14 07:34:08 +00:00
Yury Shkoda 6a34fa1b1d feat(session): add SessionController 2021-10-14 07:32:16 +00:00
Yury Shkoda 8b2564120d feat(execution): add ExecutionController working with session 2021-10-14 07:31:46 +00:00
Yury ShkodaandGitHub 686bf2eb11 Merge pull request #14 from sasjs/https-production-server
chore: added https server for production
2021-10-11 16:44:05 +03:00
Yury Shkoda 4d8efbb88d fix(prod-server): use port from configuration 2021-10-11 16:42:17 +03:00
Yury Shkoda ff9be117d9 chore(git): Merge branch 'master' into https-production-server 2021-10-11 16:40:24 +03:00
Yury Shkoda 37b6936cca fix(ts): enable files 2021-10-11 14:35:47 +03:00
Yury Shkoda 6e0b04a6e5 feat(session): add SessionController and ExecutionController 2021-10-11 14:16:22 +03:00
Yury ShkodaandGitHub e73c21aa4d chore: update README.md 2021-10-11 09:38:46 +03:00