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
28
internal/auth/auth.go
Normal file
28
internal/auth/auth.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Package auth provides authentication mechanisms for the MCP registry
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/modelcontextprotocol/registry/internal/model"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrAuthRequired is returned when authentication is required but not provided
|
||||
ErrAuthRequired = errors.New("authentication required")
|
||||
// ErrUnsupportedAuthMethod is returned when an unsupported auth method is used
|
||||
ErrUnsupportedAuthMethod = errors.New("unsupported authentication method")
|
||||
)
|
||||
|
||||
// Service defines the authentication service interface
|
||||
type Service interface {
|
||||
// StartAuthFlow initiates an authentication flow and returns the flow information
|
||||
StartAuthFlow(ctx context.Context, method model.AuthMethod, repoRef string) (map[string]string, string, error)
|
||||
|
||||
// CheckAuthStatus checks the status of an authentication flow using a status token
|
||||
CheckAuthStatus(ctx context.Context, statusToken string) (string, error)
|
||||
|
||||
// ValidateAuth validates the authentication credentials
|
||||
ValidateAuth(ctx context.Context, auth model.Authentication) (bool, error)
|
||||
}
|
||||
Loading…
Reference in a new issue