auth

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetCachedToken added in v0.3.1

func SetCachedToken(s *TokenSource, token Token)

SetCachedToken seeds a TokenSource with a pre-baked Token. Tests use it to bypass the OAuth2 round trip when only the downstream API matters.

Types

type Cloud

type Cloud string
const (
	CloudPublic  Cloud = "public"
	CloudChina   Cloud = "china"
	CloudUSGov   Cloud = "usgov"
	CloudGermany Cloud = "germany"
)

func (Cloud) ActiveDirectoryEndpoint

func (c Cloud) ActiveDirectoryEndpoint() string

func (Cloud) MicrosoftGraphEndpoint added in v0.3.1

func (c Cloud) MicrosoftGraphEndpoint() string

MicrosoftGraphEndpoint returns the Microsoft Graph resource URL used as the OAuth2 scope and base URL for Microsoft Graph requests in the given cloud.

func (Cloud) ResourceManagerEndpoint

func (c Cloud) ResourceManagerEndpoint() string

type Credential

type Credential struct {
	ClientID       string
	ClientSecret   string
	TenantID       string
	SubscriptionID string
	Cloud          Cloud
}

Credential is the provider-local Azure credential shape used by the lightweight ARM client. SubscriptionID is optional; when empty the provider enumerates all visible subscriptions first.

func FromOptions

func FromOptions(options schema.Options) (Credential, error)

func New

func New(clientID, clientSecret, tenantID, subscriptionID string, cloud Cloud) Credential

func (Credential) Validate

func (c Credential) Validate() error

type Token

type Token struct {
	AccessToken string
	ExpiresAt   time.Time
}

Token is a cached bearer token.

type TokenSource

type TokenSource struct {
	// contains filtered or unexported fields
}

TokenSource fetches and caches OAuth2 client credentials tokens.

func NewTokenSource

func NewTokenSource(cred Credential, httpClient *http.Client) *TokenSource

NewTokenSource returns a TokenSource bound to the ARM resource scope of the credential's cloud.

func NewTokenSourceForScope added in v0.3.1

func NewTokenSourceForScope(cred Credential, httpClient *http.Client, scope string) *TokenSource

NewTokenSourceForScope returns a TokenSource that mints tokens for an explicit OAuth2 scope (e.g. Microsoft Graph). Use the resource-suffixed `.default` form (e.g. "https://graph.microsoft.com/.default").

func (*TokenSource) Token

func (s *TokenSource) Token(ctx context.Context) (Token, error)

Jump to

Keyboard shortcuts

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