Documentation
¶
Index ¶
- type OAuthHelper
- func (h *OAuthHelper) CreateServiceClient(config *ServiceOAuthConfig) (*ServiceOAuthClient, error)
- func (h *OAuthHelper) GetUserClaims(ctx context.Context) (*types.TokenClaims, error)
- func (h *OAuthHelper) GetUserToken(ctx context.Context) (string, error)
- func (h *OAuthHelper) HasScope(ctx context.Context, requiredScope string) bool
- func (h *OAuthHelper) RequireScope(ctx context.Context, requiredScope string) error
- type ServiceOAuthClient
- type ServiceOAuthConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OAuthHelper ¶
type OAuthHelper struct {
// contains filtered or unexported fields
}
OAuthHelper provides OAuth functionality for MCP tools
func NewOAuthHelper ¶
func NewOAuthHelper(logger *logrus.Logger) *OAuthHelper
NewOAuthHelper creates a new OAuth helper for tools
func (*OAuthHelper) CreateServiceClient ¶
func (h *OAuthHelper) CreateServiceClient(config *ServiceOAuthConfig) (*ServiceOAuthClient, error)
CreateServiceClient creates an OAuth client for service-to-service authentication This is for Scenario 3: Tool authenticates to external services
func (*OAuthHelper) GetUserClaims ¶
func (h *OAuthHelper) GetUserClaims(ctx context.Context) (*types.TokenClaims, error)
GetUserClaims extracts OAuth claims from the current request context This is for Scenario 2: Tool uses user's OAuth identity
func (*OAuthHelper) GetUserToken ¶
func (h *OAuthHelper) GetUserToken(ctx context.Context) (string, error)
GetUserToken extracts the user's access token from the current request context This is for Scenario 2: Tool needs to make API calls as the authenticated user
func (*OAuthHelper) HasScope ¶
func (h *OAuthHelper) HasScope(ctx context.Context, requiredScope string) bool
HasScope checks if the current user has a specific OAuth scope This is for Scenario 2: Tool-level authorisation based on user permissions
func (*OAuthHelper) RequireScope ¶
func (h *OAuthHelper) RequireScope(ctx context.Context, requiredScope string) error
RequireScope returns an error if the user doesn't have the required scope This is for Scenario 2: Tool-level authorisation
type ServiceOAuthClient ¶
type ServiceOAuthClient struct {
// contains filtered or unexported fields
}
ServiceOAuthClient handles OAuth authentication to external services
func (*ServiceOAuthClient) Authenticate ¶
func (c *ServiceOAuthClient) Authenticate(ctx context.Context) error
Authenticate performs OAuth authentication to the external service This is for Scenario 3: Service-to-service authentication
func (*ServiceOAuthClient) GetAuthenticatedHTTPClient ¶
GetAuthenticatedHTTPClient returns an HTTP client with OAuth authentication This is for Scenario 3: Making authenticated requests to external services
type ServiceOAuthConfig ¶
type ServiceOAuthConfig struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
IssuerURL string `json:"issuer_url"`
Scope string `json:"scope,omitempty"`
RequireHTTPS bool `json:"require_https"`
}
ServiceOAuthConfig represents OAuth configuration for external service authentication