Skip to content

Commit 744e452

Browse files
Gustedzeripath
Gusted
andauthored
Move /info outside authorization (#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: #19318 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Andrew Thornton <[email protected]>
1 parent 12c742f commit 744e452

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

routers/web/repo/issue.go

+15
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

+5-1
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,11 @@ func RegisterRoutes(m *web.Route) {
835835
m.Combo("/compare/*", repo.MustBeNotEmpty, reqRepoCodeReader, repo.SetEditorconfigIfExists).
836836
Get(ignSignIn, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff).
837837
Post(reqSignIn, context.RepoMustNotBeArchived(), reqRepoPullsReader, repo.MustAllowPulls, bindIgnErr(forms.CreateIssueForm{}), repo.SetWhitespaceBehavior, repo.CompareAndPullRequestPost)
838+
m.Group("/{type:issues|pulls}", func() {
839+
m.Group("/{index}", func() {
840+
m.Get("/info", repo.GetIssueInfo)
841+
})
842+
})
838843
}, context.RepoAssignment, context.UnitTypes())
839844

840845
// Grouping for those endpoints that do require authentication
@@ -851,7 +856,6 @@ func RegisterRoutes(m *web.Route) {
851856
// So they can apply their own enable/disable logic on routers.
852857
m.Group("/{type:issues|pulls}", func() {
853858
m.Group("/{index}", func() {
854-
m.Get("/info", repo.GetIssueInfo)
855859
m.Post("/title", repo.UpdateIssueTitle)
856860
m.Post("/content", repo.UpdateIssueContent)
857861
m.Post("/deadline", bindIgnErr(structs.EditDeadlineOption{}), repo.UpdateIssueDeadline)

0 commit comments

Comments
 (0)