From 7ad38d77572c9ac19f98bf4d532d4444bec4b840 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Mon, 22 Feb 2021 18:37:14 +0100 Subject: [PATCH] fix token cache TTL The TTL was supplied to the middleware as a duration and then in that middleware multiplied by `time.Second` again. Durations should not be multiplied because they result in unintended values. ```go time.Second * 1 = 1s time.Second * time.Second = 277777h46m40s ``` --- changelog/unreleased/fix-tokencache-ttl.md | 5 +++++ proxy/pkg/middleware/authentication.go | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/fix-tokencache-ttl.md diff --git a/changelog/unreleased/fix-tokencache-ttl.md b/changelog/unreleased/fix-tokencache-ttl.md new file mode 100644 index 00000000000..e437234c78f --- /dev/null +++ b/changelog/unreleased/fix-tokencache-ttl.md @@ -0,0 +1,5 @@ +Bugfix: Fix the ttl of the authentication middleware cache + +The authentication cache ttl was multiplied with `time.Second` multiple times. This resulted in a ttl that was not intended. + +https://github.com/owncloud/ocis/pull/1699 diff --git a/proxy/pkg/middleware/authentication.go b/proxy/pkg/middleware/authentication.go index 1c988572753..2e0f0f5dccc 100644 --- a/proxy/pkg/middleware/authentication.go +++ b/proxy/pkg/middleware/authentication.go @@ -5,7 +5,6 @@ import ( "net/http" "regexp" "strings" - "time" ) var ( @@ -114,7 +113,7 @@ func newOIDCAuth(options Options) func(http.Handler) http.Handler { HTTPClient(options.HTTPClient), OIDCIss(options.OIDCIss), TokenCacheSize(options.UserinfoCacheSize), - TokenCacheTTL(time.Second*time.Duration(options.UserinfoCacheTTL)), + TokenCacheTTL(options.UserinfoCacheTTL), CredentialsByUserAgent(options.CredentialsByUserAgent), ) }