Documentation
¶
Index ¶
- Constants
- Variables
- func AccessGrantIsActive(tx *gorm.DB, claims *AccessClaims, now time.Time) bool
- func AuthorizationRedirect(redirectURI, code, state string) (string, error)
- func AuthorizationServerMetadata(origin string) map[string]any
- func ClientDisplayName(tx *gorm.DB, clientID string) string
- func CreateAuthorizationCode(tx *gorm.DB, req *AuthorizeRequest, userID, orgID, factoryID uuid.UUID) (string, error)
- func ExchangeAuthorizationCode(tx *gorm.DB, values url.Values, resource string) (*TokenIssue, string, *OAuthError)
- func MintAccessToken(signer *jwt.Signer, claims AccessClaims, ttl time.Duration) (string, error)
- func MintConsentToken(signer *jwt.Signer, claims ConsentClaims) (string, error)
- func OrganizationAllowsPublicMCP(orgID uuid.UUID) bool
- func ParseAuthorizeRequest(values url.Values, resource string) (*AuthorizeRequest, *OAuthError)
- func ProtectedResourceMetadata(origin string) map[string]any
- func PublicOrigin(r *http.Request, fallback string) string
- func RefreshTokens(tx *gorm.DB, values url.Values, resource string) (*TokenIssue, string, *OAuthError)
- func RegisterClient(tx *gorm.DB, body []byte) (*Client, *OAuthError)
- func RenderConsentPage(clientName, consentToken, errMessage string, workspaces []WorkspaceOption) ([]byte, error)
- func ResolveClient(ctx context.Context, tx *gorm.DB, httpClient mcp.HTTPDoer, ...) (*Client, *OAuthError)
- func ResolveConsentWorkspace(ctx context.Context, account *models.Account, factoryID string) (uuid.UUID, uuid.UUID, uuid.UUID, error)
- func ResourceURL(origin string) string
- func ServerInfo() map[string]any
- func ToolError(message string) error
- func UserAccountBlocked(tx *gorm.DB, userID uuid.UUID) bool
- func WWWAuthenticate(origin string) string
- type AccessClaims
- type AuthorizeRequest
- type Client
- type ConsentClaims
- type JSONRPCError
- type JSONRPCRequest
- type JSONRPCResponse
- type OAuthError
- type Runtime
- type TokenIssue
- type Tool
- type ToolResult
- type WorkspaceOption
Constants ¶
View Source
const ( AuthorizationCodeTTL = 10 * time.Minute RefreshTokenTTL = 30 * 24 * time.Hour )
View Source
const ( PathMCP = "/mcp" PathAuthorize = "/oauth/authorize" PathToken = "/oauth/token" PathRegister = "/oauth/register" PathProtectedResource = "/.well-known/oauth-protected-resource" PathProtectedResourceMCP = PathProtectedResource + PathMCP PathAuthorizationServer = "/.well-known/oauth-authorization-server" PathAuthorizationServerMCP = PathAuthorizationServer + PathMCP LocalClientID = "superplane-local" LocalClientName = "Cursor" ServerName = "SuperPlane" ServerVersion = "1.0.0" AccessTokenPurpose = "mcp_workspace" ConsentPurpose = "mcp_consent" )
View Source
const AccessTokenTTL = time.Hour
View Source
const ConsentTTL = 10 * time.Minute
View Source
const ServerWebsiteURL = "https://superplane.com"
Variables ¶
View Source
var CursorRedirectURIs = []string{
"http://localhost:8787/callback",
"cursor://anysphere.cursor-mcp/oauth/callback",
}
View Source
var GrantedScopes = []string{
"work_orders:read",
"work_orders:create",
"work_orders:update",
}
Functions ¶
func AccessGrantIsActive ¶
func AuthorizationRedirect ¶
func CreateAuthorizationCode ¶
func ExchangeAuthorizationCode ¶
func ExchangeAuthorizationCode(tx *gorm.DB, values url.Values, resource string) (*TokenIssue, string, *OAuthError)
func MintAccessToken ¶
func MintConsentToken ¶
func MintConsentToken(signer *jwt.Signer, claims ConsentClaims) (string, error)
func ParseAuthorizeRequest ¶
func ParseAuthorizeRequest(values url.Values, resource string) (*AuthorizeRequest, *OAuthError)
func RefreshTokens ¶
func RefreshTokens(tx *gorm.DB, values url.Values, resource string) (*TokenIssue, string, *OAuthError)
func RegisterClient ¶
func RegisterClient(tx *gorm.DB, body []byte) (*Client, *OAuthError)
func RenderConsentPage ¶
func RenderConsentPage(clientName, consentToken, errMessage string, workspaces []WorkspaceOption) ([]byte, error)
func ResolveClient ¶
func ResolveConsentWorkspace ¶
func ResourceURL ¶
func ServerInfo ¶
func WWWAuthenticate ¶
Types ¶
type AccessClaims ¶
type AccessClaims struct {
UserID uuid.UUID
OrgID uuid.UUID
FactoryID uuid.UUID
ClientID string
Resource string
Scopes []string
}
func ParseAccessToken ¶
func ParseAccessToken(signer *jwt.Signer, token, resource string) (*AccessClaims, error)
func (AccessClaims) HasScope ¶
func (c AccessClaims) HasScope(scope string) bool
type AuthorizeRequest ¶
type ConsentClaims ¶
type ConsentClaims struct {
ClientID string
RedirectURI string
State string
CodeChallenge string
CodeChallengeMethod string
Resource string
ResponseType string
}
func ParseConsentToken ¶
func ParseConsentToken(signer *jwt.Signer, token string) (*ConsentClaims, error)
type JSONRPCError ¶
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params"`
}
func ParseJSONRPC ¶
func ParseJSONRPC(body io.Reader) (*JSONRPCRequest, error)
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Result any `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
}
func HandleJSONRPC ¶
func HandleJSONRPC(ctx context.Context, runtime *Runtime, claims *AccessClaims, message *JSONRPCRequest) *JSONRPCResponse
type OAuthError ¶
func (*OAuthError) Error ¶
func (e *OAuthError) Error() string
type Runtime ¶
type Runtime struct {
Auth authorization.PermissionChecker
Intake factories.IntakeDependencies
}
type TokenIssue ¶
type Tool ¶
type ToolResult ¶
type ToolResult struct {
Content []map[string]any `json:"content"`
IsError bool `json:"isError,omitempty"`
}
func TextResult ¶
func TextResult(text string) ToolResult
type WorkspaceOption ¶
func ListConsentWorkspaces ¶
Click to show internal directories.
Click to hide internal directories.