feat(core): Add pluggable auth providers, storage hooks, multi-upstream cache awareness, and PyPI/RubyGems protocol implementations
This commit is contained in:
@@ -11,8 +11,39 @@ import { PypiRegistry } from './pypi/classes.pypiregistry.js';
|
||||
import { RubyGemsRegistry } from './rubygems/classes.rubygemsregistry.js';
|
||||
|
||||
/**
|
||||
* Main registry orchestrator
|
||||
* Routes requests to appropriate protocol handlers (OCI, NPM, Maven, Cargo, Composer, PyPI, or RubyGems)
|
||||
* Main registry orchestrator.
|
||||
* Routes requests to appropriate protocol handlers (OCI, NPM, Maven, Cargo, Composer, PyPI, or RubyGems).
|
||||
*
|
||||
* Supports pluggable authentication and storage hooks:
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Basic usage with default in-memory auth
|
||||
* const registry = new SmartRegistry(config);
|
||||
*
|
||||
* // With custom auth provider (LDAP, OAuth, etc.)
|
||||
* const registry = new SmartRegistry({
|
||||
* ...config,
|
||||
* authProvider: new LdapAuthProvider(ldapClient),
|
||||
* });
|
||||
*
|
||||
* // With storage hooks for quota tracking
|
||||
* const registry = new SmartRegistry({
|
||||
* ...config,
|
||||
* storageHooks: {
|
||||
* beforePut: async (ctx) => {
|
||||
* const quota = await getQuota(ctx.actor?.orgId);
|
||||
* if (ctx.metadata?.size > quota) {
|
||||
* return { allowed: false, reason: 'Quota exceeded' };
|
||||
* }
|
||||
* return { allowed: true };
|
||||
* },
|
||||
* afterPut: async (ctx) => {
|
||||
* await auditLog('storage.put', ctx);
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export class SmartRegistry {
|
||||
private storage: RegistryStorage;
|
||||
@@ -23,8 +54,12 @@ export class SmartRegistry {
|
||||
|
||||
constructor(config: IRegistryConfig) {
|
||||
this.config = config;
|
||||
this.storage = new RegistryStorage(config.storage);
|
||||
this.authManager = new AuthManager(config.auth);
|
||||
|
||||
// Create storage with optional hooks
|
||||
this.storage = new RegistryStorage(config.storage, config.storageHooks);
|
||||
|
||||
// Create auth manager with optional custom provider
|
||||
this.authManager = new AuthManager(config.auth, config.authProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user