Skip to content

RTECO-2746 - Adding access-token-verify feature - #3758

Open
hanochg wants to merge 28 commits into
jfrog:masterfrom
hanochg:RTECO-2746-access-token-verify
Open

hanochg wants to merge 28 commits into
jfrog:masterfrom
hanochg:RTECO-2746-access-token-verify

Conversation

@hanochg

@hanochg hanochg commented Nov 10, 2026 •

Copy link
Copy Markdown

RTECO-2746 - Adding access-token-verify feature

Draft, and it won't build in CI yet. It needs jfrog/jfrog-cli-core#1632, which needs jfrog/jfrog-client-go#1406 (and #1405 / jfrog/jfrog-cli-core#1631). go.mod will be bumped to those versions before this leaves draft.

Summary

Adds jf access-token-verify (alias jf atv). It verifies a JFrog access token against the configured server and reports what kind of token it is:

  1. For a JWT, it verifies the signature against the server's Access root certificate and validates the claims and expiry.
  2. Only then does it call GET /access/api/v1/tokens/me with the token, and only a token the server accepts is valid.
  3. A value that isn't a JWT is sent to that endpoint as a possible reference token, and its details come from the server.

The output starts with the token's format, JWT or Reference, and JSON output has a format field.

jf atv                               # paste the token at the hidden prompt
jf atv --token-file=<path>
jf atc | jf atv                      # stdin is the default; jf atc's JSON output is accepted as is
jf atv --format=json | jq .types
  • Token input. The token comes from --token-file or stdin (the default). JSON input is read for its access_token value. An argument is rejected, because arguments are visible to other processes and kept in shell history.
    • In a terminal, atv prompts on stderr and reads one line without echoing it, in raw mode and with its own reader, so long tokens aren't cut (no 1,024-byte canonical-mode limit, no 4,096-character x/term limit). Whatever is still in the terminal after that line is discarded before the terminal is restored, so a multi-line paste can never reach the shell as typed input; a multi-line paste is rejected.
    • Terminals that can't hide input (Git Bash and other Cygwin/MSYS2 ptys) get an error that points to --token-file or a pipe.
    • The input is cleaned of a BOM, CRLF line endings, Bearer and surrounding quotes. UTF-16 input with a BOM (Windows PowerShell 5.1 redirection) is decoded.
    • An empty --token-file path is an error, not a silent fallback to stdin.
  • Server. Only the configured server is used: --server-id, JFROG_CLI_SERVER_ID, or the default.
    • There is no --url, no credential flag and no --insecure-tls. Private CAs go in ~/.jfrog/security/certs.
    • The profile's credentials are never used to verify the token, and its tokens are never refreshed.
    • http:// servers get a warning.
  • Output. A FIELD/VALUE table by default, with a TYPE block when the token is valid. --format=json writes {valid, error, header, payload, types}.
    • The payload is printed even when verification fails.
    • Control and format characters in claims are escaped in the table, so an unverified token can't inject terminal sequences or fake rows. JSON output writes DEL, C1 controls and format characters as \u escapes.
    • A verification failure is logged by the command itself, with control characters escaped, and the command exits 1 without returning the message. So the JFROG_CLI_ERROR_OUTPUT_FORMAT=json handler can't parse a claim such as typ: "server response: 200 OK" as an HTTP error and print a second JSON object.
    • The exit code is 1 for any failure.
  • Token types. They come from the token's scopes only, one per kind of scope, so a token can have several: Identity, Admin, Applied Permissions Groups, Roles and Entitlements, Scoped, Connect Pairing, Connect Device, and Internal Token for any other internal: scope. Quoted scopes and the legacy member-of-groups: and api:* scopes are recognized.
  • Help. docs/general/tokenverify/help.go has the usage and the AI description.

