Skip to content

Commit 8da84df

Browse files
author
v_frgfeng
committed
✨ copilot auth limit
1 parent a18736a commit 8da84df

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

api/copilot/copilot.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ func (co *CopilotApi) TokenHandler(c *gin.Context) {
5757
return
5858
}
5959

60+
day := time.Now().Format("2006-01-02")
61+
if dayCount, ok := AuthCount[day]; ok {
62+
if authCount, ok := dayCount[TypeAuthToken]; ok && authCount > 200 {
63+
global.SugarLog.Errorw("TokenHandler get auth token err, authorization limit > 200")
64+
response.FailWithOpenAIError(http.StatusUnauthorized, "exceeded authorization limit", c)
65+
return
66+
}
67+
}
68+
6069
tokenRawCache, err := GetTokenRawInfoCache(token)
6170
if err == nil && len(tokenRawCache) > 0 {
6271
global.SugarLog.Infow("TokenHandler get token raw cache", "token", token)

0 commit comments

Comments
 (0)