summaryrefslogtreecommitdiffstats
path: root/services/lfs/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/lfs/server.go')
-rw-r--r--services/lfs/server.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/services/lfs/server.go b/services/lfs/server.go
index 32bd843ebf..8fd2759132 100644
--- a/services/lfs/server.go
+++ b/services/lfs/server.go
@@ -4,6 +4,7 @@
package lfs
import (
+ stdCtx "context"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
@@ -408,7 +409,7 @@ func getAuthenticatedMeta(ctx *context.Context, rc *requestContext, p lfs_module
}
func getAuthenticatedRepository(ctx *context.Context, rc *requestContext, requireWrite bool) *repo_model.Repository {
- repository, err := repo_model.GetRepositoryByOwnerAndName(rc.User, rc.Repo)
+ repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, rc.User, rc.Repo)
if err != nil {
log.Error("Unable to get repository: %s/%s Error: %v", rc.User, rc.Repo, err)
writeStatus(ctx, http.StatusNotFound)
@@ -506,7 +507,7 @@ func authenticate(ctx *context.Context, repository *repo_model.Repository, autho
return true
}
- user, err := parseToken(authorization, repository, accessMode)
+ user, err := parseToken(ctx, authorization, repository, accessMode)
if err != nil {
// Most of these are Warn level - the true internal server errors are logged in parseToken already
log.Warn("Authentication failure for provided token with Error: %v", err)
@@ -516,7 +517,7 @@ func authenticate(ctx *context.Context, repository *repo_model.Repository, autho
return true
}
-func handleLFSToken(tokenSHA string, target *repo_model.Repository, mode perm.AccessMode) (*user_model.User, error) {
+func handleLFSToken(ctx stdCtx.Context, tokenSHA string, target *repo_model.Repository, mode perm.AccessMode) (*user_model.User, error) {
if !strings.Contains(tokenSHA, ".") {
return nil, nil
}
@@ -543,7 +544,7 @@ func handleLFSToken(tokenSHA string, target *repo_model.Repository, mode perm.Ac
return nil, fmt.Errorf("invalid token claim")
}
- u, err := user_model.GetUserByID(claims.UserID)
+ u, err := user_model.GetUserByID(ctx, claims.UserID)
if err != nil {
log.Error("Unable to GetUserById[%d]: Error: %v", claims.UserID, err)
return nil, err
@@ -551,7 +552,7 @@ func handleLFSToken(tokenSHA string, target *repo_model.Repository, mode perm.Ac
return u, nil
}
-func parseToken(authorization string, target *repo_model.Repository, mode perm.AccessMode) (*user_model.User, error) {
+func parseToken(ctx stdCtx.Context, authorization string, target *repo_model.Repository, mode perm.AccessMode) (*user_model.User, error) {
if authorization == "" {
return nil, fmt.Errorf("no token")
}
@@ -565,7 +566,7 @@ func parseToken(authorization string, target *repo_model.Repository, mode perm.A
case "bearer":
fallthrough
case "token":
- return handleLFSToken(tokenSHA, target, mode)
+ return handleLFSToken(ctx, tokenSHA, target, mode)
}
return nil, fmt.Errorf("token not found")
}