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:
parent
582d93a103
commit
2089c5aaa1
1 changed files with 924 additions and 35 deletions
|
|
@ -12,6 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/modelcontextprotocol/registry/internal/api"
|
||||
"github.com/modelcontextprotocol/registry/internal/auth"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/database"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
|
|
@ -70,8 +71,23 @@ func main() {
|
|||
}()
|
||||
}
|
||||
|
||||
// Initialize authentication services
|
||||
authService := auth.NewAuthService(cfg)
|
||||
|
||||
if cfg.RequireAuth {
|
||||
log.Println("Authentication is required for package publishing")
|
||||
|
||||
if cfg.GithubClientID == "" || cfg.GithubClientSecret == "" {
|
||||
log.Println("Warning: GitHub OAuth credentials not configured but authentication is required")
|
||||
} else {
|
||||
log.Println("GitHub OAuth authentication is configured")
|
||||
}
|
||||
} else {
|
||||
log.Println("Authentication is optional for package publishing")
|
||||
}
|
||||
|
||||
// Initialize HTTP server
|
||||
server := api.NewServer(cfg, registryService)
|
||||
server := api.NewServer(cfg, registryService, authService)
|
||||
|
||||
// Start server in a goroutine so it doesn't block signal handling
|
||||
go func() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue