feat(auth): Implement GitHub OAuth authentication flow for package publishing

- Added authentication service and GitHub OAuth integration.
- Introduced new authentication methods and structures in the model.
- Updated the API to handle authentication during the publishing process.
- Created handlers for starting and checking the status of the OAuth flow.
- Enhanced the publish handler to validate authentication credentials.
- Updated configuration to include GitHub OAuth settings.
- Added tests for the OAuth flow and publishing with authentication.
- Updated documentation to reflect changes in the API and authentication process.
This commit is contained in:
Avinash Sridhar 2025-04-28 09:40:42 -04:00 • committed by Toby Padilla
commit 2089c5aaa1

View file

@ -192,15 +192,6 @@ func (db *MongoDB) Publish(ctx context.Context, serverDetail *model.ServerDetail
return fmt.Errorf("version must be greater than existing version")
}
// update the existing entry to not be the latest version
if existingEntry.ID != "" {
_, err = db.collection.UpdateOne(ctx, bson.M{"id": existingEntry.ID}, bson.M{"$set": bson.M{"versiondetail.islatest": false}})
if err != nil {
return fmt.Errorf("error updating existing entry: %w", err)
}
}
serverDetail.ID = uuid.New().String()
serverDetail.VersionDetail.IsLatest = true
serverDetail.VersionDetail.ReleaseDate = time.Now().Format(time.RFC3339)
@ -214,6 +205,15 @@ func (db *MongoDB) Publish(ctx context.Context, serverDetail *model.ServerDetail
return fmt.Errorf("error inserting entry: %w", err)
}
// update the existing entry to not be the latest version
if existingEntry.ID != "" {
_, err = db.collection.UpdateOne(ctx, bson.M{"id": existingEntry.ID}, bson.M{"$set": bson.M{"versiondetail.islatest": false}})
if err != nil {
return fmt.Errorf("error updating existing entry: %w", err)
}
}
return nil
}