mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
4.0.0-beta.0
This commit is contained in:
parent
91c3ad7fd8
commit
a4d324a361
38 changed files with 497 additions and 1428 deletions
|
|
@ -4,22 +4,21 @@ import (
|
|||
"fmt"
|
||||
"ghproxy/config"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/infinite-iroha/touka"
|
||||
)
|
||||
|
||||
func AuthHeaderHandler(c *app.RequestContext, cfg *config.Config) (isValid bool, err error) {
|
||||
func AuthHeaderHandler(c *touka.Context, cfg *config.Config) (isValid bool, err error) {
|
||||
if !cfg.Auth.Enabled {
|
||||
return true, nil
|
||||
}
|
||||
// 获取"GH-Auth"的值
|
||||
var authToken string
|
||||
if cfg.Auth.Key != "" {
|
||||
authToken = string(c.GetHeader(cfg.Auth.Key))
|
||||
authToken = string(c.Request.Header.Get(cfg.Auth.Key))
|
||||
|
||||
} else {
|
||||
authToken = string(c.GetHeader("GH-Auth"))
|
||||
authToken = string(c.Request.Header.Get("GH-Auth"))
|
||||
}
|
||||
logDebug("%s %s %s %s %s AUTH_TOKEN: %s", c.Method(), string(c.Path()), c.Request.Header.UserAgent(), c.Request.Header.GetProtocol(), authToken)
|
||||
if authToken == "" {
|
||||
return false, fmt.Errorf("Auth token not found")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue