oauth

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProviderForLazySetup

func RegisterProviderForLazySetup(ctx context.Context, serverName string) error

RegisterProviderForLazySetup registers a DCR provider with Docker Desktop This allows 'docker mcp oauth authorize' to work before full DCR is complete Idempotent - safe to call multiple times for the same server

Types

type CredentialHelper

type CredentialHelper struct {
	// contains filtered or unexported fields
}

CredentialHelper provides secure access to OAuth tokens via docker-credential-desktop

func NewOAuthCredentialHelper

func NewOAuthCredentialHelper() *CredentialHelper

NewOAuthCredentialHelper creates a new OAuth credential helper

func (*CredentialHelper) GetOAuthToken

func (h *CredentialHelper) GetOAuthToken(ctx context.Context, serverName string) (string, error)

GetOAuthToken retrieves an OAuth token for the specified server It follows this flow: 1. Get DCR client info to retrieve provider name and authorization endpoint 2. Construct credential key using: [AuthorizationEndpoint]/[ProviderName] 3. Retrieve token from docker-credential-desktop

func (*CredentialHelper) GetTokenStatus

func (h *CredentialHelper) GetTokenStatus(ctx context.Context, serverName string) (TokenStatus, error)

GetTokenStatus checks if an OAuth token is valid and whether it needs refresh

type Event

type Event struct {
	Type     EventType
	Provider string
	Message  string
	Error    string
}

Event represents a parsed OAuth notification event

type EventType

type EventType string

EventType represents the type of OAuth event from Docker Desktop

const (
	EventLoginStart    EventType = "login-start"
	EventCodeReceived  EventType = "code-received"
	EventLoginSuccess  EventType = "login-success"
	EventTokenRefresh  EventType = "token-refresh"
	EventLogoutSuccess EventType = "logout-success"
	EventError         EventType = "error"
)

type NotificationMonitor

type NotificationMonitor struct {
	OnOAuthEvent func(event Event)
	// contains filtered or unexported fields
}

NotificationMonitor subscribes to Docker Desktop's OAuth notification stream

func NewNotificationMonitor

func NewNotificationMonitor() *NotificationMonitor

NewNotificationMonitor creates a new notification monitor

func (*NotificationMonitor) Start

func (m *NotificationMonitor) Start(ctx context.Context)

Start begins monitoring OAuth notifications from Docker Desktop

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider manages OAuth token lifecycle for a single MCP server Each provider runs in its own goroutine with dynamic timing based on token expiry

func NewProvider

func NewProvider(name string, reloadFn func(context.Context, string) error) *Provider

NewProvider creates a new OAuth provider

func (*Provider) Run

func (p *Provider) Run(ctx context.Context)

Run starts the provider's background loop Loop dynamically adjusts timing based on token expiry

func (*Provider) SendEvent

func (p *Provider) SendEvent(event Event)

SendEvent sends an SSE event to this provider's event channel

func (*Provider) Stop

func (p *Provider) Stop()

Stop signals the provider to shutdown gracefully Safe to call multiple times - stopChan only closed once

type TokenStatus

type TokenStatus struct {
	Valid        bool
	ExpiresAt    time.Time
	NeedsRefresh bool
}

TokenStatus represents the validity status of an OAuth token

Jump to

Keyboard shortcuts

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