test
This commit is contained in:
23
auth/auth.go
23
auth/auth.go
@@ -33,26 +33,3 @@ func AuthHandler(c *gin.Context, cfg *config.Config) bool {
|
||||
|
||||
return isValid
|
||||
}
|
||||
|
||||
func IsBlacklisted(username, repo string, blacklist map[string][]string, enabled bool) bool {
|
||||
if !enabled {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查 blacklist 是否为 nil
|
||||
if blacklist == nil {
|
||||
// 可以选择记录日志或返回 false
|
||||
logw("Warning: Blacklist map is nil")
|
||||
return false
|
||||
}
|
||||
|
||||
if repos, ok := blacklist[username]; ok {
|
||||
for _, blacklistedRepo := range repos {
|
||||
if blacklistedRepo == repo {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
10
auth/blacklist.go
Normal file
10
auth/blacklist.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package auth
|
||||
|
||||
func CheckBlacklist(fullrepo string) bool {
|
||||
if fullrepo == "test/test1" {
|
||||
logw("%s in blacklist", fullrepo)
|
||||
return true
|
||||
}
|
||||
logw("%s not in blacklist", fullrepo)
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user