toolhelper

package
v0.59.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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

func (c *ServiceOAuthClient) GetAuthenticatedHTTPClient(ctx context.Context) (*http.Client, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL