ntlm isn't special
This commit is contained in:
parent
d5622de173
commit
ac9219c61c
@ -246,13 +246,8 @@ func Batch(objects []*objectResource, operation string) ([]*objectResource, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if IsAuthError(err) {
|
if IsAuthError(err) {
|
||||||
if isNtlmRequest(res) {
|
setAuthType(res)
|
||||||
toggleAuthType("ntlm")
|
|
||||||
return Batch(objects, operation)
|
return Batch(objects, operation)
|
||||||
} else {
|
|
||||||
toggleAuthType("basic")
|
|
||||||
return Batch(objects, operation)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch res.StatusCode {
|
switch res.StatusCode {
|
||||||
@ -309,13 +304,8 @@ func UploadCheck(oidPath string) (*objectResource, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if IsAuthError(err) {
|
if IsAuthError(err) {
|
||||||
if isNtlmRequest(res) {
|
setAuthType(res)
|
||||||
toggleAuthType("ntlm")
|
|
||||||
return UploadCheck(oidPath)
|
return UploadCheck(oidPath)
|
||||||
} else {
|
|
||||||
toggleAuthType("basic")
|
|
||||||
return UploadCheck(oidPath)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, newRetriableError(err)
|
return nil, newRetriableError(err)
|
||||||
@ -508,8 +498,8 @@ func doHttpRequest(req *http.Request, creds Creds) (*http.Response, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if IsAuthError(err) && isNtlmRequest(res) {
|
if IsAuthError(err) {
|
||||||
toggleAuthType("ntlm")
|
setAuthType(res)
|
||||||
doHttpRequest(req, creds)
|
doHttpRequest(req, creds)
|
||||||
} else {
|
} else {
|
||||||
err = Error(err)
|
err = Error(err)
|
||||||
@ -758,16 +748,25 @@ func setRequestAuthFromUrl(req *http.Request, u *url.URL) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isNtlmRequest(res *http.Response) bool {
|
func setAuthType(res *http.Response) {
|
||||||
header := res.Header.Get("Www-Authenticate")
|
authType := getAuthType(res)
|
||||||
return strings.HasPrefix(strings.ToLower(header), "ntlm")
|
|
||||||
}
|
|
||||||
|
|
||||||
func toggleAuthType(authType string) {
|
|
||||||
Config.SetAccess(authType)
|
Config.SetAccess(authType)
|
||||||
tracerx.Printf("api: http response indicates %q authentication. Resubmitting...", authType)
|
tracerx.Printf("api: http response indicates %q authentication. Resubmitting...", authType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getAuthType(res *http.Response) string {
|
||||||
|
auth := res.Header.Get("Www-Authenticate")
|
||||||
|
if len(auth) < 1 {
|
||||||
|
auth = res.Header.Get("Lfs-Authenticate")
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(strings.ToLower(auth), "ntlm") {
|
||||||
|
return "ntlm"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "basic"
|
||||||
|
}
|
||||||
|
|
||||||
func setRequestAuth(req *http.Request, user, pass string) {
|
func setRequestAuth(req *http.Request, user, pass string) {
|
||||||
if Config.NtlmAccess() {
|
if Config.NtlmAccess() {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user