本文整理匯總了Golang中github.com/github/git-lfs/config.Configuration.NtlmAccess方法的典型用法代碼示例。如果您正苦於以下問題:Golang Configuration.NtlmAccess方法的具體用法?Golang Configuration.NtlmAccess怎麽用?Golang Configuration.NtlmAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/github/git-lfs/config.Configuration
的用法示例。
在下文中一共展示了Configuration.NtlmAccess方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setRequestAuthFromUrl
func setRequestAuthFromUrl(cfg *config.Configuration, req *http.Request, u *url.URL) bool {
if !cfg.NtlmAccess(GetOperationForRequest(req)) && u.User != nil {
if pass, ok := u.User.Password(); ok {
fmt.Fprintln(os.Stderr, "warning: current Git remote contains credentials")
setRequestAuth(cfg, req, u.User.Username(), pass)
return true
}
}
return false
}
示例2: skipCredsCheck
func skipCredsCheck(cfg *config.Configuration, req *http.Request) bool {
if cfg.NtlmAccess(GetOperationForRequest(req)) {
return false
}
if len(req.Header.Get("Authorization")) > 0 {
return true
}
q := req.URL.Query()
return len(q["token"]) > 0
}
示例3: setRequestAuth
func setRequestAuth(cfg *config.Configuration, req *http.Request, user, pass string) {
if cfg.NtlmAccess(GetOperationForRequest(req)) {
return
}
if len(user) == 0 && len(pass) == 0 {
return
}
token := fmt.Sprintf("%s:%s", user, pass)
auth := "Basic " + strings.TrimSpace(base64.StdEncoding.EncodeToString([]byte(token)))
req.Header.Set("Authorization", auth)
}
示例4: doHttpRequest
// Internal http request management
func doHttpRequest(cfg *config.Configuration, req *http.Request, creds auth.Creds) (*http.Response, error) {
var (
res *http.Response
cause string
err error
)
if cfg.NtlmAccess(auth.GetOperationForRequest(req)) {
cause = "ntlm"
res, err = doNTLMRequest(cfg, req, true)
} else {
cause = "http"
res, err = NewHttpClient(cfg, req.Host).Do(req)
}
if res == nil {
res = &http.Response{
StatusCode: 0,
Header: make(http.Header),
Request: req,
Body: ioutil.NopCloser(bytes.NewBufferString("")),
}
}
if err != nil {
if errors.IsAuthError(err) {
SetAuthType(cfg, req, res)
doHttpRequest(cfg, req, creds)
} else {
err = errors.Wrap(err, cause)
}
} else {
err = handleResponse(cfg, res, creds)
}
if err != nil {
if res != nil {
SetErrorResponseContext(cfg, err, res)
} else {
setErrorRequestContext(cfg, err, req)
}
}
return res, err
}