Skip to content

Commit

Permalink
fix: admin token
Browse files Browse the repository at this point in the history
  • Loading branch information
icey-yu committed Sep 29, 2024
1 parent 765fa17 commit ab156e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/webhooks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
url: webhook://127.0.0.1:10008/callbackExample
url: http://127.0.0.1:10006/callbackExample
beforeSendSingleMsg:
enable: false
timeout: 5
Expand Down
12 changes: 12 additions & 0 deletions pkg/common/storage/controller/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package controller

import (
"context"
"github.com/openimsdk/tools/log"

"github.com/golang-jwt/jwt/v4"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
Expand Down Expand Up @@ -77,12 +78,23 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
return "", err
}
}

const adminTokenMaxNum = 30
if platformID == constant.AdminPlatformID {
if len(kickedTokenKey) > adminTokenMaxNum {
kickedTokenKey = kickedTokenKey[:adminTokenMaxNum]
} else {
kickedTokenKey = nil
}
}

if len(kickedTokenKey) != 0 {
for _, k := range kickedTokenKey {
err := a.cache.SetTokenFlagEx(ctx, userID, platformID, k, constant.KickedToken)
if err != nil {
return "", err
}
log.ZDebug(ctx, "kicked token in create token", "token", k)
}
}

Expand Down

0 comments on commit ab156e6

Please sign in to comment.