Skip to content

Commit d817cb0

Browse files
authored
fix: admin token in standalone mode (#3499)
* fix: performance issues with Kafka caused by encapsulating the MQ interface * fix: admin token in standalone mode
1 parent c208c37 commit d817cb0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

internal/api/router.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, cf
9797
case BestSpeed:
9898
r.Use(gzip.Gzip(gzip.BestSpeed))
9999
}
100+
if config.Standalone() {
101+
r.Use(func(c *gin.Context) {
102+
c.Set(authverify.CtxAdminUserIDsKey, cfg.Share.IMAdminUser.UserIDs)
103+
})
104+
}
100105
r.Use(api.GinLogger(), prommetricsGin(), gin.RecoveryWithWriter(gin.DefaultErrorWriter, mw.GinPanicErr), mw.CorsHandler(),
101106
mw.GinParseOperationID(), GinParseToken(rpcli.NewAuthClient(authConn)), setGinIsAdmin(cfg.Share.IMAdminUser.UserIDs))
102107

pkg/common/storage/cache/redis/token.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,15 @@ func (c *tokenCache) DeleteTokenByTokenMap(ctx context.Context, userID string, t
165165
}
166166

167167
func (c *tokenCache) DeleteAndSetTemporary(ctx context.Context, userID string, platformID int, fields []string) error {
168-
key := cachekey.GetTokenKey(userID, platformID)
169-
if err := c.rdb.HDel(ctx, key, fields...).Err(); err != nil {
170-
return errs.Wrap(err)
171-
}
172168
for _, f := range fields {
173169
k := cachekey.GetTemporaryTokenKey(userID, platformID, f)
174170
if err := c.rdb.Set(ctx, k, "", time.Minute*5).Err(); err != nil {
175171
return errs.Wrap(err)
176172
}
177173
}
178-
174+
key := cachekey.GetTokenKey(userID, platformID)
175+
if err := c.rdb.HDel(ctx, key, fields...).Err(); err != nil {
176+
return errs.Wrap(err)
177+
}
179178
return nil
180179
}

0 commit comments

Comments
 (0)