Repository navigation
PFM-ISSUE-34293 - Introduce separate JFrog user and token secrets (plain _authToken) - #191
Conversation
…-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
left a comment
There was a problem hiding this comment.
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.
|
|
||
| | 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` | |
There was a problem hiding this comment.
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 /.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| | `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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| const onReleaseBranch = this.currentBranch.startsWith( | ||
| ArtifactsHandler.RELEASE_BRANCH_PREFIX | ||
| ); | ||
| if (this.releaseFlow) return onReleaseBranch || this.force; |
There was a problem hiding this comment.
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_VERSIONon 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).
There was a problem hiding this comment.
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.
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>
…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>
|
Ran it live. The test branch was recreated from |
Kaltenbach
left a comment
There was a problem hiding this comment.
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!
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:
.npmrcJFROG_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 envJFROG_BASE64_TOKEN_authfile, unchanged::warning::deprecation annotation::error::No JFrog credentials: …before build, publish, delete or the release-version fileChanges
tools/scripts/artifacts/jfrog-credentials.ts: readsJFROG_TOKEN,authMode(TOKEN / LEGACY / NONE, decided by truthiness because an unpassed optional secret arrives as''),requireForPublishing(), andtoJSON()so the handler's "Configuration" log line never contains a secret.nx-project.ts:writeNPMRCInDistwrites the token or the legacy format. Both use the keygetJfrogUrlNoHttp()produces. npm looks credentials up by walking the registry URL prefix by prefix, so a trailing slash inJFROG_URLdoesn'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.fe-snapshot,fe-pr-snapshot,fe-pr-close,fe-cleanup-snapshots,fe-release,fe-tag,fe-release-flow) declareJFROG_TOKENandJFROG_BASE64_TOKENas optional and pass both to every artifacts step (8 env blocks).JFROG_TOKEN. The README documents the JFrog and npm secrets contract and how to migrate..npmrc(only the placeholder, never the value) and secret redaction.research.md,design.md,plan.md,live-test-plan.md,review.mdunderspecs/2026-11-23_PFM-ISSUE-34293_jfrog-authtoken-separate-secrets/.Migration for consumers: add a
JFROG_TOKENrepository secret and pass it in place ofJFROG_BASE64_TOKEN; callers usingsecrets: inheritonly need the secret. Callers that still passJFROG_BASE64_TOKENkeep working and get the deprecation warning. A caller must not passJFROG_TOKENto@masterbefore this PR is merged, because master doesn't declare that secret yet.Live validation (
clone-cplace-feagainstcplace-npm-test).npmrc, 0 auth errors, 0 leaksnpm show, unpublish and republish of 16release-26.4-pending, promoted to26.4.11, tag pushed.npmrc, one deprecation warning26.4.12npm unpublishAcross 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
masterbefore this change, each needing its own ticket):fe-release-flowskipsgithub-releasewhenRUN_E2E: false, because a skippede2ejob makes the implicitsuccess()false. The releasesversion/26.4.11andversion/26.4.12were created by hand.npm searchlists a package thatnpm viewthen can't find (E404). Upstreamcplace-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:
to Guidelines
🤖 Generated with Claude Code