Skip to content

auth login: requesting new scopes on an existing login silently succeeds; invalid-scope error doesn't name the scope #552

Closed

Description

@heredia21

Version: 1.0.0-beta.28, Linux (headless server, OAuth device flow)

What happened

I needed to add one scope (billing.read) to an existing OAuth login that many scheduled jobs on a headless server depend on.

  1. cf login --device --no-browser --scopes <current scopes> billing.read while already logged in prints:
    ●  You are already logged in.
    │  Run cf auth login --force to re-authenticate, or cf auth logout to log out.
    
    and exits 0. The requested scopes are ignored, so a script can't tell that nothing changed.
  2. Re-requesting the scopes the stored login already holds (read from the config file) plus the new one, with cf auth login --force --device --no-browser --scopes …, fails with:
    One or more of the requested scopes are not valid cf OAuth scopes.
    
    It doesn't say which ones. The stored grant includes scopes such as openid, offline, offline_access that apparently can't be requested, so the saved list can't be reused as-is.

Why it matters

On a headless box shared by many jobs, adding one permission currently means a full forced re-login with the default scopes and guessing what's requestable. The safest path isn't obvious (an auth --profile dedicated to the new scope, which I found later).

Suggestions

  • When --scopes asks for something the current login doesn't have, either re-authenticate or exit non-zero with a clear message, instead of exiting 0.
  • Name the invalid scopes in the error.
  • An --add-scopes (or cf auth scopes add) that requests the current grant plus the new scopes, skipping ones that aren't requestable.
  • In cf auth login --help, mention --profile as the way to hold a separate login for extra permissions without touching the default one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions