IDToken: cache invalidation (#100592)
* Make org role part of id token cache key. This way we will always sign a new token when it changes * Remove calls to remove id token
This commit is contained in:
@@ -63,7 +63,7 @@ func (s *Service) SignIdentity(ctx context.Context, id identity.Requester) (stri
|
||||
s.metrics.tokenSigningDurationHistogram.Observe(time.Since(t).Seconds())
|
||||
}(time.Now())
|
||||
|
||||
cacheKey := prefixCacheKey(id.GetCacheKey())
|
||||
cacheKey := getCacheKey(id)
|
||||
|
||||
type resultType struct {
|
||||
token string
|
||||
@@ -140,7 +140,7 @@ func (s *Service) SignIdentity(ctx context.Context, id identity.Requester) (stri
|
||||
}
|
||||
|
||||
func (s *Service) RemoveIDToken(ctx context.Context, id identity.Requester) error {
|
||||
return s.cache.Delete(ctx, prefixCacheKey(id.GetCacheKey()))
|
||||
return s.cache.Delete(ctx, getCacheKey(id))
|
||||
}
|
||||
|
||||
func (s *Service) hook(ctx context.Context, identity *authn.Identity, _ *authn.Request) error {
|
||||
@@ -181,8 +181,8 @@ func getAudience(orgID int64) jwt.Audience {
|
||||
return jwt.Audience{fmt.Sprintf("org:%d", orgID)}
|
||||
}
|
||||
|
||||
func prefixCacheKey(key string) string {
|
||||
return fmt.Sprintf("%s-%s", cachePrefix, key)
|
||||
func getCacheKey(ident identity.Requester) string {
|
||||
return cachePrefix + ident.GetCacheKey() + string(ident.GetOrgRole())
|
||||
}
|
||||
|
||||
func shouldLogErr(err error) bool {
|
||||
|
||||
Reference in New Issue
Block a user