Skip to content

PFM-ISSUE-34293 - Introduce separate JFrog user and token secrets (plain _authToken) - #191

Merged
vladimir-arsov merged 10 commits into
masterfrom
improvement/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets
Nov 30, 2026
Merged

vladimir-arsov merged 10 commits into
masterfrom
improvement/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets

Conversation

@vladimir-arsov

@vladimir-arsov vladimir-arsov commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Resolves PFM-ISSUE-34293

changelog: Frontend-Core: [PFM-ISSUE-34293] FE workflows publish with a plain JFROG_TOKEN (_authToken); JFROG_BASE64_TOKEN is deprecated [PR github-actions#191]

Summary

The FE artifacts tooling gets a second publish-credential mode, chosen by which secret the caller passes:

Secrets passed Generated dist .npmrc Run outcome
JFROG_TOKEN (wins if both are passed) <scope>:registry=<JFROG_URL> + <key>:_authToken=${JFROG_TOKEN}, the placeholder written literally and expanded by npm from the step env publishes
only JFROG_BASE64_TOKEN legacy four-line _auth file, unchanged publishes, plus a ::warning:: deprecation annotation
neither, in a publishing or deleting mode – fails fast with ::error::No JFrog credentials: … before build, publish, delete or the release-version file

Changes

  • tools/scripts/artifacts/jfrog-credentials.ts: reads JFROG_TOKEN, authMode (TOKEN / LEGACY / NONE, decided by truthiness because an unpassed optional secret arrives as ''), requireForPublishing(), and toJSON() so the handler's "Configuration" log line never contains a secret.
  • nx-project.ts: writeNPMRCInDist writes the token or the legacy format. Both use the key getJfrogUrlNoHttp() produces. npm looks credentials up by walking the registry URL prefix by prefix, so a trailing slash in JFROG_URL doesn't matter.
  • artifacts-handler.ts, cleanup-snapshots.ts: call the credential gate in publishing and deleting modes only. Bump-only (fe-tag) and the release flow's no-op path don't need credentials.
  • Seven reusables (fe-snapshot, fe-pr-snapshot, fe-pr-close, fe-cleanup-snapshots, fe-release, fe-tag, fe-release-flow) declare JFROG_TOKEN and JFROG_BASE64_TOKEN as optional and pass both to every artifacts step (8 env blocks).
  • The FE starter templates pass JFROG_TOKEN. The README documents the JFrog and npm secrets contract and how to migrate.
  • Unit tests for credential selection, the gate, the token .npmrc (only the placeholder, never the value) and secret redaction.
  • Specs: research.md, design.md, plan.md, live-test-plan.md, review.md under specs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/.

Migration for consumers: add a JFROG_TOKEN repository secret and pass it in place of JFROG_BASE64_TOKEN; callers using secrets: inherit only need the secret. Callers that still pass JFROG_BASE64_TOKEN keep working and get the deprecation warning. A caller must not pass JFROG_TOKEN to @master before this PR is merged, because master doesn't declare that secret yet.

Live validation (clone-cplace-fe against cplace-npm-test)

ID Runs Verdict Note
T1 main snapshot, token 45565826065 pass 21 published with the token .npmrc, 0 auth errors, 0 leaks
T2 PR snapshot ×2, token 45572898174, 45575520373 pass authenticated npm show, unpublish and republish of 16
T3 PR close, token 45576981303 pass 16 unpublished, none left
T4 release flow, token 45577536910 pass (D1) 27 under release-26.4-pending, promoted to 26.4.11, tag pushed
T5 snapshot cleanup, token 45587848793 fail (D2) crashes before the gate, a pre-existing bug
T6 failure cleanup – skipped optional, skipped by decision
L1 main snapshot, legacy 45589586654 pass legacy .npmrc, one deprecation warning
L2 PR snapshot and close, legacy 45596280138, 45597704246 pass 16 published, then unpublished
L3 release flow, legacy (explicit secrets) 45600638756 pass (D1) 27 published, promoted to 26.4.12
N1 main snapshot, neither 45592796748 pass the run starts, then fails at the gate with the error annotation; nothing published
N2 PR close, neither 45598268998 pass fails at the gate before any npm unpublish

Across all runs: no Failed to replace env in config, no secret in the logs, and no auth error. Full report: live-test-plan.md §6.

Deviations (both on master before this change, each needing its own ticket):

  • D1: fe-release-flow skips github-release when RUN_E2E: false, because a skipped e2e job makes the implicit success() false. The releases version/26.4.11 and version/26.4.12 were created by hand.
  • D2: snapshot cleanup crashes when npm search lists a package that npm view then can't find (E404). Upstream cplace-fe's scheduled cleanup fails the same way.

Change after the live tests: the review follow-up (last commit) switches the token key from a trailing-slash-normalized form to getJfrogUrlNoHttp(), the same key the legacy mode has always used. Both forms match through npm's prefix lookup (npm-registry-fetch/lib/auth.js), so the published behaviour shouldn't change. The live runs above used the earlier normalized key.

Developer Checklist:

  • Updated documentation if needed
  • Created Changelog according
    to Guidelines

🤖 Generated with Claude Code

vladimir-arsov and others added 6 commits November 24, 2026 16:48
…-snapshot

JfrogCredentials reads JFROG_TOKEN and selects TOKEN, LEGACY or NONE by
truthiness. In token mode the dist .npmrc authenticates with
_authToken=${JFROG_TOKEN}, written literally and expanded by npm. The
legacy _auth file is unchanged. toJSON() keeps both secrets out of logs.
fe-snapshot.yml accepts JFROG_TOKEN; JFROG_BASE64_TOKEN becomes optional.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…BASE64_TOKEN

JfrogCredentials.requireForPublishing() stays silent in token mode,
emits a deprecation ::warning:: in legacy mode and an ::error:: plus a
throw when neither secret is set. ArtifactsHandler.handle() calls it
for every publishing or deleting mode, before any build, publish,
delete or release-version file; bump-only and the release flow's
non-forced default-branch run stay credential-free. CleanupSnapshots
checks once before deleting and reuses one credentials instance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The six remaining reusables declare JFROG_TOKEN and JFROG_BASE64_TOKEN
as optional and pass both to every artifacts step. The FE starter
templates pass JFROG_TOKEN. The README documents the JFrog and npm
secrets and how a repository migrates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ticket id from the warning

npm finds credentials by walking the registry URL prefix by prefix, so
the key needs no trailing-slash normalization; getAuthKey() is removed
and both auth modes use getJfrogUrlNoHttp(). Adds the review record
with findings [1.3] and [1.4] resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Kaltenbach Kaltenbach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review: one important finding (a JFROG_URL without a trailing slash breaks publishing) and two minor ones. Everything else holds up: the credential gate matches the dispatch in handle(), both entry points stop early without credentials, and toJSON keeps the secrets out of the Configuration log.

Also worth knowing: 95e4829 changed the token .npmrc keying after the live test results were recorded. It now matches the legacy keying, which the live runs exercised, but the token code as shipped hasn't been run live again.

Comment thread README.md Outdated

| Secret | Content | Used for |
| -------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `JFROG_URL` | URL of the npm repository artifacts are published to (`cplace-npm-local`); a trailing slash does not matter | `<scope>:registry=`, `publishConfig.registry`, `--registry=` and the credential key of the generated dist `.npmrc` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: the trailing slash does matter. Without one, every npm publish fails with ENEEDAUTH, in both token mode and legacy mode.

npm publish checks credentials with an exact lookup that drops the last path segment of a registry URL without a trailing slash. With JFROG_URL=https://cplace.jfrog.io/artifactory/api/npm/cplace-npm-local, the dist .npmrc key is //cplace.jfrog.io/artifactory/api/npm/cplace-npm-local:_authToken, but npm looks up //cplace.jfrog.io/artifactory/api/npm/:_authToken. Adding a / to the key alone does not help. Reproduced with npm 11.19.1 npm publish --dry-run ("This command requires you to be logged in").

The reasoning in review.md 1.3 for dropping getAuthKey() holds for npm-registry-fetch but not for this pre-publish check.

Suggested fix: normalize JfrogCredentials.url (jfrog-credentials.ts) to end with exactly one /, so the registry line, publishConfig.registry and the auth key all use it. Then add the tests the design asked for, one URL with a trailing slash and one without. The alternative is to say in the README that the URL must end with /.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reproducing this. Publishing already works without normalization: the existing JFROG_URL secret ends with /, and the live runs passed with it. A misconfigured URL costs one failed run with a clear auth error, so I would rather not add normalization code and tests for it. I fixed the README instead: the JFROG_URL row now says the URL must end with /, or npm publish fails with ENEEDAUTH (it wrongly said the slash does not matter).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with the README route. Note that design.md:119/127, plan.md:393 and review.md 1.3 still say the slash is normalized or doesn't matter — worth aligning so the specs don't contradict the README.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligned in e98db2a: design.md decision 3 (incl. lines 42/119/127/203/214), plan.md:393 and review.md 1.3 now say the key is getJfrogUrlNoHttp() like the legacy one and that JFROG_URL must end with /, with a dated note on why normalizing only the key would not help. plan.md also notes that getAuthKey() was removed in 95e4829.

Comment thread README.md Outdated
| `DOT_NPMRC` | a complete `.npmrc` | installs (`npm ci`), `npm search`/`npm view` in snapshot cleanup, third-party registries; never used for publishing |

To migrate a repository: set the `JFROG_TOKEN` secret (and make `JFROG_USER` its owner), then replace the
`JFROG_BASE64_TOKEN:` line with `JFROG_TOKEN: ${{ secrets.JFROG_TOKEN }}` in every caller. Workflows called

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: "in every caller" is too broad. Callers on release branches point at @release/X.Y reusables, which don't declare JFROG_TOKEN and still require JFROG_BASE64_TOKEN. If such a caller is edited this way, the run fails at startup. I'd limit this step to callers that reference @master and say that release-branch callers stay unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed. The migration step now applies only to callers that reference the reusables @master or @release/27.1 and later. Callers on @release/26.4 or older stay unchanged, because those reusables do not declare JFROG_TOKEN and still require JFROG_BASE64_TOKEN.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good.

const onReleaseBranch = this.currentBranch.startsWith(
ArtifactsHandler.RELEASE_BRANCH_PREFIX
);
if (this.releaseFlow) return onReleaseBranch || this.force;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: this gate now replaces the removed required: true, but two of its branches have no test:

  • a forced release flow on the default branch (must require credentials)
  • ONLY_BUMP_VERSION on a non-release branch, which falls through to build and publish (must require credentials)

If this line became return onReleaseBranch, a forced dispatch on master with no secrets would fail late with an unclear npm auth error, and no test would catch it. These two cases could go into artifacts-handler-release-flow.test.ts / artifacts-handler-tag.test.ts (review.md 1.1 is still open).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: artifacts-handler-release-flow.test.ts now covers both branches. A forced release flow on master and ONLY_BUMP_VERSION on a non-release branch both fail with "No JFrog credentials" before anything is published.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good.

@Kaltenbach Kaltenbach added PR: In Review The PR is currently being reviewed and removed PR: Needs Review labels Nov 25, 2026
vladimir-arsov and others added 3 commits November 26, 2026 17:20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d 27.1+

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and non-release bump runs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kaltenbach

Copy link
Copy Markdown
Contributor

Re-checked fb729a6: all three review comments are addressed. One point from the review summary is still open: has the token .npmrc keying from 95e4829 been run live since? A single fe-snapshot run against the test repo would close that before merge.

…ule, record the live rerun

design.md, plan.md and review.md 1.3 no longer say the auth key is
normalized or that the trailing slash does not matter: the key is
getJfrogUrlNoHttp() like the legacy one, and JFROG_URL must end with /
(README). live-test-plan.md records T1r, a main snapshot rerun on the
test branch recreated from fb729a6 (run 46423593537, pass).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vladimir-arsov

Copy link
Copy Markdown
Contributor Author

Ran it live. The test branch was recreated from fb729a6 (so it includes 95e4829) and a main snapshot was replayed on clone-cplace-fe: run 46423593537, success, snapshot job on fe-snapshot.yml@6481b99. 16 publishes with //cplace.jfrog.io/artifactory/api/npm/cplace-npm-test/:_authToken=${JFROG_TOKEN}, "authMode":"TOKEN", no auth errors, no leaks, no annotations. Recorded as T1r in live-test-plan.md §6 (e98db2a).

@Kaltenbach Kaltenbach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. All review points are closed: the specs match the trailing-slash rule (e98db2a), and the token .npmrc keying ran live (clone-cplace-fe run 46423593537). Thanks!

@Kaltenbach Kaltenbach added PR: Ready to Merge and removed PR: In Review The PR is currently being reviewed labels Nov 30, 2026
@vladimir-arsov
vladimir-arsov merged commit 87b8f01 into master Nov 30, 2026
2 checks passed
@vladimir-arsov
vladimir-arsov deleted the improvement/PFM-ISSUE-34293-Introduce-separate-JFrog-user-and-token-secrets branch November 30, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants