Uh oh!
There was an error while loading. Please reload this page.
Model OAuth scope policies - #3128
Open
SamMorrowDrums wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces explicit OAuth authorization policies with alternative paths, conjunctive requirements, and argument-aware scope resolution.
Changes:
- Adds policy modeling, evaluation, hierarchy traversal, and compatibility projection.
- Resolves scopes dynamically for repository/org operations and workflow-file writes.
- Adds path validation, middleware integration, documentation, and tests.
Show a summary per file
| File | Description |
|---|---|
pkg/scopes/scopes.go | Implements policy construction and evaluation. |
pkg/scopes/scopes_test.go | Tests policy semantics and hierarchy expansion. |
pkg/scopes/map.go | Maps and resolves tool scope policies. |
pkg/scopes/map_test.go | Tests call-specific policy resolution. |
pkg/inventory/server_tool.go | Adds policy metadata to tools. |
pkg/inventory/server_tool_test.go | Verifies path headers are excluded. |
pkg/http/middleware/scope_challenge.go | Applies resolved policies to OAuth challenges. |
pkg/http/middleware/scope_challenge_test.go | Tests argument-aware challenges. |
pkg/github/ui_tools.go | Adds a scope resolver to ui_get. |
pkg/github/tool_scopes.go | Defines repository/org and UI policies. |
pkg/github/tool_scopes_test.go | Tests conditional tool policies. |
pkg/github/scope_filter.go | Filters tools using authorization paths. |
pkg/github/scope_filter_test.go | Tests compatibility and fail-open behavior. |
pkg/github/repository_path.go | Validates paths and detects workflow writes. |
pkg/github/repository_path_test.go | Tests path safety and workflow policies. |
pkg/github/repositories.go | Applies validation and dynamic write policies. |
pkg/github/issues.go | Adds issue-type scope resolution. |
pkg/github/issue_fields.go | Adds issue-field scope resolution. |
pkg/github/header_params_test.go | Ensures paths remain in MCP arguments. |
pkg/github/dependencies.go | Initializes legacy-compatible policies. |
docs/scope-filtering.md | Documents the policy model. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 21/21 changed files
- Comments generated: 2
- Review effort level: Balanced
Comment on lines
+37
to
+42
| switch method { | ||
| case "labels", "assignees", "milestones", "branches", "issue_fields", "reviewers": | ||
| if repo, ok := arguments["repo"].(string); ok && repo != "" { | ||
| return scopes.AllOfScopePolicy(scopes.Repo) | ||
| } | ||
| } |
Comment on lines
+61
to
+78
| for _, file := range files { | ||
| fileMap, ok := file.(map[string]any) | ||
| if !ok { | ||
| return scopes.UnscopedScopePolicy() | ||
| } | ||
| value, ok := fileMap["path"].(string) | ||
| if !ok { | ||
| return scopes.UnscopedScopePolicy() | ||
| } | ||
| cleaned, err := validateRelativePath(value) | ||
| if err != nil { | ||
| return scopes.UnscopedScopePolicy() | ||
| } | ||
| if isWorkflowPath(cleaned) { | ||
| return scopes.AllOfScopePolicy(scopes.Repo, scopes.Workflow) | ||
| } | ||
| } | ||
| return scopes.AllOfScopePolicy(scopes.Repo) |
SamMorrowDrumsforce-pushed
the
sammorrowdrums-scope-policy-model
branch
from
August 21, 2026 00:16
442d43f to
96f14fdCompareModel authorization as alternative paths with conjunctive requirements and per-requirement scope alternatives. Resolve call-specific policies from tool arguments for precise PAT filtering and OAuth challenges. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 26e41558-43f9-42b2-8569-8489957c2b0a
SamMorrowDrumsforce-pushed
the
sammorrowdrums-scope-policy-model
branch
from
August 21, 2026 00:18
96f14fd to
05d9ff1Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Give each tool one explicit OAuth scope policy instead of flattening scopes into lists.
A policy describes:
Tools may resolve a more specific policy from call arguments before an OAuth challenge.
Why
A flat list cannot distinguish
repo OR read:orgfromrepo AND workflow. That caused two opposite problems: PAT filtering could show tools a token could not use, while stricter interpretations could hide tools or request scopes the chosen operation did not need.What changed
list_issue_fields,list_issue_types, andui_getfrom their arguments.repoandworkflowonly for workflow-file writes.repoanddelete_repotogether.list-scopes, and generated tool docs to use the same policy.Related work
Supersedes #2778 and #3092.