Documentation
¶
Index ¶
- func ClearCookieCache(baseURL, clientID string)
- func ClearTokenCache(baseURL, clientID string)
- type Expirer
- type OAuth2Provider
- type PlatformOAuth2Provider
- func (p *PlatformOAuth2Provider) ClientID() string
- func (p *PlatformOAuth2Provider) ClientSecret() string
- func (p *PlatformOAuth2Provider) ExpiresAt() time.Time
- func (p *PlatformOAuth2Provider) GetToken(ctx context.Context) (string, error)
- func (p *PlatformOAuth2Provider) Jar() http.CookieJar
- func (p *PlatformOAuth2Provider) Name() string
- func (p *PlatformOAuth2Provider) Refresh(ctx context.Context) (string, error)
- func (p *PlatformOAuth2Provider) TenantID() string
- type Provider
- type Refresher
- type TokenProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearCookieCache ¶
func ClearCookieCache(baseURL, clientID string)
ClearCookieCache removes the on-disk cookie cache file for the given URL and client ID. Called alongside ClearTokenCache after credential changes.
func ClearTokenCache ¶
func ClearTokenCache(baseURL, clientID string)
ClearTokenCache removes the on-disk token cache file for the given URL and client ID. Called by setup commands after credential changes to prevent stale cached tokens from being used. Errors are silently ignored.
Types ¶
type OAuth2Provider ¶
type OAuth2Provider struct {
// contains filtered or unexported fields
}
OAuth2Provider uses client credentials flow to obtain and cache tokens. It proactively refreshes the token before expiry and persists tokens to a temp file so repeated CLI invocations skip redundant token exchanges.
func NewOAuth2Provider ¶
func NewOAuth2Provider(baseURL, clientID, clientSecret string) *OAuth2Provider
func (*OAuth2Provider) ExpiresAt ¶
func (p *OAuth2Provider) ExpiresAt() time.Time
ExpiresAt returns the expiry time of the last fetched token. Returns zero if GetToken has not yet been called successfully.
func (*OAuth2Provider) GetToken ¶
func (p *OAuth2Provider) GetToken(ctx context.Context) (string, error)
func (*OAuth2Provider) Jar ¶
func (p *OAuth2Provider) Jar() http.CookieJar
Jar returns the cookie jar used by this provider's HTTP client. Sharing this jar with the API client enables sticky session affinity cookies (e.g. APBALANCEID on Jamf Cloud) to persist across requests.
func (*OAuth2Provider) Name ¶
func (p *OAuth2Provider) Name() string
type PlatformOAuth2Provider ¶
type PlatformOAuth2Provider struct {
// contains filtered or unexported fields
}
PlatformOAuth2Provider uses the Jamf Platform Gateway for authentication. Instead of authenticating directly against a Jamf Pro instance, it obtains tokens from a regional platform gateway (e.g., https://us.api.platform.jamf.com) and routes all API requests through that gateway using tenant-scoped URL paths.
func NewPlatformOAuth2Provider ¶
func NewPlatformOAuth2Provider(baseURL, clientID, clientSecret, tenantID string) *PlatformOAuth2Provider
func (*PlatformOAuth2Provider) ClientID ¶
func (p *PlatformOAuth2Provider) ClientID() string
ClientID returns the OAuth2 client ID. Used to construct SDK clients that manage their own token lifecycle (e.g., the Jamf Platform SDK).
func (*PlatformOAuth2Provider) ClientSecret ¶
func (p *PlatformOAuth2Provider) ClientSecret() string
ClientSecret returns the OAuth2 client secret. Used to construct SDK clients that manage their own token lifecycle (e.g., the Jamf Platform SDK).
func (*PlatformOAuth2Provider) ExpiresAt ¶
func (p *PlatformOAuth2Provider) ExpiresAt() time.Time
ExpiresAt returns the expiry time of the last fetched token. Returns zero if GetToken has not yet been called successfully.
func (*PlatformOAuth2Provider) GetToken ¶
func (p *PlatformOAuth2Provider) GetToken(ctx context.Context) (string, error)
func (*PlatformOAuth2Provider) Jar ¶
func (p *PlatformOAuth2Provider) Jar() http.CookieJar
Jar returns the cookie jar used by this provider's HTTP client. Sharing this jar with the API client enables sticky session affinity cookies (e.g. APBALANCEID on Jamf Cloud) to persist across requests.
func (*PlatformOAuth2Provider) Name ¶
func (p *PlatformOAuth2Provider) Name() string
func (*PlatformOAuth2Provider) Refresh ¶
func (p *PlatformOAuth2Provider) Refresh(ctx context.Context) (string, error)
Refresh clears the in-memory and disk token caches and exchanges credentials for a new token. Implements auth.Refresher.
func (*PlatformOAuth2Provider) TenantID ¶
func (p *PlatformOAuth2Provider) TenantID() string
TenantID returns the tenant identifier used for gateway URL path rewriting.
type Provider ¶
type Provider interface {
// GetToken returns a valid authentication token
GetToken(ctx context.Context) (string, error)
// Name returns the provider name for logging
Name() string
}
Provider defines the interface for authentication providers
type Refresher ¶
Refresher is implemented by auth providers that support forced token refresh. Calling Refresh clears any cached state (in-memory and on-disk) and exchanges credentials for a brand-new token.
type TokenProvider ¶
type TokenProvider struct {
// contains filtered or unexported fields
}
TokenProvider uses a pre-existing bearer token
func NewTokenProvider ¶
func NewTokenProvider(token string) *TokenProvider
func (*TokenProvider) GetToken ¶
func (p *TokenProvider) GetToken(ctx context.Context) (string, error)
func (*TokenProvider) Name ¶
func (p *TokenProvider) Name() string