 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- func ConfigureEntraIDClientOptions(ctx context.Context, config *ProviderData, authorityURL string) (policy.ClientOptions, error)
- func ConfigureGraphClientOptions(ctx context.Context, config *ProviderData) (*http.Client, error)
- func ObtainCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
- func SetCloudConstants(cloud string) (string, string, string, string, error)
- func SetGraphBetaClientForDataSource(ctx context.Context, req datasource.ConfigureRequest, ...) *msgraphbetasdk.GraphServiceClient
- func SetGraphBetaClientForEphemeralResource(ctx context.Context, req ephemeral.ConfigureRequest, ...) *msgraphbetasdk.GraphServiceClient
- func SetGraphBetaClientForResource(ctx context.Context, req resource.ConfigureRequest, ...) *msgraphbetasdk.GraphServiceClient
- func SetGraphStableClientForDataSource(ctx context.Context, req datasource.ConfigureRequest, ...) *msgraphsdk.GraphServiceClient
- func SetGraphStableClientForResource(ctx context.Context, req resource.ConfigureRequest, ...) *msgraphsdk.GraphServiceClient
- type AuthenticatedHTTPClient
- func NewAuthenticatedHTTPClient(baseClient *http.Client, credential azcore.TokenCredential, ...) *AuthenticatedHTTPClient
- func SetGraphBetaHTTPClientForDataSource(ctx context.Context, req datasource.ConfigureRequest, ...) *AuthenticatedHTTPClient
- func SetGraphBetaHTTPClientForResource(ctx context.Context, req resource.ConfigureRequest, ...) *AuthenticatedHTTPClient
- func SetGraphV1HTTPClientForDataSource(ctx context.Context, req datasource.ConfigureRequest, ...) *AuthenticatedHTTPClient
- func SetGraphV1HTTPClientForResource(ctx context.Context, req resource.ConfigureRequest, ...) *AuthenticatedHTTPClient
 
- type AzureDevOpsOIDCStrategy
- type AzureDeveloperCLIStrategy
- type ClientCertificateStrategy
- type ClientOptions
- type ClientSecretStrategy
- type CredentialStrategy
- type DeviceCodeStrategy
- type EntraIDOptions
- type GitHubOIDCStrategy
- type GraphClientInterface
- type GraphClients
- type InteractiveBrowserStrategy
- type ManagedIdentityStrategy
- type MockAuthProvider
- type MockCredential
- type MockGraphClients
- func (m *MockGraphClients) GetGraphBetaClient() *AuthenticatedHTTPClient
- func (m *MockGraphClients) GetGraphV1Client() *AuthenticatedHTTPClient
- func (m *MockGraphClients) GetKiotaGraphBetaClient() *msgraphbetasdk.GraphServiceClient
- func (m *MockGraphClients) GetKiotaGraphV1Client() *msgraphsdk.GraphServiceClient
 
- type OIDCStrategy
- type ProviderData
- type WorkloadIdentityStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureEntraIDClientOptions ¶
func ConfigureEntraIDClientOptions(ctx context.Context, config *ProviderData, authorityURL string) (policy.ClientOptions, error)
ConfigureEntraIDClientOptions configures the Entra ID client options based on the provided configuration
func ConfigureGraphClientOptions ¶
ConfigureGraphClientOptions configures the Graph client options based on the provided configuration
func ObtainCredential ¶
func ObtainCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
ObtainCredential performs the necessary steps to obtain a TokenCredential based on the provider configuration. It uses the CredentialFactory and CredentialStrategy to create the appropriate credential type based on the authentication method defined within the provider configuraton.
func SetCloudConstants ¶
SetCloudConstants returns the OAuth authority URL, Graph API scope, and Graph API service root based on the provided cloud type.
func SetGraphBetaClientForDataSource ¶
func SetGraphBetaClientForDataSource(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, dataSourceName string) *msgraphbetasdk.GraphServiceClient
SetGraphBetaClientForDataSource is a helper function to retrieve and validate the Graph Beta client for data sources.
func SetGraphBetaClientForEphemeralResource ¶
func SetGraphBetaClientForEphemeralResource(ctx context.Context, req ephemeral.ConfigureRequest, resp *ephemeral.ConfigureResponse, ephemeralResourceName string) *msgraphbetasdk.GraphServiceClient
SetGraphBetaClientForEphemeralResource is a helper function to retrieve and validate the Graph Beta client for ephemeral resources.
func SetGraphBetaClientForResource ¶
func SetGraphBetaClientForResource(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse, resourceName string) *msgraphbetasdk.GraphServiceClient
SetGraphBetaClientForResource is a helper function to retrieve and validate the Graph Beta client for resources.
func SetGraphStableClientForDataSource ¶
func SetGraphStableClientForDataSource(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, dataSourceName string) *msgraphsdk.GraphServiceClient
SetGraphStableClientForDataSource is a helper function to retrieve and validate the Graph V1.0 client for data sources.
func SetGraphStableClientForResource ¶
func SetGraphStableClientForResource(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse, resourceName string) *msgraphsdk.GraphServiceClient
SetGraphStableClientForResource is a helper function to retrieve and validate the Graph V1.0 client for resources.
Types ¶
type AuthenticatedHTTPClient ¶
type AuthenticatedHTTPClient struct {
	// contains filtered or unexported fields
}
    AuthenticatedHTTPClient wraps an HTTP client with Microsoft Graph authentication
