feat(auth): add support for disabling auth via metadata

- Added logic to set `auth.Disabled` and update `auth.Status` to `StatusDisabled` when `disabled` metadata is provided and true.
- Updated `objectstore`, `gitstore`, and `postgresstore` implementations to handle the new metadata attribute.

Closes: #2651
This commit is contained in:
Luis Pater
2026-05-15 03:59:25 +08:00
parent 3a9fb3780e
commit 229d03a690
3 changed files with 12 additions and 0 deletions

View File

@@ -497,6 +497,10 @@ func (s *GitTokenStore) readAuthFile(path, baseDir string) (*cliproxyauth.Auth,
auth.Attributes["email"] = email
}
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
if disabled, ok := metadata["disabled"].(bool); ok && disabled {
auth.Disabled = true
auth.Status = cliproxyauth.StatusDisabled
}
return auth, nil
}

View File

@@ -604,6 +604,10 @@ func (s *ObjectTokenStore) readAuthFile(path, baseDir string) (*cliproxyauth.Aut
NextRefreshAfter: time.Time{},
}
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
if disabled, ok := metadata["disabled"].(bool); ok && disabled {
auth.Disabled = true
auth.Status = cliproxyauth.StatusDisabled
}
return auth, nil
}

View File

@@ -319,6 +319,10 @@ func (s *PostgresStore) List(ctx context.Context) ([]*cliproxyauth.Auth, error)
NextRefreshAfter: time.Time{},
}
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
if disabled, ok := metadata["disabled"].(bool); ok && disabled {
auth.Disabled = true
auth.Status = cliproxyauth.StatusDisabled
}
auths = append(auths, auth)
}
if err = rows.Err(); err != nil {