| 516 | } |
| 517 | |
| 518 | func (s *ObjectTokenStore) resolveAuthPath(auth *cliproxyauth.Auth) (string, error) { |
| 519 | if auth == nil { |
| 520 | return "", fmt.Errorf("object store: auth is nil") |
| 521 | } |
| 522 | if auth.Attributes != nil { |
| 523 | if path := strings.TrimSpace(auth.Attributes["path"]); path != "" { |
| 524 | if filepath.IsAbs(path) { |
| 525 | return path, nil |
| 526 | } |
| 527 | return filepath.Join(s.authDir, path), nil |
| 528 | } |
| 529 | } |
| 530 | fileName := strings.TrimSpace(auth.FileName) |
| 531 | if fileName == "" { |
| 532 | fileName = strings.TrimSpace(auth.ID) |
| 533 | } |
| 534 | if fileName == "" { |
| 535 | return "", fmt.Errorf("object store: auth %s missing filename", auth.ID) |
| 536 | } |
| 537 | if !strings.HasSuffix(strings.ToLower(fileName), ".json") { |
| 538 | fileName += ".json" |
| 539 | } |
| 540 | return filepath.Join(s.authDir, fileName), nil |
| 541 | } |
| 542 | |
| 543 | func (s *ObjectTokenStore) resolveDeletePath(id string) (string, error) { |
| 544 | id = strings.TrimSpace(id) |