Documentation
¶
Index ¶
- Constants
- Variables
- func AnnotateCredentials(integrationType string, creds *types.IntegrationCredentials, ...) *types.IntegrationCredentials
- func MergeCredentialMetadata(target, source *types.IntegrationCredentials) *types.IntegrationCredentials
- func NeedsRefresh(creds *types.IntegrationCredentials) bool
- func NormalizeScopes(scopes ...[]string) []string
- func ParseScopeString(scope string) []string
- type AtlassianProvider
- func (a *AtlassianProvider) AuthorizeURL(state, integrationType string) (string, error)
- func (a *AtlassianProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
- func (a *AtlassianProvider) Integrations() []string
- func (a *AtlassianProvider) IsConfigured() bool
- func (a *AtlassianProvider) Name() string
- func (a *AtlassianProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
- type Backend
- type GitHubProvider
- func (g *GitHubProvider) AuthorizeURL(state, integrationType string) (string, error)
- func (g *GitHubProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
- func (g *GitHubProvider) Integrations() []string
- func (g *GitHubProvider) IsConfigured() bool
- func (g *GitHubProvider) Name() string
- func (g *GitHubProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
- type GoogleProvider
- func (g *GoogleProvider) AuthorizeURL(state, integrationType string) (string, error)
- func (g *GoogleProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
- func (g *GoogleProvider) Integrations() []string
- func (g *GoogleProvider) IsConfigured() bool
- func (g *GoogleProvider) Name() string
- func (g *GoogleProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
- type LinearProvider
- func (l *LinearProvider) AuthorizeURL(state, integrationType string) (string, error)
- func (l *LinearProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
- func (l *LinearProvider) Integrations() []string
- func (l *LinearProvider) IsConfigured() bool
- func (l *LinearProvider) Name() string
- func (l *LinearProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
- type MicrosoftProvider
- func (m *MicrosoftProvider) AuthorizeURL(state, integrationType string) (string, error)
- func (m *MicrosoftProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
- func (m *MicrosoftProvider) Integrations() []string
- func (m *MicrosoftProvider) IsConfigured() bool
- func (m *MicrosoftProvider) Name() string
- func (m *MicrosoftProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
- type NotionProvider
- func (n *NotionProvider) AuthorizeURL(state, integrationType string) (string, error)
- func (n *NotionProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
- func (n *NotionProvider) Integrations() []string
- func (n *NotionProvider) IsConfigured() bool
- func (n *NotionProvider) Name() string
- func (n *NotionProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
- type Provider
- type Registry
- func (r *Registry) GetProvider(name string) (Provider, error)
- func (r *Registry) GetProviderForIntegration(integrationType string) (Provider, error)
- func (r *Registry) IsOAuthIntegration(integrationType string) bool
- func (r *Registry) ListConfiguredProviders() []string
- func (r *Registry) ListIntegrations() []string
- func (r *Registry) Register(p Provider)
- type Session
- type SessionStatus
- type SlackProvider
- func (s *SlackProvider) AuthorizeURL(state, integrationType string) (string, error)
- func (s *SlackProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
- func (s *SlackProvider) Integrations() []string
- func (s *SlackProvider) IsConfigured() bool
- func (s *SlackProvider) Name() string
- func (s *SlackProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
- type Store
- func (s *Store) Complete(id, connectionID string) error
- func (s *Store) Create(providerName string, workspaceID uint, ...) (*Session, error)
- func (s *Store) Delete(id string) error
- func (s *Store) Fail(id, errMsg string) error
- func (s *Store) Get(id string) (*Session, error)
- func (s *Store) GetByState(state string) (*Session, error)
Constants ¶
const (
DefaultSessionTTL = 10 * time.Minute
)
Variables ¶
Functions ¶
func AnnotateCredentials ¶ added in v0.1.71
func AnnotateCredentials(integrationType string, creds *types.IntegrationCredentials, grantedScopes []string) *types.IntegrationCredentials
func MergeCredentialMetadata ¶ added in v0.1.71
func MergeCredentialMetadata(target, source *types.IntegrationCredentials) *types.IntegrationCredentials
MergeCredentialMetadata copies all Extra keys from source to target when missing. This keeps persisted metadata (capabilities, scopes, cloud_id, etc.) stable across token refreshes.
func NeedsRefresh ¶
func NeedsRefresh(creds *types.IntegrationCredentials) bool
NeedsRefresh returns true if credentials are expired or about to expire.
func NormalizeScopes ¶ added in v0.1.71
func ParseScopeString ¶ added in v0.1.71
Types ¶
type AtlassianProvider ¶ added in v0.1.95
type AtlassianProvider struct {
// contains filtered or unexported fields
}
AtlassianProvider handles Atlassian OAuth 2.0 (3LO) operations.
func NewAtlassianProvider ¶ added in v0.1.95
func NewAtlassianProvider(creds types.ProviderOAuthCredentials, callbackURL string) *AtlassianProvider
func (*AtlassianProvider) AuthorizeURL ¶ added in v0.1.95
func (a *AtlassianProvider) AuthorizeURL(state, integrationType string) (string, error)
func (*AtlassianProvider) Exchange ¶ added in v0.1.95
func (a *AtlassianProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
func (*AtlassianProvider) Integrations ¶ added in v0.1.95
func (a *AtlassianProvider) Integrations() []string
func (*AtlassianProvider) IsConfigured ¶ added in v0.1.95
func (a *AtlassianProvider) IsConfigured() bool
func (*AtlassianProvider) Name ¶ added in v0.1.95
func (a *AtlassianProvider) Name() string
func (*AtlassianProvider) Refresh ¶ added in v0.1.95
func (a *AtlassianProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
type Backend ¶ added in v0.1.15
type Backend interface {
Get(ctx context.Context, key string) ([]byte, error)
Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
Delete(ctx context.Context, key string) error
}
Backend abstracts session storage.
type GitHubProvider ¶
type GitHubProvider struct {
// contains filtered or unexported fields
}
GitHubProvider handles GitHub OAuth operations.
func NewGitHubProvider ¶
func NewGitHubProvider(creds types.ProviderOAuthCredentials, callbackURL string) *GitHubProvider
func (*GitHubProvider) AuthorizeURL ¶
func (g *GitHubProvider) AuthorizeURL(state, integrationType string) (string, error)
func (*GitHubProvider) Exchange ¶
func (g *GitHubProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
func (*GitHubProvider) Integrations ¶ added in v0.1.15
func (g *GitHubProvider) Integrations() []string
func (*GitHubProvider) IsConfigured ¶
func (g *GitHubProvider) IsConfigured() bool
func (*GitHubProvider) Name ¶
func (g *GitHubProvider) Name() string
func (*GitHubProvider) Refresh ¶
func (g *GitHubProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
type GoogleProvider ¶
type GoogleProvider struct {
// contains filtered or unexported fields
}
GoogleProvider handles Google OAuth operations.
func NewGoogleProvider ¶
func NewGoogleProvider(creds types.ProviderOAuthCredentials, callbackURL string) *GoogleProvider
func (*GoogleProvider) AuthorizeURL ¶
func (g *GoogleProvider) AuthorizeURL(state, integrationType string) (string, error)
func (*GoogleProvider) Exchange ¶
func (g *GoogleProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
func (*GoogleProvider) Integrations ¶ added in v0.1.15
func (g *GoogleProvider) Integrations() []string
func (*GoogleProvider) IsConfigured ¶
func (g *GoogleProvider) IsConfigured() bool
func (*GoogleProvider) Name ¶
func (g *GoogleProvider) Name() string
func (*GoogleProvider) Refresh ¶
func (g *GoogleProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
type LinearProvider ¶ added in v0.1.9
type LinearProvider struct {
// contains filtered or unexported fields
}
LinearProvider handles Linear OAuth operations.
func NewLinearProvider ¶ added in v0.1.9
func NewLinearProvider(creds types.ProviderOAuthCredentials, callbackURL string) *LinearProvider
func (*LinearProvider) AuthorizeURL ¶ added in v0.1.9
func (l *LinearProvider) AuthorizeURL(state, integrationType string) (string, error)
func (*LinearProvider) Exchange ¶ added in v0.1.9
func (l *LinearProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
func (*LinearProvider) Integrations ¶ added in v0.1.15
func (l *LinearProvider) Integrations() []string
func (*LinearProvider) IsConfigured ¶ added in v0.1.9
func (l *LinearProvider) IsConfigured() bool
func (*LinearProvider) Name ¶ added in v0.1.9
func (l *LinearProvider) Name() string
func (*LinearProvider) Refresh ¶ added in v0.1.9
func (l *LinearProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
type MicrosoftProvider ¶ added in v0.1.143
type MicrosoftProvider struct {
// contains filtered or unexported fields
}
MicrosoftProvider handles Microsoft OAuth 2.0 operations.
func NewMicrosoftProvider ¶ added in v0.1.143
func NewMicrosoftProvider(creds types.ProviderOAuthCredentials, callbackURL string) *MicrosoftProvider
func (*MicrosoftProvider) AuthorizeURL ¶ added in v0.1.143
func (m *MicrosoftProvider) AuthorizeURL(state, integrationType string) (string, error)
func (*MicrosoftProvider) Exchange ¶ added in v0.1.143
func (m *MicrosoftProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
func (*MicrosoftProvider) Integrations ¶ added in v0.1.143
func (m *MicrosoftProvider) Integrations() []string
func (*MicrosoftProvider) IsConfigured ¶ added in v0.1.143
func (m *MicrosoftProvider) IsConfigured() bool
func (*MicrosoftProvider) Name ¶ added in v0.1.143
func (m *MicrosoftProvider) Name() string
func (*MicrosoftProvider) Refresh ¶ added in v0.1.143
func (m *MicrosoftProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
type NotionProvider ¶
type NotionProvider struct {
// contains filtered or unexported fields
}
NotionProvider handles Notion OAuth operations.
func NewNotionProvider ¶
func NewNotionProvider(creds types.ProviderOAuthCredentials, callbackURL string) *NotionProvider
func (*NotionProvider) AuthorizeURL ¶
func (n *NotionProvider) AuthorizeURL(state, integrationType string) (string, error)
func (*NotionProvider) Exchange ¶
func (n *NotionProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
func (*NotionProvider) Integrations ¶ added in v0.1.15
func (n *NotionProvider) Integrations() []string
func (*NotionProvider) IsConfigured ¶
func (n *NotionProvider) IsConfigured() bool
func (*NotionProvider) Name ¶
func (n *NotionProvider) Name() string
func (*NotionProvider) Refresh ¶
func (n *NotionProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
type Provider ¶
type Provider interface {
// Name returns the provider name (e.g., "google", "github")
Name() string
// IsConfigured returns true if the provider has valid credentials
IsConfigured() bool
// Integrations returns the integration types this provider handles
Integrations() []string
// AuthorizeURL generates the OAuth authorization URL for the given integration
AuthorizeURL(state, integrationType string) (string, error)
// Exchange exchanges an authorization code for tokens
Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
// Refresh refreshes an access token using a refresh token
Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
}
Provider defines the interface for OAuth providers.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages OAuth providers and maps integration types to providers.
func (*Registry) GetProvider ¶
GetProvider returns a provider by name.
func (*Registry) GetProviderForIntegration ¶
GetProviderForIntegration returns the provider that handles the given integration type.
func (*Registry) IsOAuthIntegration ¶
IsOAuthIntegration returns true if the integration type uses OAuth.
func (*Registry) ListConfiguredProviders ¶
ListConfiguredProviders returns names of all configured providers.
func (*Registry) ListIntegrations ¶
ListIntegrations returns all registered integration types.
type Session ¶
type Session struct {
ID string `json:"id"`
State string `json:"state"`
ProviderName string `json:"provider"`
WorkspaceID uint `json:"workspace_id_internal"`
WorkspaceExt string `json:"workspace_id"`
IntegrationType string `json:"integration_type"`
Status SessionStatus `json:"status"`
Error string `json:"error,omitempty"`
ConnectionID string `json:"connection_id,omitempty"`
ReturnTo string `json:"return_to,omitempty"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
Session represents an OAuth session in progress.
type SessionStatus ¶
type SessionStatus string
const ( StatusPending SessionStatus = "pending" StatusComplete SessionStatus = "complete" StatusError SessionStatus = "error" )
type SlackProvider ¶
type SlackProvider struct {
// contains filtered or unexported fields
}
SlackProvider handles Slack OAuth operations.
func NewSlackProvider ¶
func NewSlackProvider(creds types.ProviderOAuthCredentials, callbackURL string) *SlackProvider
func (*SlackProvider) AuthorizeURL ¶
func (s *SlackProvider) AuthorizeURL(state, integrationType string) (string, error)
func (*SlackProvider) Exchange ¶
func (s *SlackProvider) Exchange(ctx context.Context, code, integrationType string) (*types.IntegrationCredentials, error)
func (*SlackProvider) Integrations ¶ added in v0.1.15
func (s *SlackProvider) Integrations() []string
func (*SlackProvider) IsConfigured ¶
func (s *SlackProvider) IsConfigured() bool
func (*SlackProvider) Name ¶
func (s *SlackProvider) Name() string
func (*SlackProvider) Refresh ¶
func (s *SlackProvider) Refresh(ctx context.Context, refreshToken string) (*types.IntegrationCredentials, error)
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages OAuth sessions.
func NewStore ¶
func NewStore(client *common.RedisClient, ttl time.Duration) *Store
NewStore creates a session store. Uses Redis if client is non-nil, otherwise falls back to memory.
func (*Store) Create ¶
func (s *Store) Create(providerName string, workspaceID uint, workspaceExt, integrationType, returnTo string) (*Session, error)
Create creates a new pending OAuth session.