mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
feat(cliproxy): skip persisting runtime-only websocket auths
This commit is contained in:
@@ -872,6 +872,11 @@ func (m *Manager) persist(ctx context.Context, auth *Auth) error {
|
|||||||
if m.store == nil || auth == nil {
|
if m.store == nil || auth == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if auth.Attributes != nil {
|
||||||
|
if v := strings.ToLower(strings.TrimSpace(auth.Attributes["runtime_only"])); v == "true" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
// Skip persistence when metadata is absent (e.g., runtime-only auths).
|
// Skip persistence when metadata is absent (e.g., runtime-only auths).
|
||||||
if auth.Metadata == nil {
|
if auth.Metadata == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -210,13 +210,14 @@ func (s *Service) wsOnConnected(channelID string) {
|
|||||||
}
|
}
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
auth := &coreauth.Auth{
|
auth := &coreauth.Auth{
|
||||||
ID: channelID, // keep channel identifier as ID
|
ID: channelID, // keep channel identifier as ID
|
||||||
Provider: "aistudio", // logical provider for switch routing
|
Provider: "aistudio", // logical provider for switch routing
|
||||||
Label: channelID, // display original channel id
|
Label: channelID, // display original channel id
|
||||||
Status: coreauth.StatusActive,
|
Status: coreauth.StatusActive,
|
||||||
CreatedAt: now,
|
CreatedAt: now,
|
||||||
UpdatedAt: now,
|
UpdatedAt: now,
|
||||||
Metadata: map[string]any{"email": channelID}, // inject email inline
|
Attributes: map[string]string{"runtime_only": "true"},
|
||||||
|
Metadata: map[string]any{"email": channelID}, // metadata drives logging and usage tracking
|
||||||
}
|
}
|
||||||
log.Infof("websocket provider connected: %s", channelID)
|
log.Infof("websocket provider connected: %s", channelID)
|
||||||
s.applyCoreAuthAddOrUpdate(context.Background(), auth)
|
s.applyCoreAuthAddOrUpdate(context.Background(), auth)
|
||||||
|
|||||||
Reference in New Issue
Block a user