From 23e79dbf19a68b8ecdf2e7fd50aa36f066b54f6b Mon Sep 17 00:00:00 2001 From: cfz Date: Sun, 11 Jul 2021 21:29:04 +0800 Subject: [PATCH] [backport 3.4]: server/auth: enable tokenProvider if recoved store enables auth this is a manual backport of #13172 --- auth/simple_token.go | 5 +++++ auth/store.go | 3 +++ 2 files changed, 8 insertions(+) diff --git a/auth/simple_token.go b/auth/simple_token.go index a9dc5b715f6..41e92236138 100644 --- a/auth/simple_token.go +++ b/auth/simple_token.go @@ -159,6 +159,11 @@ func (t *tokenSimple) invalidateUser(username string) { } func (t *tokenSimple) enable() { + t.simpleTokensMu.Lock() + defer t.simpleTokensMu.Unlock() + if t.simpleTokenKeeper != nil { // already enabled + return + } if t.simpleTokenTTL <= 0 { t.simpleTokenTTL = simpleTokenTTLDefault } diff --git a/auth/store.go b/auth/store.go index ba1d95ff2ca..a1d2e077cfe 100644 --- a/auth/store.go +++ b/auth/store.go @@ -400,6 +400,9 @@ func (as *authStore) Recover(be backend.Backend) { as.enabledMu.Lock() as.enabled = enabled + if enabled { + as.tokenProvider.enable() + } as.enabledMu.Unlock() }