MCPcopy Create free account
hub / github.com/astercloud/aster / DeleteSession

Method DeleteSession

pkg/security/access_control.go:944–970  ·  view source on GitHub ↗

DeleteSession 删除会话

(sessionID string)

Source from the content-addressed store, hash-verified

942
943// DeleteSession 删除会话
944func (ac *AccessController) DeleteSession(sessionID string) error {
945 ac.mu.Lock()
946 defer ac.mu.Unlock()
947
948 session, exists := ac.sessions[sessionID]
949 if !exists {
950 return fmt.Errorf("session %s not found", sessionID)
951 }
952
953 session.Status = SessionStatusRevoked
954 delete(ac.sessions, sessionID)
955
956 // 记录审计日志
957 if ac.config.EnableAudit && ac.auditLog != nil {
958 _ = ac.auditLog.LogEvent(AuditEvent{
959 Type: AuditTypeSessionDeleted,
960 UserID: session.UserID,
961 Timestamp: time.Now(),
962 Message: fmt.Sprintf("Session %s revoked for user %s", sessionID, session.Username),
963 Metadata: map[string]any{
964 "session_id": sessionID,
965 },
966 })
967 }
968
969 return nil
970}
971
972// generateSessionID 生成会话ID
973func (ac *AccessController) generateSessionID(userID, ipAddress, userAgent string) string {

Callers

nothing calls this directly

Calls 2

deleteFunction · 0.85
LogEventMethod · 0.65

Tested by

no test coverage detected