Documentation
¶
Index ¶
- Constants
- func AuthorizationURL(authEndpoint, clientID, redirectURI, state, resource string, pkce PKCE) (string, error)
- func CallbackURL(baseURL string) string
- func ClientDisplayName(storedName, clientID, fallback string) string
- func ClientMetadataDocument(clientMetadataURL, redirectURI string) map[string]any
- func ClientMetadataURL(baseURL string) string
- func DecryptResourceSecret(ctx context.Context, encryptor crypto.Encryptor, resourceID uuid.UUID, ...) (string, error)
- func DecryptedResourceSecret(ctx context.Context, encryptor crypto.Encryptor, db *gorm.DB, ...) (string, error)
- func EncryptResourceSecret(ctx context.Context, encryptor crypto.Encryptor, resourceID uuid.UUID, ...) ([]byte, error)
- func GetJSON(ctx context.Context, httpClient HTTPDoer, rawURL string, dest any) error
- func MintFactoryAgentResourceAccessToken(ctx context.Context, encryptor crypto.Encryptor, httpClient HTTPDoer, ...) (string, error)
- func MintFactoryAgentResourceAccessTokenWithLifetime(ctx context.Context, encryptor crypto.Encryptor, httpClient HTTPDoer, ...) (string, error)
- func RandomState() (string, error)
- func RandomToken() (string, error)
- func RevokeToken(ctx context.Context, httpClient HTTPDoer, ...)
- func S256Challenge(verifier string) string
- func StoreOAuthTokens(ctx context.Context, encryptor crypto.Encryptor, db *gorm.DB, ...) error
- func TimeoutContext(parent context.Context) (context.Context, context.CancelFunc)
- func TokenTTL(tokens *TokenResponse) time.Duration
- func UserFacingOAuthError(err error) string
- func ValidatePublicHTTPSURL(raw string) error
- func VerifyS256(verifier, challenge string) bool
- type AuthorizationServerMetadata
- type ClientRegistration
- type Discovery
- type HTTPDoer
- type PKCE
- type ProtectedResourceMetadata
- type TokenEndpointError
- type TokenResponse
- type Tool
Constants ¶
const ( CodexClientName = "Codex" OpenCodeClientName = "OpenCode" )
const ( ClientName = "SuperPlane" OAuthTimeout = 15 * time.Second MaxMetadataBytes = 1 << 20 DefaultTokenTTL = time.Hour )
Variables ¶
This section is empty.
Functions ¶
func AuthorizationURL ¶
func CallbackURL ¶
func ClientDisplayName ¶
ClientDisplayName returns the label shown for an MCP OAuth client. A stored name that is not a known metadata URL wins. A known client label is used when that stored name is empty or is a metadata URL and the client id is a metadata URL for that client. Otherwise fallback is returned.
func ClientMetadataDocument ¶
func ClientMetadataURL ¶
func DecryptResourceSecret ¶
func DecryptResourceSecret(ctx context.Context, encryptor crypto.Encryptor, resourceID uuid.UUID, value []byte) (string, error)
DecryptResourceSecret decrypts a workspace MCP secret with the resource ID as AAD.
func DecryptedResourceSecret ¶
func DecryptedResourceSecret( ctx context.Context, encryptor crypto.Encryptor, db *gorm.DB, resource *models.FactoryAgentResource, name string, ) (string, error)
DecryptedResourceSecret returns a named secret or an empty string when missing.
func EncryptResourceSecret ¶
func EncryptResourceSecret(ctx context.Context, encryptor crypto.Encryptor, resourceID uuid.UUID, plaintext string) ([]byte, error)
EncryptResourceSecret encrypts a workspace MCP secret with the resource ID as AAD.
func MintFactoryAgentResourceAccessToken ¶
func MintFactoryAgentResourceAccessToken( ctx context.Context, encryptor crypto.Encryptor, httpClient HTTPDoer, db *gorm.DB, resource *models.FactoryAgentResource, ) (string, error)
MintFactoryAgentResourceAccessToken returns a usable OAuth access token for a workspace MCP server. It reuses the stored access token until shortly before expiry, and refreshes under a database lock.
func MintFactoryAgentResourceAccessTokenWithLifetime ¶
func MintFactoryAgentResourceAccessTokenWithLifetime( ctx context.Context, encryptor crypto.Encryptor, httpClient HTTPDoer, db *gorm.DB, resource *models.FactoryAgentResource, minRemaining time.Duration, ) (string, error)
MintFactoryAgentResourceAccessTokenWithLifetime returns a token that remains valid for at least minRemaining. Agent runs pass the execution timeout because they copy the token into fixed headers for the whole run.
func RandomState ¶
func RandomToken ¶
func RevokeToken ¶
func S256Challenge ¶
func StoreOAuthTokens ¶
func StoreOAuthTokens( ctx context.Context, encryptor crypto.Encryptor, db *gorm.DB, resource *models.FactoryAgentResource, tokens *TokenResponse, ) error
StoreOAuthTokens encrypts and persists the access token and optional refresh token. The refresh token is written first. A provider that rotates tokens has already invalidated the previous refresh token by the time this runs.
func TimeoutContext ¶
func TokenTTL ¶
func TokenTTL(tokens *TokenResponse) time.Duration
func UserFacingOAuthError ¶
UserFacingOAuthError returns a short error for the MCP servers page.
func ValidatePublicHTTPSURL ¶
ValidatePublicHTTPSURL rejects empty, non-https, and private MCP endpoints.
func VerifyS256 ¶
Types ¶
type AuthorizationServerMetadata ¶
type AuthorizationServerMetadata struct {
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
RegistrationEndpoint string `json:"registration_endpoint"`
RevocationEndpoint string `json:"revocation_endpoint"`
CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported"`
ClientIDMetadataDocumentSupported bool `json:"client_id_metadata_document_supported"`
}
type ClientRegistration ¶
type ClientRegistration struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
}
func RegisterClient ¶
type Discovery ¶
type Discovery struct {
Resource string
Protected ProtectedResourceMetadata
AuthServer AuthorizationServerMetadata
AuthServerURL string
}
type HTTPDoer ¶
func DoerFromCore ¶
func DoerFromCore(httpCtx core.HTTPContext) HTTPDoer
type TokenEndpointError ¶
TokenEndpointError is a non-success response from an OAuth token endpoint. Code is the OAuth error name, such as invalid_grant, when the body is JSON.
func (*TokenEndpointError) Error ¶
func (e *TokenEndpointError) Error() string
func (*TokenEndpointError) RejectsGrant ¶
func (e *TokenEndpointError) RejectsGrant() bool
RejectsGrant reports whether the authorization server refused the grant. Timeouts and server errors are not a rejected grant.
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int `json:"expires_in"`
TokenType string `json:"token_type"`
}