azure

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// 499b84ac-1321-427f-aa17-267ca6975798 is the UUID of Azure Devops
	// resource. The scope defined below provides access to Azure DevOps
	// Services REST API. The Microsoft Entra ID access token with this scope
	// can be used to call Azure DevOps API by passing it in the headers as a
	// Bearer Token : https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/service-principal-managed-identity?view=azure-devops#q-can-i-use-a-service-principal-or-managed-identity-with-azure-cli
	AzureDevOpsRestApiScope = "499b84ac-1321-427f-aa17-267ca6975798/.default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an authentication provider for Azure.

func New

func New(opts ...OptFunc) (*Client, error)

New returns a new authentication provider for Azure. It configures credentials using a default credential chain with options. https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity#NewDefaultAzureCredential The default scope is to ARM endpoint in Azure Cloud. The scope is overridden using OptFunc.

func (*Client) GetToken

func (p *Client) GetToken(ctx context.Context) (azcore.AccessToken, error)

GetToken gets an OAuth token using azcore TokenCredential

type FakeTokenCredential

type FakeTokenCredential struct {
	Token string

	ExpiresOn time.Time
	Err       error
}

FakeTokenCredential is a fake Azure credential provider.

func (*FakeTokenCredential) GetToken

type OptFunc

type OptFunc func(*Client)

OptFunc enables specifying options for the provider.

func WithAzureDevOpsScope

func WithAzureDevOpsScope() OptFunc

WithAzureDevOpsScope() configures the scope to access Azure DevOps Rest API needed to access Azure DevOps Repositories

func WithCredential

func WithCredential(cred azcore.TokenCredential) OptFunc

WithCredential configures the credential to use to fetch the resource manager token.

func WithProxyURL

func WithProxyURL(proxyURL *url.URL) OptFunc

WithProxyURL sets the proxy URL to use with NewDefaultAzureCredential.

func WithScope

func WithScope(scopes []string) OptFunc

WithScope() configures the scope for GetToken requests

Jump to

Keyboard shortcuts

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