diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-10-24 14:57:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-24 14:57:24 +0800 |
commit | ffff835b7338a25be96df8747a336f07afc49db2 (patch) | |
tree | cbacff25ec54160363e4b6c581ba195bc6f49747 | |
parent | 63c54f7e1f1132a6a96ea2f613e804d76d95f989 (diff) | |
download | gitea-ffff835b7338a25be96df8747a336f07afc49db2.tar.gz gitea-ffff835b7338a25be96df8747a336f07afc49db2.zip |
API should follow RequireSignInView (#8654) (#8661)
-rw-r--r-- | routers/api/v1/api.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 363379381a..3451cd5e8a 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -845,7 +845,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/topics", func() { m.Get("/search", repo.TopicSearch) }) - }, securityHeaders(), context.APIContexter(), sudo()) + }, securityHeaders(), reqTokenBySetting(), context.APIContexter(), sudo()) } func securityHeaders() macaron.Handler { @@ -857,3 +857,10 @@ func securityHeaders() macaron.Handler { }) } } + +func reqTokenBySetting() macaron.Handler { + if setting.Service.RequireSignInView { + return reqToken() + } + return func(ctx *macaron.Context) {} +} |