feat(auth): Implement HMAC-SHA256 OCI JWTs; enhance PyPI & RubyGems uploads and normalize responses
This commit is contained in:
@@ -106,7 +106,7 @@ export class RubyGemsRegistry extends BaseRegistry {
|
||||
|
||||
// API v1 endpoints
|
||||
if (path.startsWith('/api/v1/')) {
|
||||
return this.handleApiRequest(path.substring(8), context, token);
|
||||
return this.handleApiRequest(path.substring(7), context, token);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -289,14 +289,22 @@ export class RubyGemsRegistry extends BaseRegistry {
|
||||
return this.errorResponse(400, 'No gem file provided');
|
||||
}
|
||||
|
||||
// For now, we expect metadata in query params or headers
|
||||
// Full implementation would parse .gem file (tar + gzip + Marshal)
|
||||
const gemName = context.query?.name || context.headers['x-gem-name'];
|
||||
const version = context.query?.version || context.headers['x-gem-version'];
|
||||
const platform = context.query?.platform || context.headers['x-gem-platform'];
|
||||
// Try to get metadata from query params or headers first
|
||||
let gemName = context.query?.name || context.headers['x-gem-name'] as string | undefined;
|
||||
let version = context.query?.version || context.headers['x-gem-version'] as string | undefined;
|
||||
const platform = context.query?.platform || context.headers['x-gem-platform'] as string | undefined;
|
||||
|
||||
// If not provided, try to extract from gem binary
|
||||
if (!gemName || !version) {
|
||||
const extracted = await helpers.extractGemMetadata(gemData);
|
||||
if (extracted) {
|
||||
gemName = gemName || extracted.name;
|
||||
version = version || extracted.version;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gemName || !version) {
|
||||
return this.errorResponse(400, 'Gem name and version required');
|
||||
return this.errorResponse(400, 'Gem name and version required (provide in query, headers, or valid gem format)');
|
||||
}
|
||||
|
||||
// Validate gem name
|
||||
@@ -351,7 +359,7 @@ export class RubyGemsRegistry extends BaseRegistry {
|
||||
});
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
status: 201,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: Buffer.from(JSON.stringify({
|
||||
message: 'Gem uploaded successfully',
|
||||
|
||||
Reference in New Issue
Block a user