Tests

  • general/token/verify_test.go covers:
    • token sources (including the rejected argument), cleanup, UTF-16 and JSON input;
    • the hidden-prompt line reader: editing keys, escape sequences, Ctrl-C/Ctrl-D, leftover input, lines longer than 4,096 characters and the 64 KiB cap;
    • empty-input errors;
    • server lookup without prompting;
    • the exact flag set (server-id, token-file, format);
    • table and JSON output, including control- and format-character escaping;
    • verification failures kept away from the generic error handlers;
    • unsupported formats.
  • main_test.go: TestAccessTokenVerifyRegistered.
  • access_test.go: TestAccessTokenVerify mints tokens with jf atc and verifies them against the configured default server.
    • It covers identity, admin, scoped, groups and non-expiring tokens, a valid reference token (format Reference, its token_id matching the minted one), --token-file with a bare token and with jf atc JSON, and the revoked JWT, revoked reference token, non-token value, tampered, locally signed and unknown-server failures.
    • Every case asserts the token never appears in the output.
    • Tokens are passed with --token-file. A separate case checks that a token passed as an argument is rejected and never echoed.
    • It runs in the GitHub access workflow and in the external-Artifactory suite (it is not in skip_tests).
  • Manual pty test of the hidden prompt: pasting jf atc's multi-line JSON is rejected, nothing is echoed, and the next program reading the terminal gets nothing (a plain line reader in the same setup leaks the token's line).
  • Manual smoke test of the built binary against a mock Access server:
    • file and stdin input;
    • a tampered token exits 1;
    • any argument, even an empty "$TOKEN", exits 1 before stdin is read, without echoing the argument;
    • the token doesn't appear in JFROG_CLI_LOG_LEVEL=DEBUG output.

🤖 Generated with Claude Code

hanochg and others added 4 commits November 10, 2026 16:08
New command 'jf access-token-verify' (alias 'atv') verifies a JFrog
access token against the configured server and reports its type. The
token comes from the argument, --token-file, or stdin (with a hidden
prompt in a terminal); JSON input such as 'jf atc' output is read for
its access_token value. Output is a table by default, or JSON with
--format=json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mints tokens with 'jf atc' and verifies them with 'jf atv' against the
configured default server: identity, admin, scoped, groups and
non-expiring tokens, file and JSON input, and the reference, revoked,
tampered, locally signed and unknown-server failures. Every case checks
the token never appears in the output.

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

The payload is printed even when verification fails, so control and
format characters in claims are now escaped instead of reaching the
terminal raw. An empty token argument or --token-file path is now an
error instead of a silent switch to reading stdin. The help no longer
says the profile's credentials are unused.

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

The case revoked its token and the cleanup revoked it again, and the
cleanup asserts HTTP 200.

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

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@hanochg

hanochg commented Nov 10, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hanochg and others added 20 commits November 19, 2026 15:05
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dlers

The verification error can quote token claims and server text. It is now
escaped and logged by the command, which exits 1 without returning the
message, so the JSON error handler can't parse it as an HTTP error and print
a second, forged JSON object. JSON output also escapes DEL, C1 controls and
Unicode format characters. The integration suite runs in the external
Artifactory pipeline too, and checks that readiness rejects anonymous
requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Command-line arguments are visible to other processes and kept in shell
history, so atv now rejects any argument and reads the token only from
--token-file or stdin. The integration tests pass tokens through
--token-file. The anonymous readiness case is removed: Access readiness
answers 200 to anonymous requests, so the revoked-token case is what shows
that a presented token is checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The output now starts with the token's format, JWT or Reference, and JSON
output has a format field. For a reference token, the table lists the token
details the server returned, with its epoch fields as dates. The help
describes the tokens/me check and reference tokens, and the integration
tests verify a reference token, a revoked reference token and a value that
isn't a token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ixing input, output and help gaps

- The hidden prompt reads its own line without x/term's 4096-character cap, discards whatever is left in the terminal so it can't reach the shell, and rejects multi-line pastes.
- Git Bash and other Cygwin terminals, which can't hide input, get an error instead of an echoed prompt.
- UTF-16 token files (Windows PowerShell 5.1 redirection) are decoded.
- A non-object ext claim is shown in the table.
- The help and --token-file text match the current behaviour.
- tokenUnderTest is renamed to tokenUnderInvestigation, and non-critical comments are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g the INTERNAL column

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a single error line

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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…olor version has

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n the atv help

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d fixing the revoked JWT test expectation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g Artifactory audience rejections

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…se the configured server

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hanochg and others added 3 commits November 29, 2026 12:24
…rence token without details

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng the expected messages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…itespace in the token and showing less than a minute left

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hanochg hanochg reopened this Nov 30, 2026
@hanochg
hanochg marked this pull request as ready for review November 30, 2026 11:42

This branch is waiting to be deployed

1 waiting deployment
build-gate — 86a448cf Waiting Nov 30, 2026 by hanochg via Approval gate #1422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant