aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/http.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-11-07 14:46:13 -0500
committerUnknwon <joe2010xtmf@163.com>2014-11-07 14:46:13 -0500
commitabc57b6e439c5ab9c3b6ed2cedeb10d50f5ae619 (patch)
treef3625f90376d6c4fe2f1ee7a05ba23a5e0b10d9e /routers/repo/http.go
parenta01b4baca2c1a1d011f19f2255eb9b703658b3dd (diff)
downloadgitea-abc57b6e439c5ab9c3b6ed2cedeb10d50f5ae619.tar.gz
gitea-abc57b6e439c5ab9c3b6ed2cedeb10d50f5ae619.zip
work on #609
Diffstat (limited to 'routers/repo/http.go')
-rw-r--r--routers/repo/http.go27
1 files changed, 3 insertions, 24 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 3641f4dae6..0ce83cef4d 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -7,8 +7,6 @@ package repo
import (
"bytes"
"compress/gzip"
- "encoding/base64"
- "errors"
"fmt"
"io"
"io/ioutil"
@@ -16,6 +14,7 @@ import (
"os"
"os/exec"
"path"
+
"path/filepath"
"regexp"
"strconv"
@@ -29,27 +28,6 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-func basicEncode(username, password string) string {
- auth := username + ":" + password
- return base64.StdEncoding.EncodeToString([]byte(auth))
-}
-
-func basicDecode(encoded string) (user string, name string, err error) {
- var s []byte
- s, err = base64.StdEncoding.DecodeString(encoded)
- if err != nil {
- return user, name, err
- }
-
- a := strings.Split(string(s), ":")
- if len(a) == 2 {
- user, name = a[0], a[1]
- } else {
- err = errors.New("decode failed")
- }
- return user, name, err
-}
-
func authRequired(ctx *middleware.Context) {
ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=\".\"")
ctx.Data["ErrorMsg"] = "no basic auth and digit auth"
@@ -112,11 +90,12 @@ func Http(ctx *middleware.Context) {
auths := strings.Fields(baHead)
// currently check basic auth
// TODO: support digit auth
+ // FIXME: middlewares/context.go did basic auth check already
if len(auths) != 2 || auths[0] != "Basic" {
ctx.Handle(401, "no basic auth and digit auth", nil)
return
}
- authUsername, passwd, err = basicDecode(auths[1])
+ authUsername, passwd, err = base.BasicAuthDecode(auths[1])
if err != nil {
ctx.Handle(401, "no basic auth and digit auth", nil)
return