fix(auth): format and deduplicate dynamic scope fallback#352
Conversation
…ot in static scope lists When `gws auth login -s chat` (or any service not in the 7 static scope lists) is used, the static filter returns no matching scopes. Add a dynamic fallback that detects unmatched services and fetches their OAuth scopes from the Google Discovery API. This leverages the existing `fetch_discovery_document` with 24h caching. Fixes #236
…fetches Address review feedback: - Avoid per-service HashSet allocation in find_unmatched_services by collecting matched services first then computing the difference. - Use futures_util::future::join_all to fetch Discovery docs in parallel instead of sequentially.
…pping Share the service-name-to-scope-prefix mapping between scope_matches_service and find_unmatched_services via a single helper.
- Break long method chain in extract_scopes_from_doc to pass cargo fmt - Deduplicate dynamic scopes in augment_with_dynamic_scopes to prevent duplicate entries when dynamic results overlap with static ones
🦋 Changeset detectedLatest commit: 878f7dd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 refines the authentication scope resolution logic by addressing code formatting and preventing redundant scope entries. It ensures that dynamically fetched scopes are correctly integrated without introducing duplicates and improves code readability by reformatting a complex method chain, building upon previous work related to dynamic scope fetching. Highlights
Changelog
Activity
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 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 counter productive. 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully formats the code and adds a deduplication mechanism for dynamic scopes. The changes are logical and include relevant tests for the new functions. I have one suggestion to improve the performance of the scope deduplication logic.
Note: Security Review did not run due to the size of the PR.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #352 +/- ##
==========================================
+ Coverage 57.69% 62.11% +4.41%
==========================================
Files 38 38
Lines 14328 14760 +432
==========================================
+ Hits 8267 9168 +901
+ Misses 6061 5592 -469 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Follow-up to #246 — fixes two issues:
cargo fmt— breaks the long method chain inextract_scopes_from_doc()that was failing the Lint CI checkaugment_with_dynamic_scopes()now checks for duplicates before extending the result vec, preventing duplicate entries if dynamic scopes overlap with static onesChanges
extract_scopes_from_doc(): reformatteddoc.auth.as_ref().and_then(...)chain across multiple linesaugment_with_dynamic_scopes(): replacedresult.extend(dynamic)with a loop that skips scopes already presentVerification
cargo fmt --all— cleancargo clippy -- -D warnings— zero warningscargo test— 467 passed, 0 failedStacked on #246
Closes #236, #310, #316