mirror of
https://github.com/alibaba/higress.git
synced 2026-06-10 05:07:30 +08:00
fix: potential use of mismatched tokens (#1092)
Co-authored-by: Kent Dong <ch3cho@qq.com>
This commit is contained in:
@@ -290,6 +290,15 @@ func (c *ProviderConfig) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ProviderConfig) GetOrSetTokenWithContext(ctx wrapper.HttpContext) string {
|
||||
ctxApiKey := ctx.GetContext(ctxKeyApiName)
|
||||
if ctxApiKey == nil {
|
||||
ctxApiKey = c.GetRandomToken()
|
||||
ctx.SetContext(ctxKeyApiName, ctxApiKey)
|
||||
}
|
||||
return ctxApiKey.(string)
|
||||
}
|
||||
|
||||
func (c *ProviderConfig) GetRandomToken() string {
|
||||
apiTokens := c.apiTokens
|
||||
count := len(apiTokens)
|
||||
|
||||
Reference in New Issue
Block a user