Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-8834

403 error occured when pushing LFS files to a public repository with HTTP protocol

    XMLWordPrintable

Details

    Description

      Summary

      403 error occurred when pushing LFS files to a public repository with HTTP protocol.

      Steps to Reproduce

      1. Create a repository
      2. Allow LFS and make the repository public
      3. Clone the repository to local with the following URL
      4. Execute the following commands on your local
        $ git lfs track "*.txt"
        $ touch test.txt
        $ git add .gitattributes test.txt
        $ git commit -a -m "test"
        $ GIT_CURL_VERBOSE=1 git push
        

      Expected Results

      Push command should ask me to input credentials and succeed in case we input them correctly.

      Actual Results

      Push command failed as follows.

      warning: push.default is unset; its implicit value has changed in
      Git 2.0 from 'matching' to 'simple'. To squelch this message
      and maintain the traditional behavior, use:
      
        git config --global push.default matching
      
      To squelch this message and adopt the new behavior now, use:
      
        git config --global push.default simple
      
      When push.default is set to 'matching', git will push local branches
      to the remote branches that already exist with the same name.
      
      Since Git 2.0, Git defaults to the more conservative 'simple'
      behavior, which only pushes the current branch to the corresponding
      remote branch that 'git pull' uses to update the current branch.
      
      See 'git help config' and search for 'push.default' for further information.
      (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
      'current' instead of 'simple' if you sometimes use older versions of Git)
      
      * Couldn't find host 192.168.33.20 in the .netrc file; using defaults
      * Hostname was NOT found in DNS cache
      *   Trying 192.168.33.20...
      * Connected to 192.168.33.20 (192.168.33.20) port 7990 (#0)
      > GET /scm/test/test.git/info/refs?service=git-receive-pack HTTP/1.1
      User-Agent: git/2.3.2 (Apple Git-55)
      Host: 192.168.33.20:7990
      Accept: */*
      Accept-Encoding: gzip
      Pragma: no-cache
      
      < HTTP/1.1 401 Unauthorized
      * Server Apache-Coyote/1.1 is not blacklisted
      < Server: Apache-Coyote/1.1
      < X-AREQUESTID: @G03ZRHx1355x848x0
      < X-ASEN: SEN-L7921887
      < X-XSS-Protection: 1; mode=block
      < X-Frame-Options: SAMEORIGIN
      < X-Content-Type-Options: nosniff
      < WWW-Authenticate: Basic realm="Atlassian Bitbucket"
      < Transfer-Encoding: chunked
      < Date: Mon, 06 Jun 2016 22:35:44 GMT
      <
      * Connection #0 to host 192.168.33.20 left intact
      * Couldn't find host 192.168.33.20 in the .netrc file; using defaults
      * Found bundle for host 192.168.33.20: 0x7faf9841f3a0
      * Hostname was found in DNS cache
      *   Trying 192.168.33.20...
      * Connected to 192.168.33.20 (192.168.33.20) port 7990 (#1)
      > GET /scm/test/test.git/info/refs?service=git-receive-pack HTTP/1.1
      User-Agent: git/2.3.2 (Apple Git-55)
      Host: 192.168.33.20:7990
      Accept: */*
      Accept-Encoding: gzip
      Pragma: no-cache
      
      < HTTP/1.1 401 Unauthorized
      * Server Apache-Coyote/1.1 is not blacklisted
      < Server: Apache-Coyote/1.1
      < X-AREQUESTID: @G03ZRHx1355x849x0
      < X-ASEN: SEN-L7921887
      < X-XSS-Protection: 1; mode=block
      < X-Frame-Options: SAMEORIGIN
      < X-Content-Type-Options: nosniff
      < WWW-Authenticate: Basic realm="Atlassian Bitbucket"
      < Transfer-Encoding: chunked
      < Date: Mon, 06 Jun 2016 22:35:44 GMT
      <
      * Ignoring the response-body
      * Connection #1 to host 192.168.33.20 left intact
      * Issue another request to this URL: 'http://192.168.33.20:7990/scm/test/test.git/info/refs?service=git-receive-pack'
      * Couldn't find host 192.168.33.20 in the .netrc file; using defaults
      * Found bundle for host 192.168.33.20: 0x7faf9841f3a0
      * Re-using existing connection! (#1) with host 192.168.33.20
      * Connected to 192.168.33.20 (192.168.33.20) port 7990 (#1)
      * Server auth using Basic with user 'admin1'
      > GET /scm/test/test.git/info/refs?service=git-receive-pack HTTP/1.1
      Authorization: Basic YWRtaW4xOnNwaGVyZQ==
      User-Agent: git/2.3.2 (Apple Git-55)
      Host: 192.168.33.20:7990
      Accept: */*
      Accept-Encoding: gzip
      Pragma: no-cache
      
      < HTTP/1.1 200 OK
      * Server Apache-Coyote/1.1 is not blacklisted
      < Server: Apache-Coyote/1.1
      < X-AREQUESTID: @G03ZRHx1355x850x0
      < X-ASEN: SEN-L7921887
      < X-AUSERID: 1
      < X-AUSERNAME: admin1
      < X-XSS-Protection: 1; mode=block
      < X-Frame-Options: SAMEORIGIN
      < X-Content-Type-Options: nosniff
      < Expires: Fri, 01 Jan 1980 00:00:00 GMT
      < Pragma: no-cache
      < Cache-Control: no-cache, max-age=0, must-revalidate
      < Content-Type: application/x-git-receive-pack-advertisement
      < Transfer-Encoding: chunked
      < Date: Mon, 06 Jun 2016 22:35:44 GMT
      <
      * Connection #1 to host 192.168.33.20 left intact
      > POST /scm/test/test.git/info/lfs/objects/batch HTTP/1.1
      > Host: 192.168.33.20:7990
      > Accept: application/vnd.git-lfs+json; charset=utf-8
      > Content-Type: application/vnd.git-lfs+json; charset=utf-8
      > User-Agent: git-lfs/1.1.0 (GitHub; darwin amd64; go 1.5.1)
      >
      {"objects":[{"oid":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","size":0}],"operation":"upload"}
      
      < HTTP/1.1 403 Forbidden
      < Transfer-Encoding: chunked
      < Content-Type: application/vnd.git-lfs+json
      < Date: Mon, 06 Jun 2016 22:35:44 GMT
      < Server: Apache-Coyote/1.1
      < X-Arequestid: @G03ZRHx1355x851x0
      < X-Asen: SEN-L7921887
      < X-Content-Type-Options: nosniff
      < X-Frame-Options: SAMEORIGIN
      < X-Xss-Protection: 1; mode=block
      <
      Git LFS: (0 of 1 files) 0 B / 0 B                                                                                                                                                                          You are not permitted to access this resource: Access is denied
      error: failed to push some refs to 'http://192.168.33.20:7990/scm/test/test.git'
      

      Notes

      • After the Step 3, if you try git lfs env command, you can see the following information
        Endpoint=http://192.168.33.20:7990/scm/test/test.git/info/lfs (auth=none)
        
      • If you make the repository private, push command succeeded as expected
      • Once your push command succeeded, even if you make the repository public again, delete the repository on your local and clone it , the push command will succeed
        • Then, git lfs env showed the following information
          Endpoint=http://192.168.33.20:7990/scm/test/test.git/info/lfs (auth=basic)
          

      Workaround

      Clone the repository with the following URL instead and just add, commit, push the files as usual.
      http://<USER>@<BASE_URL>/scm/<PROJECT>/<REPOSITORY>.git

      Attachments

        Issue Links

          Activity

            People

              jthomas@atlassian.com Justin Thomas
              yokamoto Yuki Okamoto (Inactive)
              Votes:
              16 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: