Qiao-yq commented on code in PR #1592:
URL: https://github.com/apache/dubbo-admin/pull/1592#discussion_r4336684184
##########
ai/store/gorm/store.go:
##########
@@ -626,6 +685,28 @@ func (s *GormStore) findSession(tx *gorm.DB, sessionID
string, lock bool) (*Sess
return &model, nil
}
+func (s *GormStore) findActiveSession(tx *gorm.DB, access
security.AccessContext, sessionID string, lock bool) (*SessionModel, error) {
+ model, err := s.findSession(tx, access, sessionID, lock)
+ if err != nil {
+ return nil, err
+ }
+ if err := conversationstore.ValidateSessionActive(sessionID,
model.Status, isExpired(model, time.Now())); err != nil {
+ return nil, err
+ }
+ return model, nil
+}
+
+func scopeSessions(query *gorm.DB, access security.AccessContext) *gorm.DB {
+ if access.IsSystem() {
+ return query
+ }
+ query = query.Where("tenant_id = ?", access.Subject.TenantID)
+ if !access.Subject.HasScope(security.ScopeSessionAdmin) {
+ query = query.Where("owner_id = ?", access.Subject.UserID)
Review Comment:
Thanks for catching this. Fixed in 4c6bbad: GORM now rechecks tenant and
owner identities using exact Go string comparisons after querying, including
history access. List results are filtered using the same policy.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]