Skip to content

Commit 99703aa

Browse files
Gustedzeripath
authored andcommitted
Move /info outside authorization (go-gitea#19888)
- To use the web's API to get information about a issue/pull on a repository, doesn't require authorization(nor that the repository isn't archived). - Regressed by: go-gitea#19318 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Andrew Thornton <[email protected]>
1 parent 3a8be9e commit 99703aa

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

routers/web/repo/issue.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,21 @@ func GetIssueInfo(ctx *context.Context) {
17991799
}
18001800
return
18011801
}
1802+
1803+
if issue.IsPull {
1804+
// Need to check if Pulls are enabled and we can read Pulls
1805+
if !ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(unit.TypePullRequests) {
1806+
ctx.Error(http.StatusNotFound)
1807+
return
1808+
}
1809+
} else {
1810+
// Need to check if Issues are enabled and we can read Issues
1811+
if !ctx.Repo.CanRead(unit.TypeIssues) {
1812+
ctx.Error(http.StatusNotFound)
1813+
return
1814+
}
1815+
}
1816+
18021817
ctx.JSON(http.StatusOK, convert.ToAPIIssue(issue))
18031818
}
18041819

routers/web/web.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,11 @@ func RegisterRoutes(m *web.Route) {
841841
m.Combo("/compare/*", repo.MustBeNotEmpty, reqRepoCodeReader, repo.SetEditorconfigIfExists).
842842
Get(ignSignIn, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff).
843843
Post(reqSignIn, context.RepoMustNotBeArchived(), reqRepoPullsReader, repo.MustAllowPulls, bindIgnErr(forms.CreateIssueForm{}), repo.SetWhitespaceBehavior, repo.CompareAndPullRequestPost)
844+
m.Group("/{type:issues|pulls}", func() {
845+
m.Group("/{index}", func() {
846+
m.Get("/info", repo.GetIssueInfo)
847+
})
848+
})
844849
}, context.RepoAssignment, context.UnitTypes())
845850

846851
// Grouping for those endpoints that do require authentication
@@ -857,7 +862,6 @@ func RegisterRoutes(m *web.Route) {
857862
// So they can apply their own enable/disable logic on routers.
858863
m.Group("/{type:issues|pulls}", func() {
859864
m.Group("/{index}", func() {
860-
m.Get("/info", repo.GetIssueInfo)
861865
m.Post("/title", repo.UpdateIssueTitle)
862866
m.Post("/content", repo.UpdateIssueContent)
863867
m.Post("/deadline", bindIgnErr(structs.EditDeadlineOption{}), repo.UpdateIssueDeadline)

0 commit comments

Comments
 (0)