We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e530568 commit 8214177Copy full SHA for 8214177
routers/api/v1/api.go
@@ -407,6 +407,21 @@ func reqRepoReader(unitType unit.Type) func(ctx *context.APIContext) {
407
ctx.Error(http.StatusForbidden, "reqRepoReader", "user should have specific read permission or be a repo admin or a site admin")
408
return
409
}
410
+
411
+ if true == ctx.Data["IsApiToken"] {
412
+ switch unitType {
413
+ case unit.TypeCode:
414
+ publicRepo, pubRepoExists := ctx.Data["ApiTokenScopePublicRepoOnly"]
415
416
+ if pubRepoExists && publicRepo.(bool) &&
417
+ ctx.Repo.Repository != nil && ctx.Repo.Repository.IsPrivate {
418
+ ctx.Error(http.StatusForbidden, "reqToken", "token scope is limited to public repos")
419
+ return
420
+ }
421
422
423
424
425
426
427
0 commit comments