diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-04-10 22:12:32 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-04-10 22:12:32 +0800 |
commit | 16b6e5d50b665c5376b61ca7d02e3716a1c05ead (patch) | |
tree | 47abc80f5c6cc23384baa68b980439409e475d48 /routers/repo/repo.go | |
parent | 9791e70da67091d244728070b80ee92c98d6aa8b (diff) | |
download | gitea-16b6e5d50b665c5376b61ca7d02e3716a1c05ead.tar.gz gitea-16b6e5d50b665c5376b61ca7d02e3716a1c05ead.zip |
bug fixed
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r-- | routers/repo/repo.go | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go index d223600c52..6b002f6c81 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -14,8 +14,6 @@ import ( "github.com/go-martini/martini" - "github.com/gogits/webdav" - "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" @@ -266,89 +264,6 @@ func authRequired(ctx *middleware.Context) { ctx.HTML(401, fmt.Sprintf("status/401")) } -func Http(ctx *middleware.Context, params martini.Params) { - username := params["username"] - reponame := params["reponame"] - if strings.HasSuffix(reponame, ".git") { - reponame = reponame[:len(reponame)-4] - } - - //fmt.Println("req:", ctx.Req.Header) - - repoUser, err := models.GetUserByName(username) - if err != nil { - ctx.Handle(500, "repo.GetUserByName", nil) - return - } - - repo, err := models.GetRepositoryByName(repoUser.Id, reponame) - if err != nil { - ctx.Handle(500, "repo.GetRepositoryByName", nil) - return - } - - isPull := webdav.IsPullMethod(ctx.Req.Method) - var askAuth = !(!repo.IsPrivate && isPull) - - //authRequired(ctx) - //return - - // check access - if askAuth { - // check digit auth - - // check basic auth - baHead := ctx.Req.Header.Get("Authorization") - if baHead == "" { - authRequired(ctx) - return - } - - auths := strings.Fields(baHead) - if len(auths) != 2 || auths[0] != "Basic" { - ctx.Handle(401, "no basic auth and digit auth", nil) - return - } - authUsername, passwd, err := basicDecode(auths[1]) - if err != nil { - ctx.Handle(401, "no basic auth and digit auth", nil) - return - } - - authUser, err := models.GetUserByName(authUsername) - if err != nil { - ctx.Handle(401, "no basic auth and digit auth", nil) - return - } - - newUser := &models.User{Passwd: passwd} - newUser.EncodePasswd() - if authUser.Passwd != newUser.Passwd { - ctx.Handle(401, "no basic auth and digit auth", nil) - return - } - - var tp = models.AU_WRITABLE - if isPull { - tp = models.AU_READABLE - } - - has, err := models.HasAccess(authUsername, username+"/"+reponame, tp) - if err != nil || !has { - ctx.Handle(401, "no basic auth and digit auth", nil) - return - } - } - - dir := models.RepoPath(username, reponame) - - prefix := path.Join("/", username, params["reponame"]) - server := webdav.NewServer( - dir, prefix, true) - - server.ServeHTTP(ctx.ResponseWriter, ctx.Req) -} - func Setting(ctx *middleware.Context, params martini.Params) { if !ctx.Repo.IsOwner { ctx.Handle(404, "repo.Setting", nil) |