Skip to content

Add login --add-scope to keep the stored sign-in's scopes - #69

Open
sunilmehta-si wants to merge 1 commit into
prooflinedev:mainfrom
sunilmehta-si:login-add-scope
Open

sunilmehta-si wants to merge 1 commit into
prooflinedev:mainfrom
sunilmehta-si:login-add-scope

Conversation

@sunilmehta-si

Copy link
Copy Markdown

Who this helps

Anyone signed in with proofline login who needs one more scope. Scans need scans:request, exports need analytics:read, and configuration needs setup:write and org:configure, while the default sign-in has none of them.

Today --scope replaces the defaults, so adding one scope means retyping every scope the sign-in already holds. The CLI's own hint makes this worse. When a scan is refused for a missing scope, it prints:

run `proofline login --scope reviews:read --scope findings:read --scope reviews:request --scope scans:request`

Someone who followed the configuration or export instructions earlier loses setup:write, org:configure or analytics:read by running it, and only finds out when the next command is refused.

What this adds

proofline login --add-scope SCOPE (repeatable) asks for the scopes of the sign-in stored for that console plus the scopes you name:

$ proofline login --add-scope scans:request
Asking for reviews:read findings:read reviews:request analytics:read scans:request.
Your sign-in code is ...

The scan refusal now suggests proofline login --add-scope scans:request.

Decisions

  • A new flag, not a change to --scope or to plain login. Both keep their current meaning, so scripts, the installer and the documented sign-in commands behave as before.
  • It starts from the stored sign-in's granted scopes, which are what the approval page actually granted, not what was asked for. An expired sign-in still counts, because a re-login after expiry is when people lose scopes. With nothing stored, or an unreadable entry, it starts from the defaults. So for someone not signed in, --add-scope scans:request asks for exactly the list the old hint did.
  • It prints the full list before the browser opens, so the person can see what they are about to approve. The approval page can still narrow it.
  • --add-scope conflicts with --scope. Combining "replace" and "add" has no obvious meaning, so clap refuses it.
  • Left alone: the configuration hint (config::LOGIN), which the installer, the agent setup message and two tests use as the canonical first sign-in. It could suggest --add-scope too when a stored sign-in lacks a configuration scope. I kept this change small and can do that next if you want.

How I verified it

  • cargo fmt --check and cargo clippy --locked --all-targets -- -D warnings are clean.
  • cargo test --locked --no-fail-fast: everything passes except agent_install::unattended_registration_preserves_settings_and_uses_the_installed_binary, which fails the same way on an unmodified main on macOS (/var/... vs /private/var/...).
  • New unit tests cover keeping the stored scopes, dropping duplicates, falling back to the defaults, and the --scope conflict. The scan test now pins the new hint.
  • End to end on macOS with the real keychain, against a loopback stand-in for /auth/device/code and /auth/device/token that logs the requested scopes and approves them:
Step Scopes the CLI asked for
login --scope reviews:read --scope findings:read --scope reviews:request --scope analytics:read reviews:read findings:read reviews:request analytics:read
login --add-scope scans:request reviews:read findings:read reviews:request analytics:read scans:request
login --scope scans:request (the old hint, for comparison) scans:request
login --add-scope scans:request with nothing stored reviews:read findings:read reviews:request scans:request
login --scope a --add-scope b refused: the argument '--scope <SCOPE>' cannot be used with '--add-scope <SCOPE>'

proofline status showed the same scopes after each sign-in, and proofline logout removed the test entries afterwards.

`proofline login --scope` replaces the default scopes, so adding one
scope meant retyping every scope of the current sign-in. The scan
refusal printed such a command with a fixed list, and following it
dropped any other scope the sign-in held, such as analytics:read or
org:configure.

`--add-scope SCOPE` asks for the scopes of the sign-in stored for the
console, even an expired one, plus the named scopes, and starts from the
defaults when nothing is stored. It prints the full list before the
browser opens and cannot be combined with `--scope`. The scan refusal
now suggests `proofline login --add-scope scans:request`, which asks for
the same scopes as before when nothing is stored.

This branch has not been deployed

No deployments
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