Documentation
¶
Index ¶
- Constants
- func Default() *registry
- func New(store dalConnectionStore, logger *zap.Logger) (*registry, error)
- func SetDefault(reg *registry)
- type APIKeyCredential
- func (c *APIKeyCredential) AuthType() string
- func (c *APIKeyCredential) ConnectionID() uint64
- func (c *APIKeyCredential) GetAccessToken() string
- func (c *APIKeyCredential) MarshalState() map[string]any
- func (c *APIKeyCredential) NeedsRefresh() bool
- func (c *APIKeyCredential) Refresh(_ context.Context, _ *http.Client) error
- type BearerCredential
- func (c *BearerCredential) AuthType() string
- func (c *BearerCredential) ConnectionID() uint64
- func (c *BearerCredential) GetAccessToken() string
- func (c *BearerCredential) MarshalState() map[string]any
- func (c *BearerCredential) NeedsRefresh() bool
- func (c *BearerCredential) Refresh(_ context.Context, _ *http.Client) error
- type Credential
- type CredentialConfig
- type GoogleServiceAccountCredential
- func (c *GoogleServiceAccountCredential) AuthType() string
- func (c *GoogleServiceAccountCredential) ConnectionID() uint64
- func (c *GoogleServiceAccountCredential) GetAccessToken() string
- func (c *GoogleServiceAccountCredential) MarshalState() map[string]any
- func (c *GoogleServiceAccountCredential) NeedsRefresh() bool
- func (c *GoogleServiceAccountCredential) Refresh(ctx context.Context, client *http.Client) error
- type JWTBearerCredential
- func (c *JWTBearerCredential) AuthType() string
- func (c *JWTBearerCredential) ConnectionID() uint64
- func (c *JWTBearerCredential) GetAccessToken() string
- func (c *JWTBearerCredential) MarshalState() map[string]any
- func (c *JWTBearerCredential) NeedsRefresh() bool
- func (c *JWTBearerCredential) Refresh(ctx context.Context, client *http.Client) error
- type OAuth2ClientCredsCredential
- func (c *OAuth2ClientCredsCredential) AuthType() string
- func (c *OAuth2ClientCredsCredential) ConnectionID() uint64
- func (c *OAuth2ClientCredsCredential) GetAccessToken() string
- func (c *OAuth2ClientCredsCredential) MarshalState() map[string]any
- func (c *OAuth2ClientCredsCredential) NeedsRefresh() bool
- func (c *OAuth2ClientCredsCredential) Refresh(ctx context.Context, client *http.Client) error
Constants ¶
const ( // DefaultTokenLifetime is the default JWT assertion lifetime DefaultTokenLifetime = time.Hour )
const ( // OAuth2TokenRefreshBuffer is the time before expiry when token refresh should occur OAuth2TokenRefreshBuffer = 5 * time.Minute )
const ( // RefreshCheckInterval is how often the refresher checks for expiring tokens RefreshCheckInterval = 1 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIKeyCredential ¶
type APIKeyCredential struct {
Key string
// default: X-API-Key
HeaderName string
// optional prefix
Prefix string
// contains filtered or unexported fields
}
APIKeyCredential holds a static API key.
func NewAPIKeyCredential ¶
func NewAPIKeyCredential(connID uint64, key, headerName, prefix string) *APIKeyCredential
func (*APIKeyCredential) AuthType ¶
func (c *APIKeyCredential) AuthType() string
func (*APIKeyCredential) ConnectionID ¶
func (c *APIKeyCredential) ConnectionID() uint64
func (*APIKeyCredential) GetAccessToken ¶
func (c *APIKeyCredential) GetAccessToken() string
func (*APIKeyCredential) MarshalState ¶
func (c *APIKeyCredential) MarshalState() map[string]any
func (*APIKeyCredential) NeedsRefresh ¶
func (c *APIKeyCredential) NeedsRefresh() bool
type BearerCredential ¶
type BearerCredential struct {
Token string
// contains filtered or unexported fields
}
BearerCredential holds a static bearer token.
func NewBearerCredential ¶
func NewBearerCredential(connID uint64, token string) *BearerCredential
func (*BearerCredential) AuthType ¶
func (c *BearerCredential) AuthType() string
func (*BearerCredential) ConnectionID ¶
func (c *BearerCredential) ConnectionID() uint64
func (*BearerCredential) GetAccessToken ¶
func (c *BearerCredential) GetAccessToken() string
func (*BearerCredential) MarshalState ¶
func (c *BearerCredential) MarshalState() map[string]any
func (*BearerCredential) NeedsRefresh ¶
func (c *BearerCredential) NeedsRefresh() bool
type Credential ¶
type Credential interface {
ConnectionID() uint64
AuthType() string
GetAccessToken() string
NeedsRefresh() bool
Refresh(ctx context.Context, client *http.Client) error
MarshalState() map[string]any
}
Credential defines the interface for all credential types. Each auth method implements its own refresh and state management.
func NewCredential ¶
func NewCredential(cfg CredentialConfig) (Credential, error)
NewCredential constructs the appropriate Credential implementation based on the auth type specified in the config.
type CredentialConfig ¶
type CredentialConfig struct {
ConnectionID uint64
AuthType string
Token string
APIKey string
ClientID string
ClientSecret string
TokenURL string
// JWT bearer fields
Issuer string
Subject string
Audience string
Scopes []string
PrivateKey string
TokenLifetime time.Duration
// Google service account fields
ServiceAccountEmail string
}
CredentialConfig holds the parameters needed to construct a Credential.
type GoogleServiceAccountCredential ¶
type GoogleServiceAccountCredential struct {
*JWTBearerCredential
}
GoogleServiceAccountCredential wraps JWTBearerCredential with Google-specific defaults (token URL, audience, default scopes).
func (*GoogleServiceAccountCredential) AuthType ¶
func (c *GoogleServiceAccountCredential) AuthType() string
func (*GoogleServiceAccountCredential) ConnectionID ¶
func (c *GoogleServiceAccountCredential) ConnectionID() uint64
func (*GoogleServiceAccountCredential) GetAccessToken ¶
func (c *GoogleServiceAccountCredential) GetAccessToken() string
func (*GoogleServiceAccountCredential) MarshalState ¶
func (c *GoogleServiceAccountCredential) MarshalState() map[string]any
func (*GoogleServiceAccountCredential) NeedsRefresh ¶
func (c *GoogleServiceAccountCredential) NeedsRefresh() bool
type JWTBearerCredential ¶
type JWTBearerCredential struct {
// Static config
Issuer string // JWT "iss" claim (e.g. service account email)
Subject string // JWT "sub" claim (optional, for domain-wide delegation)
Audience string // JWT "aud" claim (token endpoint URL)
Scopes []string // space-joined into JWT "scope" claim
PrivateKey string // PEM-encoded RSA private key
TokenURL string // token endpoint
TokenLifetime time.Duration // JWT assertion lifetime (default: 1h)
// Mutable runtime state
AccessToken string
ExpiresAt time.Time
// contains filtered or unexported fields
}
JWTBearerCredential handles the JWT bearer assertion grant (grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer).
Works with any provider that accepts a signed JWT assertion (e.g. Google service accounts, Azure AD, custom IdPs).
func NewJWTBearerCredential ¶
func (*JWTBearerCredential) AuthType ¶
func (c *JWTBearerCredential) AuthType() string
func (*JWTBearerCredential) ConnectionID ¶
func (c *JWTBearerCredential) ConnectionID() uint64
func (*JWTBearerCredential) GetAccessToken ¶
func (c *JWTBearerCredential) GetAccessToken() string
func (*JWTBearerCredential) MarshalState ¶
func (c *JWTBearerCredential) MarshalState() map[string]any
func (*JWTBearerCredential) NeedsRefresh ¶
func (c *JWTBearerCredential) NeedsRefresh() bool
type OAuth2ClientCredsCredential ¶
type OAuth2ClientCredsCredential struct {
ClientID string
ClientSecret string
TokenURL string
// Mutable runtime state
AccessToken string
ExpiresAt time.Time
// contains filtered or unexported fields
}
OAuth2ClientCredsCredential handles OAuth2 client credentials grant.
func NewOAuth2ClientCredsCredential ¶
func NewOAuth2ClientCredsCredential(connID uint64, clientID, clientSecret, tokenURL string) *OAuth2ClientCredsCredential
func (*OAuth2ClientCredsCredential) AuthType ¶
func (c *OAuth2ClientCredsCredential) AuthType() string
func (*OAuth2ClientCredsCredential) ConnectionID ¶
func (c *OAuth2ClientCredsCredential) ConnectionID() uint64
func (*OAuth2ClientCredsCredential) GetAccessToken ¶
func (c *OAuth2ClientCredsCredential) GetAccessToken() string
func (*OAuth2ClientCredsCredential) MarshalState ¶
func (c *OAuth2ClientCredsCredential) MarshalState() map[string]any
func (*OAuth2ClientCredsCredential) NeedsRefresh ¶
func (c *OAuth2ClientCredsCredential) NeedsRefresh() bool