Documentation
¶
Index ¶
- Constants
- Variables
- func CreateContextWithTokenSource(ctx context.Context) (context.Context, error)
- func GetAPIClient() (*sncloud.APIClient, error)
- func GetSNCloudLogClient() (*http.Client, error)
- func InitSNCloudClient(issuerURL, audience, keyFilePath, apiURL string, timeout time.Duration, ...) error
- func InitSNCloudLogClient(issuerData auth.Issuer, tokenStore store.Store) error
- func ResetSNCloudLogClient()
- func TokenRefreshed(audience string, token *oauth2.Token, tokenStore store.Store) error
- type Auth
- type AuthOptions
- type Context
- type ExternalKafka
- type ExternalPulsar
- type OAuth2TokenRefresher
- type Options
- type SnConfig
- type Storage
Constants ¶
const ( ServiceName = "StreamNativeMCP" KeychainName = "snmcp" )
const ( EnvConfigDir = "SNMCP_CONFIG_DIR" GlobalDefaultIssuer = "https://auth.streamnative.cloud/" GlobalDefaultClientID = "AJYEdHWi9EFekEaUXkPWA2MqQ3lq1NrI" GlobalDefaultAudience = "https://api.streamnative.cloud" GlobalDefaultAPIServer = "https://api.streamnative.cloud" GlobalDefaultProxyLocation = "https://proxy.streamnative.cloud" GlobalDefaultLogLocation = "https://log.streamnative.cloud" )
Variables ¶
var SNCloudClient *sncloud.APIClient
var SNCloudClientConfiguration *sncloud.Configuration
var SNCloudLogClient *http.Client
Functions ¶
func CreateContextWithTokenSource ¶
CreateContextWithTokenSource creates a context with the TokenSource This might be useful in special scenarios, but is usually not needed as we've already configured the default HTTP client
func GetAPIClient ¶
GetAPIClient returns the initialized API client or an error if not initialized
func GetSNCloudLogClient ¶
func InitSNCloudClient ¶
func InitSNCloudClient(issuerURL, audience, keyFilePath, apiURL string, timeout time.Duration, tokenStore store.Store) error
InitSNCloudClient initializes the StreamNative Cloud API client Parameters:
- issuerURL: OAuth2 authorization server URL
- audience: API service audience identifier
- keyFilePath: Client credentials key file path
- apiURL: API server URL
- timeout: HTTP client timeout
- tokenStore: Store for caching tokens
func InitSNCloudLogClient ¶
func ResetSNCloudLogClient ¶
func ResetSNCloudLogClient()
Types ¶
type Auth ¶
type Auth struct {
// the OAuth 2.0 issuer endpoint
IssuerEndpoint string `yaml:"issuer"`
// the audience identifier for the API server (default: server URL)
Audience string `yaml:"audience"`
// the client ID to use for authorization grants (note: not used for service accounts)
ClientID string `yaml:"client-id"`
}
type AuthOptions ¶
type AuthOptions struct {
BackendOverride string
// AuthOptions is a facade for the token store
// note: call Complete before using the token store methods
store.Store
// contains filtered or unexported fields
}
func NewDefaultAuthOptions ¶
func NewDefaultAuthOptions() AuthOptions
func (*AuthOptions) AddFlags ¶
func (o *AuthOptions) AddFlags(cmd *cobra.Command)
func (*AuthOptions) Complete ¶
func (o *AuthOptions) Complete(storage Storage) error
type ExternalKafka ¶
type ExternalKafka struct {
BootstrapServers string
AuthType string
AuthMechanism string
AuthUser string
AuthPass string
UseTLS bool
ClientKeyFile string
ClientCertFile string
CaFile string
SchemaRegistryURL string
SchemaRegistryAuthUser string
SchemaRegistryAuthPass string
SchemaRegistryBearerToken string
}
type ExternalPulsar ¶
type OAuth2TokenRefresher ¶
type OAuth2TokenRefresher struct {
// contains filtered or unexported fields
}
OAuth2TokenRefresher implements oauth2.TokenSource interface for refreshing OAuth2 tokens This is now a wrapper around the cache.CachingTokenSource to leverage the existing token caching
func NewOAuth2TokenRefresher ¶
func NewOAuth2TokenRefresher(tokenStore store.Store, audience string, refresher auth.AuthorizationGrantRefresher) (*OAuth2TokenRefresher, error)
NewOAuth2TokenRefresher creates a new token refresher that uses the stored token cache
type Options ¶
type Options struct {
AuthOptions
ConfigDir string
ConfigPath string
Server string
// the OAuth 2.0 issuer endpoint
IssuerEndpoint string
// the audience identifier for the API server (default: server URL)
Audience string
// the client ID to use for authorization grants (note: not used for service accounts)
ClientID string
Organization string
PulsarInstance string
PulsarCluster string
ProxyLocation string
LogLocation string
KeyFile string
UseExternalKafka bool
UseExternalPulsar bool
Kafka ExternalKafka
Pulsar ExternalPulsar
}
Options represents the common options used throughout the program.
func NewConfigOptions ¶
func NewConfigOptions() *Options
NewConfigOptions creates and returns a new Options instance with default values
func (*Options) GetConfigDirectory ¶
func (*Options) LoadConfig ¶
func (*Options) LoadConfigOrDie ¶
func (*Options) SaveConfig ¶
type SnConfig ¶
type SnConfig struct {
// the API server endpoint
Server string `yaml:"server"`
// CA bundle (base64, PEM)
CertificateAuthorityData string `yaml:"certificate-authority-data"`
// indicates whether to skip TLS verification
InsecureSkipTLSVerify bool `yaml:"insecure-skip-tls-verify"`
// user auth information
Auth Auth `yaml:"auth"`
// settable context
Context Context `yaml:"context"`
ProxyLocation string `yaml:"proxy-location"`
LogLocation string `yaml:"log-location"`
KeyFile string `yaml:"key-file"`
ExternalKafka *ExternalKafka `yaml:"external-kafka"`
ExternalPulsar *ExternalPulsar `yaml:"external-pulsar"`
}
type Storage ¶
type Storage interface {
// Gets the config directory for configuration files, credentials and caches
GetConfigDirectory() string
// LoadConfig loads the raw configuration from storage.
LoadConfig() (*SnConfig, error)
// LoadConfigOrDie loads the raw configuration from storage, or dies if unable to.
LoadConfigOrDie() *SnConfig
// SaveConfig saves the given configuration to storage, overwriting any previous configuration.
SaveConfig(config *SnConfig) error
}