fix(auth): include admin reports scopes#800
Conversation
|
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
- Avoid introducing changes that are outside the primary goal of a pull request to prevent scope creep.
There was a problem hiding this comment.
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.") |
There was a problem hiding this comment.
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
- Avoid introducing changes that are outside the primary goal of a pull request to prevent scope creep.
There was a problem hiding this comment.
Done in df4b7e8. I generalized the documented family and the implementation to admin.*, and added coverage for both Admin Directory and Admin Reports scopes.
|
/gemini review |
There was a problem hiding this comment.
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.
| short.starts_with("admin.") | ||
| || short.starts_with("apps.") |
There was a problem hiding this comment.
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.")|
/gemini review |
There was a problem hiding this comment.
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.
Fixes #765.
Summary
--services admin-reportsfiltering and classify Admin Reports as Workspace-admin-only for recommended scope filteringTests
cargo fmt --checkcargo test -p google-workspace-cli admin_reports