diff options
author | techknowlogick <hello@techknowlogick.com> | 2019-04-25 18:42:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-25 18:42:50 -0400 |
commit | ec2d489d15580ba934f34d8cdf3d779e1d64374d (patch) | |
tree | 97b2a1453ad5b557fd7fb925102e4a63d9791667 /routers/repo/http.go | |
parent | 199faadea3ff40880d70c8bc031aab800720330d (diff) | |
download | gitea-ec2d489d15580ba934f34d8cdf3d779e1d64374d.tar.gz gitea-ec2d489d15580ba934f34d8cdf3d779e1d64374d.zip |
OAuth2 token can be used in basic auth (#6747)
Diffstat (limited to 'routers/repo/http.go')
-rw-r--r-- | routers/repo/http.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go index 2bc50efd83..fccecfb71d 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -18,6 +19,7 @@ import ( "time" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" @@ -166,6 +168,16 @@ func HTTP(ctx *context.Context) { // Assume password is token authToken = authPasswd } + uid := auth.CheckOAuthAccessToken(authToken) + if uid != 0 { + ctx.Data["IsApiToken"] = true + + authUser, err = models.GetUserByID(uid) + if err != nil { + ctx.ServerError("GetUserByID", err) + return + } + } // Assume password is a token. token, err := models.GetAccessTokenBySHA(authToken) if err == nil { |