Skip to content

Commit

Permalink
Support kerberos client
Browse files Browse the repository at this point in the history
  • Loading branch information
RobiNino committed Oct 1, 2024
1 parent d6a1c83 commit 89f7c8f
Show file tree
Hide file tree
Showing 17 changed files with 161 additions and 27 deletions.
1 change: 1 addition & 0 deletions access/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func New(config config.Config) (*AccessServicesManager, error) {
SetOverallRequestTimeout(config.GetOverallRequestTimeout()).
SetRetries(config.GetHttpRetries()).
SetRetryWaitMilliSecs(config.GetHttpRetryWaitMilliSecs()).
SetKerberosDetails(config.GetKerberosDetails()).
Build()

return manager, err
Expand Down
4 changes: 2 additions & 2 deletions artifactory/manager.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package artifactory

import (
"io"

"github.com/jfrog/jfrog-client-go/auth"
"io"

buildinfo "github.com/jfrog/build-info-go/entities"

Expand Down Expand Up @@ -618,5 +617,6 @@ func buildJFrogHttpClient(config config.Config, authDetails auth.ServiceDetails)
SetRetries(config.GetHttpRetries()).
SetRetryWaitMilliSecs(config.GetHttpRetryWaitMilliSecs()).
SetHttpClient(config.GetHttpClient()).
SetKerberosDetails(config.GetKerberosDetails()).
Build()
}
46 changes: 29 additions & 17 deletions auth/servicedetails.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package auth

import (
"github.com/jfrog/jfrog-client-go/http/httpclient"
"sync"
"time"

Expand Down Expand Up @@ -31,6 +32,7 @@ type ServiceDetails interface {
GetSshAuthHeaders() map[string]string
GetClient() *jfroghttpclient.JfrogHttpClient
GetVersion() (string, error)
GetKerberosDetails() httpclient.KerberosDetails

SetUrl(url string)
SetUser(user string)
Expand All @@ -47,6 +49,7 @@ type ServiceDetails interface {
SetClient(client *jfroghttpclient.JfrogHttpClient)
SetDialTimeout(dialTimeout time.Duration)
SetOverallRequestTimeout(overallRequestTimeout time.Duration)
SetKerberosDetails(kerberosDetails httpclient.KerberosDetails)

IsSshAuthHeaderSet() bool
IsSshAuthentication() bool
Expand All @@ -58,23 +61,24 @@ type ServiceDetails interface {
}

type CommonConfigFields struct {
Url string `json:"-"`
User string `json:"-"`
Password string `json:"-"`
ApiKey string `json:"-"`
AccessToken string `json:"-"`
PreRequestInterceptors []ServiceDetailsPreRequestFunc `json:"-"`
ClientCertPath string `json:"-"`
ClientCertKeyPath string `json:"-"`
Version string `json:"-"`
SshUrl string `json:"-"`
SshKeyPath string `json:"-"`
SshPassphrase string `json:"-"`
SshAuthHeaders map[string]string `json:"-"`
TokenMutex sync.Mutex
client *jfroghttpclient.JfrogHttpClient
dialTimeout time.Duration
overallRequestTimeout time.Duration
Url string `json:"-"`
User string `json:"-"`
Password string `json:"-"`
ApiKey string `json:"-"`
AccessToken string `json:"-"`
PreRequestInterceptors []ServiceDetailsPreRequestFunc `json:"-"`
ClientCertPath string `json:"-"`
ClientCertKeyPath string `json:"-"`
Version string `json:"-"`
SshUrl string `json:"-"`
SshKeyPath string `json:"-"`
SshPassphrase string `json:"-"`
SshAuthHeaders map[string]string `json:"-"`
httpclient.KerberosDetails `json:"-"`
TokenMutex sync.Mutex
client *jfroghttpclient.JfrogHttpClient
dialTimeout time.Duration
overallRequestTimeout time.Duration
}

func (ccf *CommonConfigFields) GetUrl() string {
Expand Down Expand Up @@ -129,6 +133,10 @@ func (ccf *CommonConfigFields) GetClient() *jfroghttpclient.JfrogHttpClient {
return ccf.client
}

func (ccf *CommonConfigFields) GetKerberosDetails() httpclient.KerberosDetails {
return ccf.KerberosDetails
}

func (ccf *CommonConfigFields) SetUrl(url string) {
ccf.Url = utils.AddTrailingSlashIfNeeded(url)
}
Expand Down Expand Up @@ -189,6 +197,10 @@ func (ccf *CommonConfigFields) SetOverallRequestTimeout(overallRequestTimeout ti
ccf.overallRequestTimeout = overallRequestTimeout
}

func (ccf *CommonConfigFields) SetKerberosDetails(kerberosDetails httpclient.KerberosDetails) {
ccf.KerberosDetails = kerberosDetails
}

func (ccf *CommonConfigFields) IsSshAuthHeaderSet() bool {
return len(ccf.SshAuthHeaders) > 0
}
Expand Down
7 changes: 7 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"context"
"github.com/jfrog/jfrog-client-go/http/httpclient"
"net/http"
"time"

Expand All @@ -22,6 +23,7 @@ type Config interface {
GetHttpRetries() int
GetHttpRetryWaitMilliSecs() int
GetHttpClient() *http.Client
GetKerberosDetails() httpclient.KerberosDetails
}

type servicesConfig struct {
Expand All @@ -37,6 +39,7 @@ type servicesConfig struct {
httpRetries int
httpRetryWaitMilliSecs int
httpClient *http.Client
kerberosDetails httpclient.KerberosDetails
}

func (config *servicesConfig) IsDryRun() bool {
Expand Down Expand Up @@ -86,3 +89,7 @@ func (config *servicesConfig) GetHttpRetryWaitMilliSecs() int {
func (config *servicesConfig) GetHttpClient() *http.Client {
return config.httpClient
}

func (config *servicesConfig) GetKerberosDetails() httpclient.KerberosDetails {
return config.kerberosDetails
}
7 changes: 7 additions & 0 deletions config/configbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type servicesConfigBuilder struct {
httpRetries int
httpRetryWaitMilliSecs int
httpClient *http.Client
kerberosDetails httpclient.KerberosDetails
}

func (builder *servicesConfigBuilder) SetServiceDetails(artDetails auth.ServiceDetails) *servicesConfigBuilder {
Expand Down Expand Up @@ -87,6 +88,11 @@ func (builder *servicesConfigBuilder) SetHttpClient(httpClient *http.Client) *se
return builder
}

func (builder *servicesConfigBuilder) SetKerberosDetails(kerberosDetails httpclient.KerberosDetails) *servicesConfigBuilder {
builder.kerberosDetails = kerberosDetails
return builder
}

func (builder *servicesConfigBuilder) Build() (Config, error) {
c := &servicesConfig{}
c.ServiceDetails = builder.ServiceDetails
Expand All @@ -100,5 +106,6 @@ func (builder *servicesConfigBuilder) Build() (Config, error) {
c.httpRetries = builder.httpRetries
c.httpRetryWaitMilliSecs = builder.httpRetryWaitMilliSecs
c.httpClient = builder.httpClient
c.kerberosDetails = builder.kerberosDetails
return c, nil
}
1 change: 1 addition & 0 deletions distribution/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func New(config config.Config) (*DistributionServicesManager, error) {
SetContext(config.GetContext()).
SetRetries(config.GetHttpRetries()).
SetRetryWaitMilliSecs(config.GetHttpRetryWaitMilliSecs()).
SetKerberosDetails(config.GetKerberosDetails()).
Build()
return manager, err
}
Expand Down
1 change: 1 addition & 0 deletions evidence/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func New(config config.Config) (*EvidenceServicesManager, error) {
SetOverallRequestTimeout(config.GetOverallRequestTimeout()).
SetRetries(config.GetHttpRetries()).
SetRetryWaitMilliSecs(config.GetHttpRetryWaitMilliSecs()).
SetKerberosDetails(config.GetKerberosDetails()).
Build()

return manager, err
Expand Down
9 changes: 8 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/go-git/go-git/v5 v5.12.0
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/gookit/color v1.5.4
github.com/jcmturner/gokrb5/v8 v8.4.4
github.com/jfrog/archiver/v3 v3.6.1
github.com/jfrog/build-info-go v1.10.1
github.com/jfrog/gofrog v1.7.6
Expand All @@ -34,7 +35,13 @@ require (
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/goidentity/v6 v6.0.1 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
Expand All @@ -58,6 +65,6 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20240909072259-13bf8722d051
replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20240930223505-7bd47c2713e2

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.7.6-0.20240909061051-2d36ae4bd05a
32 changes: 30 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,31 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg=
github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo=
github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o=
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8=
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI=
github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw=
github.com/jfrog/build-info-go v1.10.1 h1:5nLrpFjbV2zuBdmJXW2nybAz5vyu+qDkOtR7v0ehi8s=
github.com/jfrog/build-info-go v1.10.1/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
github.com/jfrog/build-info-go v1.8.9-0.20240930223505-7bd47c2713e2 h1:SzlXWJ9u/M/2BVC0q7PsZgDrAeEpMNS1pVoWyayVWfU=
github.com/jfrog/build-info-go v1.8.9-0.20240930223505-7bd47c2713e2/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down Expand Up @@ -104,8 +123,13 @@ github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo=
Expand All @@ -130,6 +154,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
Expand All @@ -140,11 +165,13 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
Expand Down Expand Up @@ -200,5 +227,6 @@ gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 12 additions & 2 deletions http/httpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package httpclient
import (
"bytes"
"context"
krb5Client "github.com/jcmturner/gokrb5/v8/client"
"github.com/jcmturner/gokrb5/v8/spnego"
"github.com/minio/sha256-simd"
"strings"
//#nosec G505 -- sha1 is supported by Artifactory.
Expand Down Expand Up @@ -31,6 +33,7 @@ type HttpClient struct {
ctx context.Context
retries int
retryWaitMilliSecs int
kerberosClient *krb5Client.Client
}

const (
Expand Down Expand Up @@ -190,7 +193,7 @@ func (jc *HttpClient) doRequest(req *http.Request, content []byte, followRedirec
}
}

resp, err = client.Do(req)
resp, err = doWithCustomClient(req, client, jc.kerberosClient)
if err != nil && redirectUrl != "" {
if !followRedirect {
log.Debug("Blocking HTTP redirect to", redirectUrl)
Expand Down Expand Up @@ -339,7 +342,7 @@ func (jc *HttpClient) UploadFileFromReader(reader io.Reader, url string, httpCli
addUserAgentHeader(req)

client := jc.client
resp, err = client.Do(req)
resp, err = doWithCustomClient(req, client, jc.kerberosClient)
if errorutils.CheckError(err) != nil || resp == nil {
return
}
Expand Down Expand Up @@ -836,6 +839,13 @@ func addUserAgentHeader(req *http.Request) {
req.Header.Set("User-Agent", utils.GetUserAgent())
}

func doWithCustomClient(req *http.Request, httpClient *http.Client, kerberosClient *krb5Client.Client) (*http.Response, error) {
if kerberosClient != nil {
return spnego.NewClient(kerberosClient, httpClient, "").Do(req)
}
return httpClient.Do(req)
}

type DownloadFileDetails struct {
FileName string `json:"FileName,omitempty"`
DownloadPath string `json:"DownloadPath,omitempty"`
Expand Down
Loading

0 comments on commit 89f7c8f

Please sign in to comment.