44package web
55
66import (
7- "net/http"
8-
9- "code.gitea.io/gitea/modules/setting"
107 "code.gitea.io/gitea/modules/web"
118 "code.gitea.io/gitea/routers/web/repo"
129 "code.gitea.io/gitea/services/context"
1310)
1411
1512func addOwnerRepoGitHTTPRouters (m * web.Router ) {
16- reqGitSignIn := func (ctx * context.Context ) {
17- if ! setting .Service .RequireSignInView {
18- return
19- }
20- // rely on the results of Contexter
21- if ! ctx .IsSigned {
22- // TODO: support digit auth - which would be Authorization header with digit
23- ctx .Resp .Header ().Set ("WWW-Authenticate" , `Basic realm="Gitea"` )
24- ctx .HTTPError (http .StatusUnauthorized )
25- }
26- }
2713 m .Group ("/{username}/{reponame}" , func () {
2814 m .Methods ("POST,OPTIONS" , "/git-upload-pack" , repo .ServiceUploadPack )
2915 m .Methods ("POST,OPTIONS" , "/git-receive-pack" , repo .ServiceReceivePack )
@@ -36,5 +22,5 @@ func addOwnerRepoGitHTTPRouters(m *web.Router) {
3622 m .Methods ("GET,OPTIONS" , "/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38,62}}" , repo .GetLooseObject )
3723 m .Methods ("GET,OPTIONS" , "/objects/pack/pack-{file:[0-9a-f]{40,64}}.pack" , repo .GetPackFile )
3824 m .Methods ("GET,OPTIONS" , "/objects/pack/pack-{file:[0-9a-f]{40,64}}.idx" , repo .GetIdxFile )
39- }, optSignInIgnoreCsrf , reqGitSignIn , repo .HTTPGitEnabledHandler , repo .CorsHandler (), context .UserAssignmentWeb ())
25+ }, optSignInIgnoreCsrf , repo .HTTPGitEnabledHandler , repo .CorsHandler (), context .UserAssignmentWeb ())
4026}
0 commit comments