Documentation
¶
Overview ¶
Package auth provides authentication functionality for the Braintrust SDK.
Index ¶
Constants ¶
const ( // TestAPIKey is a special API key used for testing TestAPIKey = "___TEST_API_KEY___" // DefaultAppURL is the default Braintrust app URL DefaultAppURL = "https://www.braintrust.dev" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// AppURL is the URL of the Braintrust app
AppURL string
// AppPublicURL is the public URL of the Braintrust app
AppPublicURL string
// APIURL is the URL of the Braintrust API
APIURL string
// APIKey is the API key to use
APIKey string
// OrgName is the name of a specific organization to connect to (optional)
OrgName string
// Logger is the logger to use (optional, defaults to noop logger)
Logger logger.Logger
// Client is the HTTPS client to use for login requests (optional)
// If not provided, a default https.Client will be created
// This is primarily used for testing with VCR
Client *https.Client
}
Options contains options for the Login function
type OrgInfo ¶
type OrgInfo struct {
ID string `json:"id"`
Name string `json:"name"`
APIURL string `json:"api_url"`
ProxyURL string `json:"proxy_url"`
}
OrgInfo represents organization information from the login response
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages authentication and login state.
func NewSession ¶
NewSession creates a session and starts login with retry in the background. Returns an error if required fields (APIKey, AppURL) are missing. The context is used for the background login goroutine. If opts.Logger is nil, a noop logger is used. If opts.Client is nil, a default client will be created.
func NewTestSession ¶
func NewTestSession(apiKey, orgID, orgName, apiURL, appURL, appPublicURL string, log logger.Logger) *Session
NewTestSession creates a static test session with hardcoded data. This is for use in test packages outside of internal/auth to avoid import cycles. This session does not make any network calls or start goroutines.
func (*Session) APIInfo ¶ added in v0.1.0
APIInfo returns the API key and API URL. API key comes from config, API URL comes from server response (or default). Always available - falls back to config/defaults if login not complete.
func (*Session) AppPublicURL ¶ added in v0.1.0
AppPublicURL returns the public app URL from config. Always available.
func (*Session) Login ¶
Login blocks until login completes or context is cancelled. Returns error if login failed.