Skip to content

fix(auth): include admin reports scopes#800

Open
Lubrsy706 wants to merge 3 commits into
googleworkspace:mainfrom
Lubrsy706:fix/admin-reports-scopes
Open

fix(auth): include admin reports scopes#800
Lubrsy706 wants to merge 3 commits into
googleworkspace:mainfrom
Lubrsy706:fix/admin-reports-scopes

Conversation

@Lubrsy706
Copy link
Copy Markdown

Fixes #765.

Summary

  • add Admin Reports audit and usage readonly scopes to full/readonly presets
  • surface the same scopes in the fallback scope picker
  • support --services admin-reports filtering and classify Admin Reports as Workspace-admin-only for recommended scope filtering

Tests

  • cargo fmt --check
  • cargo test -p google-workspace-cli admin_reports

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

⚠️ No Changeset found

Latest commit: 14ded8c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Google Workspace CLI by integrating support for Admin Reports API scopes. These changes ensure that audit and usage reporting scopes are available for selection, properly filtered, and correctly classified within the existing scope management framework.

Highlights

  • Scope Expansion: Added 'admin.reports.audit.readonly' and 'admin.reports.usage.readonly' scopes to the full and readonly preset configurations.
  • Scope Picker Update: Included the new Admin Reports scopes in the fallback scope picker and updated the CLI to support filtering by '--services admin-reports'.
  • Admin Classification: Classified Admin Reports scopes as workspace-admin-only to ensure they are correctly handled in recommended scope filtering.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for Google Workspace Admin Reports API scopes, specifically the audit and usage read-only scopes. The changes include updating scope constants, service mappings, and internal logic to identify these as admin-only scopes, supported by new unit tests. Feedback suggests generalizing the documentation and the is_workspace_admin_scope check to cover the entire admin.* scope family instead of just admin.reports.* to ensure consistency and reduce redundancy.

/// They are excluded from the "Recommended" preset to avoid login failures.
///
/// Affected scope families:
/// - `admin.reports.*` — Admin Reports API audit and usage reports
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The documentation for excluded scope families is incomplete. Since all admin.* scopes require Workspace admin privileges and are excluded from the Recommended preset, it is better to document the entire family rather than just admin.reports.*.

/// - admin.*            — Admin SDK (Directory, Reports, etc.)
References
  1. Avoid introducing changes that are outside the primary goal of a pull request to prevent scope creep.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in df4b7e8. I generalized the documented family and the implementation to admin.*, and added coverage for both Admin Directory and Admin Reports scopes.

.strip_prefix("https://www.googleapis.com/auth/")
.unwrap_or(url);
short.starts_with("apps.")
short.starts_with("admin.reports.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Checking specifically for admin.reports. is redundant because the caller (is_recommended_scope at line 923) already checks for the admin. prefix. Generalizing this check to admin. makes the function a consistent source of truth for identifying admin-only scopes and ensures all admin-related scopes are handled uniformly.

    short.starts_with("admin.")
References
  1. Avoid introducing changes that are outside the primary goal of a pull request to prevent scope creep.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in df4b7e8. I generalized the documented family and the implementation to admin.*, and added coverage for both Admin Directory and Admin Reports scopes.

@googleworkspace-bot
Copy link
Copy Markdown
Collaborator

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Google Workspace Admin Reports scopes, specifically adding audit and usage read-only scopes to the configuration and mapping logic. The changes include updates to scope presets, service-to-scope mapping, and classification of admin-only scopes, along with corresponding unit tests. Feedback was provided to refine the is_workspace_admin_scope check to include an exact match for the top-level 'admin' scope, ensuring all related scopes are correctly identified as admin-only to prevent potential authorization errors.

Comment on lines +1621 to +1622
short.starts_with("admin.")
|| short.starts_with("apps.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The check short.starts_with("admin.") will miss the exact match for the top-level https://www.googleapis.com/auth/admin scope if it is ever encountered. Including an exact match check ensures that the entire admin scope family is correctly classified as Workspace-admin-only, preventing potential 400 invalid_scope errors for personal accounts.

    short == "admin"
        || short.starts_with("admin.")
        || short.starts_with("apps.")

@googleworkspace-bot
Copy link
Copy Markdown
Collaborator

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for Google Admin Reports API scopes, specifically admin.reports.audit.readonly and admin.reports.usage.readonly. The changes include updating the full and read-only scope lists, mapping the admin-reports service to its corresponding scope prefix, and ensuring these scopes are correctly identified as workspace admin scopes. Additionally, unit tests were added to verify the availability and matching logic for these new scopes. I have no feedback to provide as there were no review comments to evaluate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing admin reports scopes in picker

2 participants