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

Require repo scope for PATs for private repos and basic authentication #24362

Merged
merged 6 commits into from
Apr 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: placate linter
Signed-off-by: jolheiser <john.olheiser@gmail.com>
jolheiser committed Apr 26, 2023
commit 3d9cefa89b720a94ae05671eceb45914e5fe7cb9
2 changes: 1 addition & 1 deletion modules/context/permission.go
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ func CheckRepoScopedToken(ctx *Context, repo *repo_model.Repository) {
var err error
scope, ok := ctx.Data["ApiTokenScope"].(auth_model.AccessTokenScope)
Copy link
Contributor

@wxiaoguang wxiaoguang Apr 26, 2023

Choose a reason for hiding this comment

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

If no test covers it, it is very fragile.

Maybe next refactoring changes the key "ApiTokenScope", then this "check" will become a noop, the accesses just pass it.

if ok { // it's a personal access token but not oauth2 token
scopeMatched := false
var scopeMatched bool
scopeMatched, err = scope.HasScope(auth_model.AccessTokenScopeRepo)
if err != nil {
ctx.ServerError("HasScope", err)