This commit is contained in:
thoscut 2025-03-11 16:39:38 -03:00 committed by GitHub
commit 28abf7fcdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 7 deletions

View File

@ -533,6 +533,14 @@ func authenticate(ctx *context.Context, repository *repo_model.Repository, autho
return accessMode <= perm_model.AccessModeWrite
}
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)
return false
}
ctx.Doer = user
// ctx.IsSigned is unnecessary here, this will be checked in perm.CanAccess
perm, err := access_model.GetUserRepoPermission(ctx, repository, ctx.Doer)
if err != nil {
@ -545,13 +553,6 @@ func authenticate(ctx *context.Context, repository *repo_model.Repository, autho
return true
}
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)
return false
}
ctx.Doer = user
return true
}