Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added globus auth scope show command #1077

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

derek-globus
Copy link
Contributor

@derek-globus derek-globus commented Jan 31, 2025

Added

  • New command globus auth scope show SCOPE_ID_OR_STRING
    • Note: globus auth is a hidden command tree; Stephen and I discussed keeping it that way until we have 5+ commands registered under there.
  • New FieldFormatters:
    • ArrayMultilineFormatter(ArrayFormatter) - Supports multiline formatted elements, adding a yaml-style - element start indicator to the beginning of each new one.
    • RecordFormatter - Prints an object using the RecordPrinter into a buffered string.
  • New util,LazyDict - A dict with "key loaders" which will load values for specific keys when accessed the first time, caching the result.
  • New termio module: terminal_info with a global singleton TERM_INFO to centrally track and mutate content width.

Changed

  • Empty arrays render as [] instead of nothing.

Draft

  • This PR is in draft until:
    1. I have a chance to put the command in front of the auth team.
    2. I figure out how to figure out reserved_width in RecordFormatter; it's a pretty minute thing but is hardcoded right now.

Auth team has signed off in slack & I figured it out!

Usage

By Scope ID

Standard Output (dependent scope strings get loaded in a secondary batched call)

> globus auth scope show 24f3dcbe-7655-4721-bc64-d1c5d635b9a1
Scope String:          https://auth.globus.org/scopes/actions.globus.org/hello_world
Scope ID:              24f3dcbe-7655-4721-bc64-d1c5d635b9a1
Name:                  Hello World Action
Description:           Allow the Hello World action to extend greetings.
Client ID:             5fac2e64-c734-4e6b-90ea-ff12ddbf9653
Allows Refresh Tokens: True
Required Domains:      
Advertised:            True
Dependent Scopes:      
  - Scope String:           urn:globus:auth:scope:nexus.api.globus.org:groups
    Scope ID:               69a73d8f-cd45-4e37-bb3b-43678424aeb7
    Optional:               False
    Requires Refresh Token: False
  - Scope String:           urn:globus:auth:scope:groups.api.globus.org:view_my_groups_and_memberships
    Scope ID:               73320ffe-4cb4-4b25-a0a3-83d53d59ce4f
    Optional:               False
    Requires Refresh Token: False

JSON Output (no secondary dependent scope resolution call happens)

> globus auth scope show 24f3dcbe-7655-4721-bc64-d1c5d635b9a1 -F json                
{
  "scope": {
    "advertised": true,
    "allows_refresh_token": true,
    "client": "5fac2e64-c734-4e6b-90ea-ff12ddbf9653",
    "dependent_scopes": [
      {
        "optional": false,
        "requires_refresh_token": false,
        "scope": "69a73d8f-cd45-4e37-bb3b-43678424aeb7"
      },
      {
        "optional": false,
        "requires_refresh_token": false,
        "scope": "73320ffe-4cb4-4b25-a0a3-83d53d59ce4f"
      }
    ],
    "description": "Allow the Hello World action to extend greetings.",
    "id": "24f3dcbe-7655-4721-bc64-d1c5d635b9a1",
    "name": "Hello World Action",
    "required_domains": [],
    "scope_string": "https://auth.globus.org/scopes/actions.globus.org/hello_world"
  }
}

By Scope String

Similarly when accessing by scope string

> globus auth scope show https://auth.globus.org/scopes/actions.globus.org/hello_world
Scope String:          https://auth.globus.org/scopes/actions.globus.org/hello_world
Scope ID:              24f3dcbe-7655-4721-bc64-d1c5d635b9a1
Name:                  Hello World Action
Description:           Allow the Hello World action to extend greetings.
Client ID:             5fac2e64-c734-4e6b-90ea-ff12ddbf9653
Allows Refresh Tokens: True
Required Domains:      
Advertised:            True
Dependent Scopes:      
  - Scope String:           urn:globus:auth:scope:nexus.api.globus.org:groups
    Scope ID:               69a73d8f-cd45-4e37-bb3b-43678424aeb7
    Optional:               False
    Requires Refresh Token: False
  - Scope String:           urn:globus:auth:scope:groups.api.globus.org:view_my_groups_and_memberships
    Scope ID:               73320ffe-4cb4-4b25-a0a3-83d53d59ce4f
    Optional:               False
    Requires Refresh Token: False

JSON by scope string uses a the get-scopes route so response is a list of one element

> globus auth scope show https://auth.globus.org/scopes/actions.globus.org/hello_world -F json
{
  "scopes": [
    {
      "advertised": true,
      "allows_refresh_token": true,
      "client": "5fac2e64-c734-4e6b-90ea-ff12ddbf9653",
      "dependent_scopes": [
        {
          "optional": false,
          "requires_refresh_token": false,
          "scope": "69a73d8f-cd45-4e37-bb3b-43678424aeb7"
        },
        {
          "optional": false,
          "requires_refresh_token": false,
          "scope": "73320ffe-4cb4-4b25-a0a3-83d53d59ce4f"
        }
      ],
      "description": "Allow the Hello World action to extend greetings.",
      "id": "24f3dcbe-7655-4721-bc64-d1c5d635b9a1",
      "name": "Hello World Action",
      "required_domains": [],
      "scope_string": "https://auth.globus.org/scopes/actions.globus.org/hello_world"
    }
  ]
}

@kurtmckee
Copy link
Member

globus auth is a hidden command tree; Stephen and I discussed keeping it that way until we have 5+ commands registered under there

Why?

@sirosen
Copy link
Member

sirosen commented Jan 31, 2025

globus auth is a hidden command tree; Stephen and I discussed keeping it that way until we have 5+ commands registered under there

Why?

Because the launch of a globus auth command tree should potentially include aliasing/renaming and deprecation of existing commands like globus get-identities. We agreed on hidden commands as an easy way for us to continue to discuss exactly what should happen to the CLI when we add globus auth commands without blocking work, and that once there are a handful of commands implemented, the downside of holding back a release outweighs the potential upsides of making more adjustments for the initial release of these commands.

We can reopen this debate, but let's not do it in this PR thread.

src/globus_cli/termio/terminal_info.py Show resolved Hide resolved
src/globus_cli/types.py Show resolved Hide resolved
src/globus_cli/utils.py Show resolved Hide resolved
@derek-globus derek-globus marked this pull request as ready for review February 3, 2025 20:08
@derek-globus
Copy link
Contributor Author

derek-globus commented Feb 3, 2025

Auth has confirmed their comfort with (1) this command structure proposal and (2) the decisions made in this PR that diverge our display slightly from their raw api.

So this guy is open for business!

src/globus_cli/termio/formatters/compound.py Outdated Show resolved Hide resolved
src/globus_cli/termio/formatters/compound.py Outdated Show resolved Hide resolved
src/globus_cli/termio/formatters/compound.py Show resolved Hide resolved
src/globus_cli/termio/printers/record_printer.py Outdated Show resolved Hide resolved
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.

3 participants