Debian Codegraph @

lfsapi/auth.go

raw symbols SCIP
1 package lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/
2
3 import (
4 "encoding/base64scip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/"
5 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
6 "net/httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/"
7 "net/urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/"
8 "osscip-go gomod github.com/golang/go/src go1.25.0 os/"
9 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
10
11 "github.com/git-lfs/git-lfs/v3/credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/"
12 "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/"
13 "github.com/git-lfs/git-lfs/v3/lfshttpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/"
14 "github.com/git-lfs/git-lfs/v3/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/"
15 "github.com/rubyist/tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/"
16 )
17
18 var (
19 defaultEndpointFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/defaultEndpointFinder. = NewEndpointFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewEndpointFinder().(nil)
20 defaultMaxAuthAttemptsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/defaultMaxAuthAttempts. = 3
21 )
22
23 // DoWithAuth sends an HTTP request to get an HTTP response. It attempts to add
24 // authentication from netrc or git's credential helpers if necessary,
25 // supporting basic authentication.
26 func (c *Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#) DoWithAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#DoWithAuth().(remote string, access credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.Accessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) (*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#, error) {
27 maxAuthAttempts := defaultMaxAuthAttemptsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/defaultMaxAuthAttempts.
28 if access.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().() == credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.NoneAccessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NoneAccess. {
29 maxAuthAttempts++
30 }
31
32 for i := range maxAuthAttempts {
33 res, err := c.doWithAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#doWithAuth().(remote, access, req, nil)
34 if err == nil || !errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsAuthErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsAuthError().(err) {
35 return res, err
36 }
37
38 // We expect this condition should occur only when an
39 // Authorization header was already set for the request
40 // and the request was rejected. Otherwise, after a 401
41 // status code is received, doWithAuth() will remove any
42 // Authorization header that it added to the request.
43 if len(req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Get().("Authorization")) != 0 {
44 return res, err
45 }
46
47 // This case represents a rejected request that
48 // should have been authenticated but wasn't, possibly because
49 // it is part of a multi-stage authentication sequence.
50 if res != nil && res.Bodyscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Body. != nil {
51 res.Bodyscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Body..Closescip-go gomod github.com/golang/go/src go1.25.0 io/Closer#Close().()
52 }
53
54 // If at least one more attempt is still permitted, we update
55 // the access mode and retry the request.
56 if i < maxAuthAttempts-1 {
57 access = c.Endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Endpoints..AccessForscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#AccessFor.(access.URLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#URL().())
58 tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("api: http response indicates %q authentication. Resubmitting...", access.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().())
59 }
60 }
61
62 c.credContextscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#credContext..SetStateFieldsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperContext#SetStateFields().(nil)
63
64 tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("api: too many authentication attempts")
65 return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("too many authentication attempts")
66 }
67
68 // DoWithAuthNoRetry sends an HTTP request to get an HTTP response. It works in
69 // the same way as DoWithAuth, but will not retry the request if it fails with
70 // an authorization error.
71 func (c *Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#) DoWithAuthNoRetryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#DoWithAuthNoRetry().(remote string, access credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.Accessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) (*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#, error) {
72 return c.doWithAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#doWithAuth().(remote, access, req, nil)
73 }
74
75 // DoAPIRequestWithAuth sends an HTTP request to get an HTTP response similarly
76 // to DoWithAuth, but using the LFS API endpoint for the provided remote and
77 // operation to determine the access mode.
78 func (c *Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#) DoAPIRequestWithAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#DoAPIRequestWithAuth().(remote string, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) (*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#, error) {
79 operation := getReqOperationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/getReqOperation().(req)
80 apiEndpoint := c.Endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Endpoints..Endpointscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#Endpoint.(operation, remote)
81 access := c.Endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Endpoints..AccessForscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#AccessFor.(apiEndpoint.Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#Url.)
82 return c.DoWithAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#DoWithAuth().(remote, access, req)
83 }
84
85 func (c *Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#) doWithAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#doWithAuth().(remote string, access credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.Accessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#, via []*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) (*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#, error) {
86 req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header. = c.clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#client..ExtraHeadersForscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Client#ExtraHeadersFor().(req)
87
88 credWrapper, err := c.getCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#getCreds().(remote, access, req)
89 if err != nil {
90 return nil, err
91 }
92 c.credContextscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#credContext..SetStateFieldsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperContext#SetStateFields().(credWrapper.Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds.["state[]"])
93
94 res, err := c.doWithCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#doWithCreds().(req, credWrapper, access, via)
95 if err != nil && errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsAuthErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsAuthError().(err) {
96 multistage := credWrapper.Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds..IsMultistagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#IsMultistage().()
97 newMode, newModes, headers := getAuthAccessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/getAuthAccess().(res, access.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().(), c.accessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#access., multistage)
98 newAccess := access.Upgradescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Upgrade().(newMode)
99 if newAccess.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().() != access.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().() {
100 c.Endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Endpoints..SetAccessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#SetAccess.(newAccess)
101 c.accessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#access. = newModes
102 }
103
104 if credWrapper.Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds. != nil {
105 req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Delscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Del().("Authorization")
106 if !multistage {
107 credWrapper.CredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#CredentialHelper..Rejectscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelper#Reject.(credWrapper.Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds.)
108 }
109 }
110 c.credContextscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#credContext..SetWWWAuthHeadersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperContext#SetWWWAuthHeaders().(headers)
111 }
112
113 if res != nil && res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. < 300 && res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. > 199 {
114 credWrapper.CredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#CredentialHelper..Approvescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelper#Approve.(credWrapper.Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds.)
115 }
116
117 return res, err
118 }
119
120 func (c *Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#) doWithCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#doWithCreds().(req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#, credWrapper credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.CredentialHelperWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#, access credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.Accessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#, via []*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) (*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#, error) {
121 if access.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().() == credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.NegotiateAccessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NegotiateAccess. {
122 return c.doWithNegotiatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#doWithNegotiate().(req, credWrapper)
123 }
124
125 req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("User-Agent", lfshttpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/.UserAgentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/UserAgent.)
126
127 client, err := c.clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#client..HttpClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Client#HttpClient().(req.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL., access.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().())
128 if err != nil {
129 return nil, err
130 }
131
132 redirectedReq, res, err := c.clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#client..DoWithRedirectscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Client#DoWithRedirect().(client, req, "", via)
133 if err != nil || res != nil {
134 return res, err
135 }
136
137 if redirectedReq == nil {
138 return res, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("failed to redirect request"))
139 }
140
141 return c.doWithAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#doWithAuth().("", access, redirectedReq, via)
142 }
143
144 // getCreds fills the authorization header for the given request if possible,
145 // from the following sources:
146 //
147 // 1. NTLM access is handled elsewhere.
148 // 2. Existing Authorization or ?token query tells LFS that the request is ready.
149 // 3. Netrc based on the hostname.
150 // 4. URL authentication on the Endpoint URL or the Git Remote URL.
151 // 5. Git Credential Helper, potentially prompting the user.
152 //
153 // There are three URLs in play, that make this a little confusing.
154 //
155 // 1. The request URL, which should be something like "https://git.com/repo.git/info/lfs/objects/batch"
156 // 2. The LFS API URL, which should be something like "https://git.com/repo.git/info/lfs"
157 // This URL used for the "lfs.URL.access" git config key, which determines
158 // what kind of auth the LFS server expects. Could be BasicAccess,
159 // NTLMAccess, NegotiateAccess, or NoneAccess, in which the Git Credential
160 // Helper step is skipped. We do not want to prompt the user for a password
161 // to fetch public repository data.
162 // 3. The Git Remote URL, which should be something like "https://git.com/repo.git"
163 // This URL is used for the Git Credential Helper. This way existing https
164 // Git remote credentials can be re-used for LFS.
165 func (c *Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#) getCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#getCreds().(remote string, access credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.Accessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) (credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.CredentialHelperWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#, error) {
166 ef := c.Endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Endpoints.
167 if ef == nil {
168 ef = defaultEndpointFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/defaultEndpointFinder.
169 }
170
171 operation := getReqOperationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/getReqOperation().(req)
172 apiEndpoint := ef.Endpointscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#Endpoint.(operation, remote)
173
174 if access.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().() != credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.NegotiateAccessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NegotiateAccess. {
175 if requestHasAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/requestHasAuth().(req) || access.Modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Access#Mode().() == credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.NoneAccessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NoneAccess. {
176 return credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.CredentialHelperWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#{CredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#CredentialHelper.: credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.NullCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NullCreds., Inputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Input.: nil, Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Url.: nil, Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds.: nil}, nil
177 }
178
179 credsURL, err := getCredURLForAPIscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/getCredURLForAPI().(ef, operation, remote, apiEndpoint, req)
180 if err != nil {
181 return credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.CredentialHelperWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#{CredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#CredentialHelper.: credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.NullCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NullCreds., Inputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Input.: nil, Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Url.: nil, Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds.: nil}, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Wrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Wrap().(err, trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("credentials"))
182 }
183
184 if credsURL == nil {
185 return credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.CredentialHelperWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#{CredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#CredentialHelper.: credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.NullCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NullCreds., Inputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Input.: nil, Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Url.: nil, Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds.: nil}, nil
186 }
187
188 credWrapper := c.getGitCredsWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#getGitCredsWrapper().(ef, req, credsURL)
189 err = credWrapper.FillCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#FillCreds().()
190 if err == nil {
191 tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("Filled credentials for %s", credsURL)
192 setRequestAuthWithCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/setRequestAuthWithCreds().(req, credWrapper.Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds.)
193 }
194 return credWrapper, err
195 }
196
197 // Negotiate only
198
199 credsURL, err := urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Parse().(apiEndpoint.Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#Url.)
200 if err != nil {
201 return credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.CredentialHelperWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#{CredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#CredentialHelper.: credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.NullCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/NullCreds., Inputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Input.: nil, Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Url.: nil, Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper#Creds.: nil}, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Wrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Wrap().(err, trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("credentials"))
202 }
203
204 // NTLM uses creds to create the session
205 credWrapper := c.getGitCredsWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#getGitCredsWrapper().(ef, req, credsURL)
206 return credWrapper, err
207 }
208
209 func (c *Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#) getGitCredsWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#getGitCredsWrapper().(ef EndpointFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#, u *urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#) credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.CredentialHelperWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperWrapper# {
210 return c.credContextscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#credContext..GetCredentialHelperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/CredentialHelperContext#GetCredentialHelper().(c.Credentialsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Credentials., u)
211 }
212
213 func getCredURLForAPIscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/getCredURLForAPI().(ef EndpointFinderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#, operation, remote string, apiEndpoint lfshttpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/.Endpointscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) (*urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#, error) {
214 apiURL, err := urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Parse().(apiEndpoint.Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#Url.)
215 if err != nil {
216 return nil, err
217 }
218
219 // if the LFS request doesn't match the current LFS url, don't bother
220 // attempting to set the Authorization header from the LFS or Git remote URLs.
221 if req.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Schemescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Scheme. != apiURL.Schemescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Scheme. ||
222 req.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Hostscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Host. != apiURL.Hostscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Host. {
223 return req.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL., nil
224 }
225
226 if setRequestAuthFromURLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/setRequestAuthFromURL().(req, apiURL) {
227 return nil, nil
228 }
229
230 if len(remote) > 0 {
231 if u := ef.GitRemoteURLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#GitRemoteURL.(remote, operation == "upload"); u != "" {
232 schemedUrl, _ := fixSchemelessURLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/fixSchemelessURL().(u)
233
234 gitRemoteURL, err := urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Parse().(schemedUrl)
235 if err != nil {
236 return nil, err
237 }
238
239 if gitRemoteURL.Schemescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Scheme. == apiURL.Schemescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Scheme. &&
240 gitRemoteURL.Hostscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Host. == apiURL.Hostscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Host. {
241
242 if setRequestAuthFromURLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/setRequestAuthFromURL().(req, gitRemoteURL) {
243 return nil, nil
244 }
245
246 return gitRemoteURL, nil
247 }
248 }
249 }
250
251 return apiURL, nil
252 }
253
254 // fixSchemelessURL prepends an empty scheme "//" if none was found in
255 // the URL and replaces the first colon with a slash in order to satisfy RFC
256 // 3986 ยง3.3, and `net/url.Parse()`.
257 //
258 // It returns a string parse-able with `net/url.Parse()` and a boolean whether
259 // or not an empty scheme was added.
260 func fixSchemelessURLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/fixSchemelessURL().(u string) (string, bool) {
261 if hasSchemescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/hasScheme().(u) {
262 return u, false
263 }
264
265 colon := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Indexscip-go gomod github.com/golang/go/src go1.25.0 strings/Index().(u, ":")
266 slash := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Indexscip-go gomod github.com/golang/go/src go1.25.0 strings/Index().(u, "/")
267
268 if colon >= 0 && (slash < 0 || colon < slash) {
269 // First path segment has a colon, assumed that it's a
270 // scheme-less URL. Append an empty scheme on top to
271 // satisfy RFC 3986 ยง3.3, and `net/url.Parse()`.
272 //
273 // In addition, replace the first colon with a slash since
274 // otherwise the colon looks like it's introducing a port
275 // number.
276 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("//%s", stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Replacescip-go gomod github.com/golang/go/src go1.25.0 strings/Replace().(u, ":", "/", 1)), true
277 }
278 return u, true
279 }
280
281 var (
282 // supportedSchemes is the list of URL schemes the `lfsapi` package
283 // supports.
284 supportedSchemesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/supportedSchemes. = []string{"ssh", "http", "https"}
285 )
286
287 // hasScheme returns whether or not a given string (taken to represent a RFC
288 // 3986 URL) has a scheme that is supported by the `lfsapi` package.
289 func hasSchemescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/hasScheme().(what string) bool {
290 for _, scheme := range supportedSchemesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/supportedSchemes. {
291 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(what, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("%s://", scheme)) {
292 return true
293 }
294 }
295
296 return false
297 }
298
299 func requestHasAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/requestHasAuth().(req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) bool {
300 // The "Authorization" string constant is safe, since we assume that all
301 // request headers have been canonicalized.
302 if len(req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Get().("Authorization")) > 0 {
303 return true
304 }
305
306 return len(req.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Queryscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#Query().().Getscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Values#Get().("token")) > 0
307 }
308
309 func setRequestAuthFromURLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/setRequestAuthFromURL().(req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#, u *urlscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#) bool {
310 if u.Userscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#User. == nil {
311 return false
312 }
313
314 if pass, ok := u.Userscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#User..Passwordscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Userinfo#Password().(); ok {
315 fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintln().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr., trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("warning: current Git remote contains credentials"))
316 setRequestAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/setRequestAuth().(req, u.Userscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#User..Usernamescip-go gomod github.com/golang/go/src go1.25.0 `net/url`/Userinfo#Username().(), pass)
317 return true
318 }
319
320 return false
321 }
322
323 func setRequestAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/setRequestAuth().(req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#, user, pass string) {
324 if len(user) == 0 && len(pass) == 0 {
325 return
326 }
327
328 token := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("%s:%s", user, pass)
329 auth := "Basic " + stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSpace().(base64scip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/.StdEncodingscip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/StdEncoding..EncodeToStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/base64`/Encoding#EncodeToString().([]byte(token)))
330 req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Authorization", auth)
331 }
332
333 func setRequestAuthWithCredsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/setRequestAuthWithCreds().(req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#, c credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.Credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/Creds#) {
334 authtype := credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(c, "authtype")
335 credential := credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(c, "credential")
336 if len(authtype) == 0 && len(credential) == 0 {
337 user := credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(c, "username")
338 pass := credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.FirstEntryForKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/FirstEntryForKey().(c, "password")
339 setRequestAuthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/setRequestAuth().(req, user, pass)
340 return
341 }
342
343 auth := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("%s %s", authtype, credential)
344 req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Authorization", auth)
345 }
346
347 func getReqOperationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/getReqOperation().(req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) string {
348 operation := "download"
349 if req.Methodscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Method. == "POST" || req.Methodscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Method. == "PUT" {
350 operation = "upload"
351 }
352 return operation
353 }
354
355 var (
356 authenticateHeadersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/authenticateHeaders. = []string{"Lfs-Authenticate", "Www-Authenticate"}
357 )
358
359 func getAuthAccessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/getAuthAccess().(res *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#, access credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.AccessModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/AccessMode#, modes []credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.AccessModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/AccessMode#, multistage bool) (credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.AccessModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/AccessMode#, []credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.AccessModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/AccessMode#, []string) {
360 newModes := make([]credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.AccessModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/AccessMode#, 0, len(modes))
361 for _, mode := range modes {
362 if multistage || access != mode {
363 newModes = append(newModes, mode)
364 }
365 }
366 headers := make([]string, 0)
367 if res != nil {
368 for _, headerName := range authenticateHeadersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/authenticateHeaders. {
369 headers = append(headers, res.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Header.[headerName]...)
370 }
371 supportedModes := make(map[credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.AccessModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/AccessMode#]struct{})
372 for _, headerName := range authenticateHeadersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/authenticateHeaders. {
373 for _, auth := range res.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Header.[headerName] {
374 pieces := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.SplitNscip-go gomod github.com/golang/go/src go1.25.0 strings/SplitN().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.0 strings/ToLower().(auth), " ", 2)
375 if len(pieces) == 0 {
376 continue
377 }
378
379 supportedModes[credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.AccessModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/AccessMode#(pieces[0])] = struct{}{}
380 }
381 }
382 for _, mode := range newModes {
383 if _, ok := supportedModes[mode]; ok {
384 return mode, newModes, headers
385 }
386 }
387 }
388
389 return credsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/.BasicAccessscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/creds`/BasicAccess., newModes, headers
390 }