func NewAuthenticatedHTTPClient ¶
func NewAuthenticatedHTTPClient(baseClient *http.Client, credential azcore.TokenCredential, scope, baseURL string) *AuthenticatedHTTPClient
NewAuthenticatedHTTPClient creates a new HTTP client with authentication for Microsoft Graph
func SetGraphBetaHTTPClientForDataSource ¶
func SetGraphBetaHTTPClientForDataSource(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, dataSourceName string) *AuthenticatedHTTPClient
SetGraphBetaHTTPClientForDataSource is a helper function to retrieve and validate the Graph Beta HTTP client for data sources.
func SetGraphBetaHTTPClientForResource ¶
func SetGraphBetaHTTPClientForResource(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse, resourceName string) *AuthenticatedHTTPClient
SetGraphBetaHTTPClientForResource is a helper function to retrieve and validate the Graph Beta HTTP client for resources.
func SetGraphV1HTTPClientForDataSource ¶
func SetGraphV1HTTPClientForDataSource(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, dataSourceName string) *AuthenticatedHTTPClient
SetGraphV1HTTPClientForDataSource is a helper function to retrieve and validate the Graph V1.0 HTTP client for data sources.
func SetGraphV1HTTPClientForResource ¶
func SetGraphV1HTTPClientForResource(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse, resourceName string) *AuthenticatedHTTPClient
SetGraphV1HTTPClientForResource is a helper function to retrieve and validate the Graph V1.0 HTTP client for resources.
func (*AuthenticatedHTTPClient) GetBaseURL ¶
func (c *AuthenticatedHTTPClient) GetBaseURL() string
GetBaseURL returns the base URL for this client
func (*AuthenticatedHTTPClient) GetClient ¶
func (c *AuthenticatedHTTPClient) GetClient() *http.Client
GetClient returns the underlying HTTP client
type AzureDevOpsOIDCStrategy ¶
type AzureDevOpsOIDCStrategy struct{}
    AzureDevOpsOIDCStrategy implements the credential strategy for Azure DevOps OIDC authentication
