mirror of
https://github.com/gogs/gogs.git
synced 2025-12-24 01:00:00 +01:00
api: GitHub compliance (#4549)
* Add undocumented endpoint for /repositories/:id * GitHub API Compliance
This commit is contained in:
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/models/errors"
|
||||
"github.com/gogits/gogs/pkg/tool"
|
||||
"github.com/gogits/gogs/pkg/setting"
|
||||
"github.com/gogits/gogs/pkg/tool"
|
||||
)
|
||||
|
||||
func IsAPIPath(url string) bool {
|
||||
@@ -24,17 +24,20 @@ func IsAPIPath(url string) bool {
|
||||
}
|
||||
|
||||
// SignedInID returns the id of signed in user.
|
||||
func SignedInID(ctx *macaron.Context, sess session.Store) int64 {
|
||||
func SignedInID(c *macaron.Context, sess session.Store) int64 {
|
||||
if !models.HasEngine {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Check access token.
|
||||
if IsAPIPath(ctx.Req.URL.Path) {
|
||||
tokenSHA := ctx.Query("token")
|
||||
if IsAPIPath(c.Req.URL.Path) {
|
||||
tokenSHA := c.Query("token")
|
||||
if len(tokenSHA) <= 0 {
|
||||
tokenSHA = c.Query("access_token")
|
||||
}
|
||||
if len(tokenSHA) == 0 {
|
||||
// Well, check with header again.
|
||||
auHead := ctx.Req.Header.Get("Authorization")
|
||||
auHead := c.Req.Header.Get("Authorization")
|
||||
if len(auHead) > 0 {
|
||||
auths := strings.Fields(auHead)
|
||||
if len(auths) == 2 && auths[0] == "token" {
|
||||
|
||||
Reference in New Issue
Block a user