Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tier: Add support of service principal to Azure #254

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/vulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ 1.21.4 ]
go-version: [ 1.21.5 ]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
24 changes: 24 additions & 0 deletions tier-azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ package madmin

//go:generate msgp -file $GOFILE

// ServicePrincipalAuth holds fields for a successful SP authentication with Azure
type ServicePrincipalAuth struct {
vadmeste marked this conversation as resolved.
Show resolved Hide resolved
TenantID string `json:",omitempty"`
ClientID string `json:",omitempty"`
ClientSecret string `json:",omitempty"`
}

// TierAzure represents the remote tier configuration for Azure Blob Storage.
type TierAzure struct {
Endpoint string `json:",omitempty"`
Expand All @@ -30,11 +37,28 @@ type TierAzure struct {
Prefix string `json:",omitempty"`
Region string `json:",omitempty"`
StorageClass string `json:",omitempty"`

SPAuth ServicePrincipalAuth `json:",omitempty"`
}

// IsSPEnabled returns true if some SP related fields are provided
func (ti TierAzure) IsSPEnabled() bool {
return ti.SPAuth.TenantID != "" || ti.SPAuth.ClientID != "" || ti.SPAuth.ClientSecret != ""
}

// AzureOptions supports NewTierAzure to take variadic options
type AzureOptions func(*TierAzure) error

// AzureServicePrincipal helper to supply optional service principal credentials
func AzureServicePrincipal(tenantID, clientID, clientSecret string) func(az *TierAzure) error {
return func(az *TierAzure) error {
az.SPAuth.TenantID = tenantID
az.SPAuth.ClientID = clientID
az.SPAuth.ClientSecret = clientSecret
return nil
}
}

// AzurePrefix helper to supply optional object prefix to NewTierAzure
func AzurePrefix(prefix string) func(az *TierAzure) error {
return func(az *TierAzure) error {
Expand Down
Loading
Loading