Store and use refresh tokens in the client cache (#3857)
* Refresh resources using refresh tokens
This commit is contained in:
1 parent
5daef58f54
commit
b2fec2e4f0
22 files changed
+1388
-105
No files matched your search
@@ -75,17 +75,17 @@ func (s *TestServer) AddResources(t *testing.T, p *authtokens.AuthToken, tars []
|
||||
r, err := cache.NewRepository(ctx, s.CacheServer.store, &sync.Map{}, s.cmd.ReadTokenFromKeyring, atReadFn)
|
||||
require.NoError(t, err)
|
||||
|
||||
tarFn := func(ctx context.Context, _, tok string) ([]*targets.Target, error) {
|
||||
tarFn := func(ctx context.Context, _, tok string, _ cache.RefreshTokenValue) ([]*targets.Target, []string, cache.RefreshTokenValue, error) {
|
||||
if tok != p.Token {
|
||||
return nil, nil
|
||||
return nil, nil, "", nil
|
||||
}
|
||||
return tars, nil
|
||||
return tars, nil, "", nil
|
||||
}
|
||||
sessFn := func(ctx context.Context, _, tok string) ([]*sessions.Session, error) {
|
||||
sessFn := func(ctx context.Context, _, tok string, _ cache.RefreshTokenValue) ([]*sessions.Session, []string, cache.RefreshTokenValue, error) {
|
||||
if tok != p.Token {
|
||||
return nil, nil
|
||||
return nil, nil, "", nil
|
||||
}
|
||||
return sess, nil
|
||||
return sess, nil, "", nil
|
||||
}
|
||||
rs, err := cache.NewRefreshService(ctx, r)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultRefreshIntervalSeconds = 5 * 60
|
||||
DefaultRefreshIntervalSeconds = 15
|
||||
defaultRefreshInterval = DefaultRefreshIntervalSeconds * time.Second
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user