| 384 | } |
| 385 | |
| 386 | func (s *FileTokenStore) resolveAuthPath(auth *cliproxyauth.Auth) (string, error) { |
| 387 | if auth == nil { |
| 388 | return "", fmt.Errorf("auth filestore: auth is nil") |
| 389 | } |
| 390 | if auth.Attributes != nil { |
| 391 | if p := strings.TrimSpace(auth.Attributes["path"]); p != "" { |
| 392 | return p, nil |
| 393 | } |
| 394 | } |
| 395 | if fileName := strings.TrimSpace(auth.FileName); fileName != "" { |
| 396 | if filepath.IsAbs(fileName) { |
| 397 | return fileName, nil |
| 398 | } |
| 399 | if dir := s.baseDirSnapshot(); dir != "" { |
| 400 | return filepath.Join(dir, fileName), nil |
| 401 | } |
| 402 | return fileName, nil |
| 403 | } |
| 404 | if auth.ID == "" { |
| 405 | return "", fmt.Errorf("auth filestore: missing id") |
| 406 | } |
| 407 | if filepath.IsAbs(auth.ID) { |
| 408 | return auth.ID, nil |
| 409 | } |
| 410 | dir := s.baseDirSnapshot() |
| 411 | if dir == "" { |
| 412 | return "", fmt.Errorf("auth filestore: directory not configured") |
| 413 | } |
| 414 | return filepath.Join(dir, auth.ID), nil |
| 415 | } |
| 416 | |
| 417 | func (s *FileTokenStore) labelFor(metadata map[string]any) string { |
| 418 | if metadata == nil { |