MCPcopy
hub / github.com/git-lfs/git-lfs / doWithAuth

Method doWithAuth

lfsapi/auth.go:63–104  ·  view source on GitHub ↗
(remote string, count *int, access creds.Access, req *http.Request, via []*http.Request)

Source from the content-addressed store, hash-verified

61}
62
63func (c *Client) doWithAuth(remote string, count *int, access creds.Access, req *http.Request, via []*http.Request) (*http.Response, error) {
64 if *count == defaultMaxAuthAttempts {
65 return nil, fmt.Errorf("too many authentication attempts")
66 }
67
68 req.Header = c.client.ExtraHeadersFor(req)
69
70 credWrapper, err := c.getCreds(remote, access, req)
71 if err != nil {
72 return nil, err
73 }
74 c.credContext.SetStateFields(credWrapper.Creds["state[]"])
75
76 res, err := c.doWithCreds(req, count, credWrapper, access, via)
77 if err != nil {
78 if errors.IsAuthError(err) {
79 multistage := credWrapper.Creds.IsMultistage()
80 newMode, newModes, headers := getAuthAccess(res, access.Mode(), c.access, multistage)
81 newAccess := access.Upgrade(newMode)
82 if newAccess.Mode() != access.Mode() {
83 c.Endpoints.SetAccess(newAccess)
84 c.access = newModes
85 }
86
87 if credWrapper.Creds != nil {
88 req.Header.Del("Authorization")
89 if multistage && *count < defaultMaxAuthAttempts && res != nil && res.StatusCode == 401 {
90 *count++
91 } else {
92 credWrapper.CredentialHelper.Reject(credWrapper.Creds)
93 }
94 }
95 c.credContext.SetWWWAuthHeaders(headers)
96 }
97 }
98
99 if res != nil && res.StatusCode < 300 && res.StatusCode > 199 {
100 credWrapper.CredentialHelper.Approve(credWrapper.Creds)
101 }
102
103 return res, err
104}
105
106func (c *Client) doWithCreds(req *http.Request, count *int, credWrapper creds.CredentialHelperWrapper, access creds.Access, via []*http.Request) (*http.Response, error) {
107 if access.Mode() == creds.NegotiateAccess {

Callers 3

DoWithAuthMethod · 0.95
DoWithAuthNoRetryMethod · 0.95
doWithCredsMethod · 0.95

Calls 15

getCredsMethod · 0.95
doWithCredsMethod · 0.95
IsAuthErrorFunction · 0.92
getAuthAccessFunction · 0.85
ExtraHeadersForMethod · 0.80
SetStateFieldsMethod · 0.80
IsMultistageMethod · 0.80
ModeMethod · 0.80
SetWWWAuthHeadersMethod · 0.80
ErrorfMethod · 0.65
UpgradeMethod · 0.65
SetAccessMethod · 0.65

Tested by

no test coverage detected