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 Info ¶
type Info struct {
LoginToken string
OrgID string
OrgName string
APIKey string
APIURL string
ProxyURL string
AppURL string
AppPublicURL string
LoggedIn bool
}
Info holds authentication information
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
}
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.
func NewTestSession ¶
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) Endpoints ¶
Endpoints returns the API credentials and URLs. If login has completed, returns values from Info (which may be updated by the server). Otherwise, falls back to the original Options. This is always available immediately, no blocking required.
func (*Session) Info ¶
Info returns current auth info (non-blocking). Returns (ok=true, info) if login succeeded. Returns (ok=false, nil) if login is in progress or failed.