auth

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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 Expirer

type Expirer interface {
	ExpiresAt() time.Time
}

Expirer is implemented by auth providers that expose token expiry information.

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

func (*OAuth2Provider) Refresh

func (p *OAuth2Provider) 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.

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

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

type Refresher interface {
	Refresh(ctx context.Context) (string, error)
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL