Documentation
¶
Index ¶
- func Attach(mux goahttp.Muxer, service *Service)
- func ClientInfoCacheKey(mcpURL string, clientID string) string
- func GrantCacheKey(toolsetId uuid.UUID, code string) string
- func TokenCacheKey(toolsetID uuid.UUID, token string) string
- type AuthorizationRequest
- type ClientInfo
- type ClientRegistrationService
- func (s *ClientRegistrationService) GetClient(ctx context.Context, mcpURL string, clientID string) (*ClientInfo, error)
- func (s *ClientRegistrationService) IsValidRedirectURI(ctx context.Context, mcpURL string, clientID, redirectURI string) (bool, error)
- func (s *ClientRegistrationService) RegisterClient(ctx context.Context, req *ClientInfo, mcpURL string) (*ClientInfo, error)
- func (s *ClientRegistrationService) ValidateClientCredentials(ctx context.Context, mcpURL string, clientID, clientSecret string) (*ClientInfo, error)
- type ConsentTemplateData
- type ExternalSecret
- type Grant
- type GrantManager
- func (gm *GrantManager) BuildAuthorizationResponse(ctx context.Context, grant *Grant, redirectURI string) (string, error)
- func (gm *GrantManager) BuildErrorResponse(ctx context.Context, redirectURI, errorString, errorDescription, state string) (string, error)
- func (gm *GrantManager) CreateAuthorizationGrant(ctx context.Context, req *AuthorizationRequest, mcpURL string, ...) (*Grant, error)
- func (gm *GrantManager) ValidateAndConsumeGrant(ctx context.Context, toolsetId uuid.UUID, code, clientID, redirectURI string) (*Grant, error)
- func (gm *GrantManager) ValidateAuthorizationRequest(ctx context.Context, req *AuthorizationRequest, mcpURL string) error
- type OauthProxyClientInfo
- type PKCEService
- func (s *PKCEService) GenerateCodeChallenge(codeVerifier string, method string) (string, error)
- func (s *PKCEService) ValidateCodeChallenge(ctx context.Context, codeChallenge string, method string) error
- func (s *PKCEService) ValidateCodeVerifier(ctx context.Context, codeVerifier string) error
- func (s *PKCEService) ValidatePKCEFlow(ctx context.Context, grant *Grant, codeVerifier string) error
- func (s *PKCEService) VerifyCodeChallenge(ctx context.Context, codeVerifier, codeChallenge, method string) error
- type Service
- type Token
- type TokenRequest
- type TokenResponse
- type TokenService
- func (ts *TokenService) CreateErrorResponse(errorType, description string) map[string]interface{}
- func (ts *TokenService) CreateTokenResponse(token *Token) *TokenResponse
- func (ts *TokenService) ExchangeAuthorizationCode(ctx context.Context, req *TokenRequest, mcpURL string, toolsetId uuid.UUID) (*Token, error)
- func (ts *TokenService) SetTokenExpiration(accessTokenExpiration time.Duration)
- func (ts *TokenService) ValidateAccessToken(ctx context.Context, toolsetId uuid.UUID, accessToken string) (*Token, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientInfoCacheKey ¶
Types ¶
type AuthorizationRequest ¶
type AuthorizationRequest struct {
ResponseType string `json:"response_type"`
ClientID string `json:"client_id"`
RedirectURI string `json:"redirect_uri"`
Scope string `json:"scope"`
State string `json:"state"`
CodeChallenge string `json:"code_challenge"`
CodeChallengeMethod string `json:"code_challenge_method"`
Nonce string `json:"nonce"`
}
AuthorizationRequest represents an OAuth authorization request
type ClientInfo ¶
type ClientInfo struct {
MCPURL string `json:"mcp_url"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
ClientSecretExpiresAt int64 `json:"client_secret_expires_at"`
ClientName string `json:"client_name"`
RedirectURIs []string `json:"redirect_uris"`
GrantTypes []string `json:"grant_types"`
ResponseTypes []string `json:"response_types"`
Scope string `json:"scope"`
TokenEndpointAuthMethod string `json:"token_endpoint_auth_method"`
ApplicationType string `json:"application_type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ClientInfo represents an OAuth client registration
type ClientRegistrationService ¶
type ClientRegistrationService struct {
// contains filtered or unexported fields
}
ClientRegistrationService handles OAuth Dynamic Client Registration
func NewClientRegistrationService ¶
func NewClientRegistrationService(cacheImpl cache.Cache, logger *slog.Logger) *ClientRegistrationService
func (*ClientRegistrationService) GetClient ¶
func (s *ClientRegistrationService) GetClient(ctx context.Context, mcpURL string, clientID string) (*ClientInfo, error)
func (*ClientRegistrationService) IsValidRedirectURI ¶
func (s *ClientRegistrationService) IsValidRedirectURI(ctx context.Context, mcpURL string, clientID, redirectURI string) (bool, error)
IsValidRedirectURI checks if a redirect URI is valid for the client
func (*ClientRegistrationService) RegisterClient ¶
func (s *ClientRegistrationService) RegisterClient(ctx context.Context, req *ClientInfo, mcpURL string) (*ClientInfo, error)
RegisterClient implements RFC 7591 Dynamic Client Registration
func (*ClientRegistrationService) ValidateClientCredentials ¶
func (s *ClientRegistrationService) ValidateClientCredentials(ctx context.Context, mcpURL string, clientID, clientSecret string) (*ClientInfo, error)
ValidateClientCredentials validates client credentials
type ConsentTemplateData ¶
type ConsentTemplateData struct {
ClientID string
ClientName string
ToolsetName string
RedirectURI string
Scope string
Scopes []string
State string
CodeChallenge string
CodeChallengeMethod string
ResponseType string
MCPURL string
MCPSlug string
}
ConsentTemplateData represents the data for the consent screen
type ExternalSecret ¶
type Grant ¶
type Grant struct {
ToolsetID uuid.UUID
Code string
ClientID string
RedirectURI string
Scope string
State string
CodeChallenge string
CodeChallengeMethod string
Props map[string]string
CreatedAt time.Time
ExpiresAt time.Time
ExternalSecrets []ExternalSecret
}
Grant represents an OAuth authorization grant
func (Grant) AdditionalCacheKeys ¶
type GrantManager ¶
type GrantManager struct {
// contains filtered or unexported fields
}
GrantManager handles OAuth authorization grant operations
func NewGrantManager ¶
func NewGrantManager(cacheImpl cache.Cache, clientRegistration *ClientRegistrationService, pkceService *PKCEService, logger *slog.Logger, enc *encryption.Client) *GrantManager
func (*GrantManager) BuildAuthorizationResponse ¶
func (gm *GrantManager) BuildAuthorizationResponse(ctx context.Context, grant *Grant, redirectURI string) (string, error)
BuildAuthorizationResponse builds the authorization response URL
func (*GrantManager) BuildErrorResponse ¶
func (gm *GrantManager) BuildErrorResponse(ctx context.Context, redirectURI, errorString, errorDescription, state string) (string, error)
BuildErrorResponse builds an error response URL
func (*GrantManager) CreateAuthorizationGrant ¶
func (gm *GrantManager) CreateAuthorizationGrant(ctx context.Context, req *AuthorizationRequest, mcpURL string, toolsetId uuid.UUID, accessToken string, expiresAt *time.Time, securityKeys []string) (*Grant, error)
CreateAuthorizationGrant creates a new authorization grant
func (*GrantManager) ValidateAndConsumeGrant ¶
func (gm *GrantManager) ValidateAndConsumeGrant(ctx context.Context, toolsetId uuid.UUID, code, clientID, redirectURI string) (*Grant, error)
ValidateAndConsumeGrant validates and consumes an authorization grant
func (*GrantManager) ValidateAuthorizationRequest ¶
func (gm *GrantManager) ValidateAuthorizationRequest(ctx context.Context, req *AuthorizationRequest, mcpURL string) error
ValidateAuthorizationRequest validates an authorization request
type OauthProxyClientInfo ¶
type OauthProxyClientInfo struct {
MCPURL string
ClientID string
ClientSecret string
ClientSecretExpiresAt time.Time
ClientName string
RedirectUris []string
GrantTypes []string
ResponseTypes []string
Scope string
TokenEndpointAuthMethod string
ApplicationType string
CreatedAt time.Time
UpdatedAt time.Time
}
func (OauthProxyClientInfo) AdditionalCacheKeys ¶
func (o OauthProxyClientInfo) AdditionalCacheKeys() []string
func (OauthProxyClientInfo) CacheKey ¶
func (o OauthProxyClientInfo) CacheKey() string
func (OauthProxyClientInfo) TTL ¶
func (o OauthProxyClientInfo) TTL() time.Duration
type PKCEService ¶
type PKCEService struct {
// contains filtered or unexported fields
}
PKCEService handles PKCE (Proof Key for Code Exchange) operations
func NewPKCEService ¶
func NewPKCEService(logger *slog.Logger) *PKCEService
func (*PKCEService) GenerateCodeChallenge ¶
func (s *PKCEService) GenerateCodeChallenge(codeVerifier string, method string) (string, error)
GenerateCodeChallenge generates a code challenge from a code verifier
func (*PKCEService) ValidateCodeChallenge ¶
func (s *PKCEService) ValidateCodeChallenge(ctx context.Context, codeChallenge string, method string) error
ValidateCodeChallenge validates that a code challenge is properly formatted
func (*PKCEService) ValidateCodeVerifier ¶
func (s *PKCEService) ValidateCodeVerifier(ctx context.Context, codeVerifier string) error
ValidateCodeVerifier validates that a code verifier is properly formatted
func (*PKCEService) ValidatePKCEFlow ¶
func (s *PKCEService) ValidatePKCEFlow(ctx context.Context, grant *Grant, codeVerifier string) error
ValidatePKCEFlow validates the complete PKCE flow
func (*PKCEService) VerifyCodeChallenge ¶
func (s *PKCEService) VerifyCodeChallenge(ctx context.Context, codeVerifier, codeChallenge, method string) error
VerifyCodeChallenge verifies that a code verifier matches the code challenge
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(logger *slog.Logger, tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider, db *pgxpool.Pool, serverURL *url.URL, cacheImpl cache.Cache, enc *encryption.Client, env *environments.EnvironmentEntries) *Service
type Token ¶
type Token struct {
ToolsetID uuid.UUID `json:"-"`
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
Scope string `json:"scope,omitempty"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
ExternalSecrets []ExternalSecret `json:"-"` // this should never be exposed in JSON
}
Token represents an OAuth access token
func (Token) AdditionalCacheKeys ¶
type TokenRequest ¶
type TokenRequest struct {
GrantType string `json:"grant_type"`
Code string `json:"code"`
RedirectURI string `json:"redirect_uri"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
CodeVerifier string `json:"code_verifier"`
}
TokenRequest represents an OAuth token request
type TokenResponse ¶
type TokenService ¶
type TokenService struct {
// contains filtered or unexported fields
}
TokenService handles OAuth token operations
func NewTokenService ¶
func NewTokenService(cacheImpl cache.Cache, clientRegistration *ClientRegistrationService, grantManager *GrantManager, pkceService *PKCEService, logger *slog.Logger, enc *encryption.Client) *TokenService
func (*TokenService) CreateErrorResponse ¶
func (ts *TokenService) CreateErrorResponse(errorType, description string) map[string]interface{}
CreateErrorResponse creates a standardized error response
func (*TokenService) CreateTokenResponse ¶
func (ts *TokenService) CreateTokenResponse(token *Token) *TokenResponse
CreateTokenResponse creates a standardized token response
func (*TokenService) ExchangeAuthorizationCode ¶
func (ts *TokenService) ExchangeAuthorizationCode(ctx context.Context, req *TokenRequest, mcpURL string, toolsetId uuid.UUID) (*Token, error)
ExchangeAuthorizationCode exchanges an authorization code for tokens
func (*TokenService) SetTokenExpiration ¶
func (ts *TokenService) SetTokenExpiration(accessTokenExpiration time.Duration)
SetTokenExpiration sets custom token expiration time
func (*TokenService) ValidateAccessToken ¶
func (ts *TokenService) ValidateAccessToken(ctx context.Context, toolsetId uuid.UUID, accessToken string) (*Token, error)
ValidateAccessToken validates an access token