Documentation
¶
Index ¶
Constants ¶
const ( // MCP Server OAuth endpoints (which proxy to Clerk) AuthURL = "https://auth.onkernel.com/authorize" TokenURL = "https://auth.onkernel.com/token" // OAuth client configuration ClientID = "hmFrJn9hKDV2N02M" // Prod Kernel CLI OAuth Client ID RedirectURI = "http://localhost" // OAuth scopes - openid for the MCP server flow DefaultScope = "openid email" )
const ( KeyringService = "kernel-cli" KeyringUser = "oauth-tokens" )
Variables ¶
This section is empty.
Functions ¶
func GetAuthenticatedClient ¶
func GetAuthenticatedClient(opts ...option.RequestOption) (*kernel.Client, error)
GetAuthenticatedClient returns a Kernel client with appropriate authentication
func SaveTokens ¶
func SaveTokens(tokens *TokenStorage) error
SaveTokens stores authentication tokens securely in the OS keychain
Types ¶
type AuthResult ¶
AuthResult represents the result data passed through the callback channel
type OAuthConfig ¶
OAuthConfig represents the OAuth2 configuration
func NewOAuthConfig ¶
func NewOAuthConfig() (*OAuthConfig, error)
NewOAuthConfig creates a new OAuth configuration with PKCE
func (*OAuthConfig) StartOAuthFlow ¶
func (oc *OAuthConfig) StartOAuthFlow(ctx context.Context) (*TokenStorage, error)
StartOAuthFlow initiates the OAuth flow with browser redirect
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"`
OrgID string `json:"org_id"`
}
TokenResponse represents the OAuth token response
type TokenStorage ¶
type TokenStorage struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresAt time.Time `json:"expires_at"`
OrgID string `json:"org_id"`
}
TokenStorage represents stored authentication tokens
func LoadTokens ¶
func LoadTokens() (*TokenStorage, error)
LoadTokens retrieves authentication tokens from secure storage
func RefreshTokens ¶
func RefreshTokens(ctx context.Context, tokens *TokenStorage) (*TokenStorage, error)
RefreshTokens refreshes the access token using the refresh token
func (*TokenStorage) IsExpired ¶
func (t *TokenStorage) IsExpired() bool
IsExpired checks if the access token is expired (with 5 minute buffer)