aboutsummaryrefslogtreecommitdiff
path: root/internal/auth
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-04-04 21:14:15 +0800
committerGitHub <noreply@github.com>2020-04-04 21:14:15 +0800
commit34145c990d4fd9f278f29cdf9c61378a75e9b934 (patch)
tree7b151bbd5aef9e487759953e3a775a82244d268d /internal/auth
parent2bd9d0b9c8238ded727cd98a3ace20b53c10a44f (diff)
lfs: implement HTTP routes (#6035)
* Bootstrap with GORM * Fix lint error * Set conn max lifetime to one minute * Fallback to use gorm v1 * Define HTTP routes * Finish authentication * Save token updated * Add docstring * Finish authorization * serveBatch rundown * Define types in lfsutil * Finish Batch * authutil * Finish basic * Formalize response error * Fix lint errors * authutil: add tests * dbutil: add tests * lfsutil: add tests * strutil: add tests * Formalize 401 response
Diffstat (limited to 'internal/auth')
-rw-r--r--internal/auth/auth.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go
index 05751c05..43d7f2e5 100644
--- a/internal/auth/auth.go
+++ b/internal/auth/auth.go
@@ -48,18 +48,18 @@ func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bo
// Let's see if token is valid.
if len(tokenSHA) > 0 {
- t, err := db.GetAccessTokenBySHA(tokenSHA)
+ t, err := db.AccessTokens.GetBySHA(tokenSHA)
if err != nil {
- if !db.IsErrAccessTokenNotExist(err) && !db.IsErrAccessTokenEmpty(err) {
+ if !db.IsErrAccessTokenNotExist(err) {
log.Error("GetAccessTokenBySHA: %v", err)
}
return 0, false
}
t.Updated = time.Now()
- if err = db.UpdateAccessToken(t); err != nil {
+ if err = db.AccessTokens.Save(t); err != nil {
log.Error("UpdateAccessToken: %v", err)
}
- return t.UID, true
+ return t.UserID, true
}
}
@@ -90,7 +90,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasic
if uid <= 0 {
if conf.Auth.EnableReverseProxyAuthentication {
- webAuthUser := ctx.Req.Header.Get(conf.Security.ReverseProxyAuthenticationUser)
+ webAuthUser := ctx.Req.Header.Get(conf.Auth.ReverseProxyAuthenticationHeader)
if len(webAuthUser) > 0 {
u, err := db.GetUserByName(webAuthUser)
if err != nil {
@@ -127,7 +127,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasic
if len(auths) == 2 && auths[0] == "Basic" {
uname, passwd, _ := tool.BasicAuthDecode(auths[1])
- u, err := db.UserLogin(uname, passwd, -1)
+ u, err := db.Users.Authenticate(uname, passwd, -1)
if err != nil {
if !db.IsErrUserNotExist(err) {
log.Error("Failed to authenticate user: %v", err)