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
2 changed files with 924 additions and 35 deletions
|
|
@ -4,16 +4,17 @@ package router
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/modelcontextprotocol/registry/internal/auth"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
)
|
||||
|
||||
// New creates a new router with all API versions registered
|
||||
func New(cfg *config.Config, registry service.RegistryService) *http.ServeMux {
|
||||
func New(cfg *config.Config, registry service.RegistryService, authService auth.Service) *http.ServeMux {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// Register routes for all API versions
|
||||
RegisterV0Routes(mux, cfg, registry)
|
||||
RegisterV0Routes(mux, cfg, registry, authService)
|
||||
|
||||
return mux
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,18 +5,19 @@ import (
|
|||
"net/http"
|
||||
|
||||
v0 "github.com/modelcontextprotocol/registry/internal/api/handlers/v0"
|
||||
"github.com/modelcontextprotocol/registry/internal/auth"
|
||||
"github.com/modelcontextprotocol/registry/internal/config"
|
||||
"github.com/modelcontextprotocol/registry/internal/service"
|
||||
)
|
||||
|
||||
// RegisterV0Routes registers all v0 API routes to the provided router
|
||||
func RegisterV0Routes(mux *http.ServeMux, cfg *config.Config, registry service.RegistryService) {
|
||||
func RegisterV0Routes(mux *http.ServeMux, cfg *config.Config, registry service.RegistryService, authService auth.Service) {
|
||||
// Register v0 endpoints
|
||||
mux.HandleFunc("/v0/health", v0.HealthHandler())
|
||||
mux.HandleFunc("/v0/servers", v0.ServersHandler(registry))
|
||||
mux.HandleFunc("/v0/servers/{id}", v0.ServersDetailHandler(registry))
|
||||
mux.HandleFunc("/v0/ping", v0.PingHandler(cfg))
|
||||
mux.HandleFunc("/v0/publish", v0.PublishHandler(registry))
|
||||
mux.HandleFunc("/v0/publish", v0.PublishHandler(registry, authService))
|
||||
|
||||
// Register Swagger UI routes
|
||||
mux.HandleFunc("/v0/swagger/", v0.SwaggerHandler())
|
||||
|
|
|
|||
Loading…
Reference in a new issue