func (*AzureDevOpsOIDCStrategy) GetCredential ¶
func (s *AzureDevOpsOIDCStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type AzureDeveloperCLIStrategy ¶
type AzureDeveloperCLIStrategy struct{}
    AzureDeveloperCLIStrategy implements the credential strategy for Azure Developer CLI authentication
func (*AzureDeveloperCLIStrategy) GetCredential ¶
func (s *AzureDeveloperCLIStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type ClientCertificateStrategy ¶
type ClientCertificateStrategy struct{}
    ClientCertificateStrategy implements the credential strategy for client certificate authentication
func (*ClientCertificateStrategy) GetCredential ¶
func (s *ClientCertificateStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type ClientOptions ¶
type ClientOptions struct {
	// EnableRetry indicates whether to enable retry
	EnableRetry bool
	// MaxRetries is the maximum number of retries
	MaxRetries int64
	// RetryDelaySeconds is the delay between retries in seconds
	RetryDelaySeconds int64
	// EnableRedirect indicates whether to enable redirect
	EnableRedirect bool
	// MaxRedirects is the maximum number of redirects
	MaxRedirects int64
	// EnableCompression indicates whether to enable compression
	EnableCompression bool
	// CustomUserAgent is the custom user agent
	CustomUserAgent string
	// EnableHeadersInspection indicates whether to enable headers inspection
	EnableHeadersInspection bool
	// TimeoutSeconds is the timeout in seconds
	TimeoutSeconds int64
	// UseProxy indicates whether to use a proxy
	UseProxy bool
	// ProxyURL is the proxy URL
	ProxyURL string
	// ProxyUsername is the proxy username
	ProxyUsername string
	// ProxyPassword is the proxy password
	ProxyPassword string
	// EnableChaos indicates whether to enable chaos
	EnableChaos bool
	// ChaosPercentage is the chaos percentage
	ChaosPercentage int64
	// ChaosStatusCode is the chaos status code
	ChaosStatusCode int64
	// ChaosStatusMessage is the chaos status message
	ChaosStatusMessage string
}
    ClientOptions represents the options for the Microsoft Graph client
type ClientSecretStrategy ¶
type ClientSecretStrategy struct{}
    ClientSecretStrategy implements the credential strategy for client secret authentication
func (*ClientSecretStrategy) GetCredential ¶
func (s *ClientSecretStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type CredentialStrategy ¶
type CredentialStrategy interface {
	GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
}
    CredentialStrategy defines the interface for credential creation strategies
type DeviceCodeStrategy ¶
type DeviceCodeStrategy struct{}
    DeviceCodeStrategy implements the credential strategy for device code authentication
func (*DeviceCodeStrategy) GetCredential ¶
func (s *DeviceCodeStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type EntraIDOptions ¶
type EntraIDOptions struct {
	// ClientID is the client ID (application ID) for the Entra ID application
	ClientID string
	// ClientSecret is the client secret for the Entra ID application
	ClientSecret string
	// ClientCertificate is the path to the client certificate file
	ClientCertificate string
	// ClientCertificatePassword is the password for the client certificate
	ClientCertificatePassword string
	// Username is the username for interactive authentication
	Username string
	// RedirectUrl is the redirect URL for interactive authentication
	RedirectUrl string
	// FederatedTokenFilePath is the path to the federated token file
	FederatedTokenFilePath string
	// ManagedIdentityClientID is the client ID for managed identity authentication
	ManagedIdentityClientID string
	// ManagedIdentityResourceID is the resource ID for managed identity authentication
	ManagedIdentityResourceID string
	// OIDCTokenFilePath is the path to the OIDC token file
	OIDCTokenFilePath string
	// OIDCToken is the OIDC token
	OIDCToken string
	// OIDCRequestToken is the OIDC request token
	OIDCRequestToken string
	// OIDCRequestURL is the OIDC request URL
	OIDCRequestURL string
	// DisableInstanceDiscovery indicates whether to disable instance discovery
	DisableInstanceDiscovery bool
	// SendCertificateChain indicates whether to send the certificate chain
	SendCertificateChain bool
	// AdditionallyAllowedTenants is a list of additionally allowed tenants
	AdditionallyAllowedTenants []string
}
    EntraIDOptions represents the options for Entra ID authentication
type GitHubOIDCStrategy ¶
type GitHubOIDCStrategy struct{}
    GitHubOIDCStrategy implements the credential strategy for GitHub OIDC authentication
func (*GitHubOIDCStrategy) GetCredential ¶
func (s *GitHubOIDCStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type GraphClientInterface ¶
type GraphClientInterface interface {
	GetKiotaGraphV1Client() *msgraphsdk.GraphServiceClient
	GetKiotaGraphBetaClient() *msgraphbetasdk.GraphServiceClient
	GetGraphV1Client() *AuthenticatedHTTPClient
	GetGraphBetaClient() *AuthenticatedHTTPClient
}
    GraphClientInterface defines the interface for GraphClients
func NewGraphClients ¶
func NewGraphClients(ctx context.Context, data *ProviderData, diags *diag.Diagnostics) GraphClientInterface
NewGraphClients sets up the Microsoft Graph clients with the given configuration. It processes the provider data, sets up authentication, and initializes the Microsoft Graph clients (stable and beta).
The function supports various authentication methods, proxy settings, and national cloud deployments. It performs the following main steps:
- Determines cloud-specific constants and endpoints.
- Configures the Entra ID client options.
- Obtains credentials based on the specified authentication method.
- Creates and configures the Microsoft Graph clients (stable and beta).
If any errors occur during these steps, appropriate diagnostics are added to the diagnostics collection.
type GraphClients ¶
type GraphClients struct {
	KiotaGraphV1Client   *msgraphsdk.GraphServiceClient
	KiotaGraphBetaClient *msgraphbetasdk.GraphServiceClient
	GraphV1Client        *AuthenticatedHTTPClient
	GraphBetaClient      *AuthenticatedHTTPClient
}
    func (*GraphClients) GetGraphBetaClient ¶
func (g *GraphClients) GetGraphBetaClient() *AuthenticatedHTTPClient
GetGraphBetaClient returns the Beta HTTP client for raw JSON calls
func (*GraphClients) GetGraphV1Client ¶
func (g *GraphClients) GetGraphV1Client() *AuthenticatedHTTPClient
GetGraphV1Client returns the V1 HTTP client for raw JSON calls
func (*GraphClients) GetKiotaGraphBetaClient ¶
func (g *GraphClients) GetKiotaGraphBetaClient() *msgraphbetasdk.GraphServiceClient
GetKiotaGraphBetaClient returns the beta client
func (*GraphClients) GetKiotaGraphV1Client ¶
func (g *GraphClients) GetKiotaGraphV1Client() *msgraphsdk.GraphServiceClient
GetStableClient returns the stable client
type InteractiveBrowserStrategy ¶
type InteractiveBrowserStrategy struct{}
    InteractiveBrowserStrategy implements the credential strategy for interactive browser authentication
func (*InteractiveBrowserStrategy) GetCredential ¶
func (s *InteractiveBrowserStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type ManagedIdentityStrategy ¶
type ManagedIdentityStrategy struct{}
    ManagedIdentityStrategy implements the credential strategy for managed identity authentication
func (*ManagedIdentityStrategy) GetCredential ¶
func (s *ManagedIdentityStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type MockAuthProvider ¶
type MockAuthProvider struct{}
    MockAuthProvider implements the required authentication interface for testing
func (*MockAuthProvider) AuthenticateRequest ¶
func (m *MockAuthProvider) AuthenticateRequest(ctx context.Context, request *abstractions.RequestInformation, additionalAuthenticationContext map[string]any) error
AuthenticateRequest adds a mock authorization header to requests
type MockCredential ¶
type MockCredential struct{}
    MockCredential implements azcore.TokenCredential for testing
func (*MockCredential) GetToken ¶
func (m *MockCredential) GetToken(ctx context.Context, options policy.TokenRequestOptions) (azcore.AccessToken, error)
GetToken returns a mock access token
type MockGraphClients ¶
type MockGraphClients struct {
	MockV1Client       *msgraphsdk.GraphServiceClient
	MockBetaClient     *msgraphbetasdk.GraphServiceClient
	MockV1HTTPClient   *AuthenticatedHTTPClient
	MockBetaHTTPClient *AuthenticatedHTTPClient
}
    MockGraphClients is a mock implementation of GraphClientInterface for testing
func NewMockGraphClients ¶
func NewMockGraphClients(httpClient *http.Client) *MockGraphClients
NewMockGraphClients creates a new instance of MockGraphClients with initialized mock clients
func (*MockGraphClients) GetGraphBetaClient ¶
func (m *MockGraphClients) GetGraphBetaClient() *AuthenticatedHTTPClient
GetGraphBetaClient returns the mock Beta HTTP client
func (*MockGraphClients) GetGraphV1Client ¶
func (m *MockGraphClients) GetGraphV1Client() *AuthenticatedHTTPClient
GetGraphV1Client returns the mock V1 HTTP client
func (*MockGraphClients) GetKiotaGraphBetaClient ¶
func (m *MockGraphClients) GetKiotaGraphBetaClient() *msgraphbetasdk.GraphServiceClient
GetKiotaGraphBetaClient returns the mock Beta client
func (*MockGraphClients) GetKiotaGraphV1Client ¶
func (m *MockGraphClients) GetKiotaGraphV1Client() *msgraphsdk.GraphServiceClient
GetKiotaGraphV1Client returns the mock V1 client
type OIDCStrategy ¶
type OIDCStrategy struct{}
    OIDCStrategy implements the credential strategy for OIDC authentication
func (*OIDCStrategy) GetCredential ¶
func (s *OIDCStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)
type ProviderData ¶
type ProviderData struct {
	// Cloud is the Microsoft cloud environment to use (public, dod, gcc, gcchigh, china, etc.)
	Cloud string
	// TenantID is the Microsoft 365 tenant ID
	TenantID string
	// AuthMethod is the authentication method to use (client_secret, client_certificate, etc.)
	AuthMethod string
	// EntraIDOptions contains options for Entra ID authentication
	EntraIDOptions *EntraIDOptions
	// ClientOptions contains options for the Microsoft Graph client
	ClientOptions *ClientOptions
	// TelemetryOptout indicates whether to opt out of telemetry
	TelemetryOptout bool
	// DebugMode indicates whether debug mode is enabled
	DebugMode bool
}
    ProviderData represents the data needed to configure the Microsoft Graph clients. This is a simplified version of the provider model that only includes the fields needed for client configuration.
func (*ProviderData) GetClientOptions ¶
func (d *ProviderData) GetClientOptions() policy.ClientOptions
GetClientOptions returns the Azure SDK client options based on the provider data
type WorkloadIdentityStrategy ¶
type WorkloadIdentityStrategy struct{}
    WorkloadIdentityStrategy implements the credential strategy for workload identity authentication
func (*WorkloadIdentityStrategy) GetCredential ¶
func (s *WorkloadIdentityStrategy) GetCredential(ctx context.Context, config *ProviderData, clientOptions policy.ClientOptions) (azcore.TokenCredential, error)