auth

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// MCP Server OAuth endpoints (which proxy to Clerk)
	// Production
	AuthURL  = "https://auth.onkernel.com/authorize"
	TokenURL = "https://auth.onkernel.com/token"

	// OAuth client configuration
	ClientID = "hmFrJn9hKDV2N02M" // Prod Kernel CLI OAuth Client ID
	// ClientID    = "gkUVbm11p6EqKd7r" // Staging Kernel CLI OAuth Client ID
	// ClientID    = "J7i8BKwyFBoyPQN3" // Local Kernel CLI OAuth Client ID
	RedirectURI = "http://localhost"

	// OAuth scopes - openid for the MCP server flow
	DefaultScope = "openid email"
)
View Source
const (
	KeyringService = "kernel-cli"
	KeyringUser    = "oauth-tokens"
)

Variables

This section is empty.

Functions

func DeleteTokens

func DeleteTokens() error

DeleteTokens removes stored authentication tokens

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

type AuthResult struct {
	Code  string `json:"code"`
	OrgID string `json:"org_id,omitempty"`
}

AuthResult represents the result data passed through the callback channel

type OAuthConfig

type OAuthConfig struct {
	Config   *oauth2.Config
	Verifier string
	State    string
}

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)

Jump to

Keyboard shortcuts

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