migrate token cache to cache.Expiring

This commit is contained in:
Mike Danese
2019-11-06 16:23:21 -08:00
parent 9167711fd1
commit 3f194d5b41
9 changed files with 78 additions and 35 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package authenticator
import (
"context"
"time"
"github.com/go-openapi/spec"
@@ -192,7 +193,7 @@ func (config Config) New() (authenticator.Request, *spec.SecurityDefinitions, er
tokenAuth := tokenunion.New(tokenAuthenticators...)
// Optionally cache authentication results
if config.TokenSuccessCacheTTL > 0 || config.TokenFailureCacheTTL > 0 {
tokenAuth = tokencache.New(tokenAuth, true, config.TokenSuccessCacheTTL, config.TokenFailureCacheTTL)
tokenAuth = tokencache.New(context.TODO(), tokenAuth, true, config.TokenSuccessCacheTTL, config.TokenFailureCacheTTL)
}
authenticators = append(authenticators, bearertoken.New(tokenAuth), websocket.NewProtocolAuthenticator(tokenAuth))
securityDefinitions["BearerToken"] = &spec.SecurityScheme{
@@ -312,5 +313,5 @@ func newWebhookTokenAuthenticator(webhookConfigFile string, version string, ttl
return nil, err
}
return tokencache.New(webhookTokenAuthenticator, false, ttl, ttl), nil
return tokencache.New(context.TODO(), webhookTokenAuthenticator, false, ttl, ttl), nil
}