Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gogs to local: Warn: Authentication required #267

Closed
gerardnico opened this issue Sep 2, 2024 · 11 comments
Closed

Gogs to local: Warn: Authentication required #267

gerardnico opened this issue Sep 2, 2024 · 11 comments

Comments

@gerardnico
Copy link

gerardnico commented Sep 2, 2024

Hallo,

I have an authentication problem but I don't know why.

2024-09-02T08:41:03Z INF cloning aap path=/tmp/gickup stage=locally
2024-09-02T08:41:03Z WRN retry 2 from 5 error="authentication required" path=/tmp/gickup stage=locally

I try a lot of configuration but could not make it work.

Below you can see the run and all the investigation that I have done.

The config from gogs to local:

source:
  gogs:
    - url: https://gogs.bytle.net/
      # GOGS_TOKEN is an env
      token: GOGS_TOKEN
      # the user you want to clone the repositories from.
      user: nickeau
      username: nickeau
      # GOGS_PASSWORD is an env
      password: GOGS_PASSWORD
      ssh: false
      filter:
        excludeforks: true # exclude forked repositories
      # this includes the repo "aap"
      include:
        - aap
destination:
  local:
    # Export this path from Docker with a volume to make it accessible and more permanent.
    - path: /tmp/gickup

The run:

docker run --rm \
    -v ~/.config/gickup/gogs-to-local-conf.yml:/gickup/conf.yml \
    -e GITHUB_TOKEN=$GITHUB_TOKEN \
    -e GOGS_TOKEN=$GOGS_TOKEN \
    -e GOGS_PASSWORD=$GOGS_PASSWORD \
    --mount type=tmpfs,destination=/tmp \
    ghcr.io/cooperspencer/gickup:0.10.34

The result:

2024-09-02T08:40:57Z INF Reading /gickup/conf.yml file=/gickup/conf.yml
2024-09-02T08:40:57Z INF Configuration loaded destinations=1 pairs=1 sources=1
2024-09-02T08:40:57Z INF Backup run starting
2024-09-02T08:40:57Z INF grabbing repositories from nickeau stage=gogs url=https://gogs.bytle.net/
2024-09-02T08:40:58Z INF starting backup for https://gogs.bytle.net/nickeau/aap.git stage=backup
2024-09-02T08:40:58Z INF cloning aap path=/tmp/gickup stage=locally
2024-09-02T08:40:58Z WRN retry 1 from 5 error="authentication required" path=/tmp/gickup stage=locally
2024-09-02T08:41:03Z INF cloning aap path=/tmp/gickup stage=locally
2024-09-02T08:41:03Z WRN retry 2 from 5 error="authentication required" path=/tmp/gickup stage=locally

Authentication test:

  • The git auth credentials are the good one
git clone --mirror https://nickeau:$GOGS_PASSWORD@gogs.bytle.net/nickeau/algo /tmp/algo
Cloning into bare repository '/tmp/algo'...
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 12 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (12/12), 3.76 KiB | 1.25 MiB/s, done.
  • The API Token is the good one
curl -sS -f -I -H "Authorization: token $GOGS_TOKEN" https://gogs.bytle.net/api/v1/user/repos
HTTP/2 200
server: nginx/1.20.1
date: Mon, 02 Sep 2024 08:49:40 GMT
content-type: application/json; charset=UTF-8
set-cookie: lang=en-US; Path=/; Max-Age=2147483647
set-cookie: i_like_gogs=c005152a9d17e209; Path=/; HttpOnly
set-cookie: _csrf=jMWlYalLrf-wxc9d__wbWJM8iXE6MTcyNTI2Njk4MDQ5NTc4NDc3NA%3D%3D; Path=/; Expires=Tue, 03 Sep 2024 08:49:40 GMT; HttpOnly

Note that I installed also gickup locally and got the same behavior.
I have no idea how to increase the log level. There is a log in the conf file but I don't see any log level.

How are you doing the cloning? via a mirror?

git clone --mirror ....
@cooperspencer
Copy link
Owner

cooperspencer commented Sep 2, 2024

Hi,
I'll have a look at what is going on.
There is a --debug option, but it is not that good yet and desires major improvement in the future.

How are you doing the cloning? via a mirror?

It does a normal clone and keeps it up to date via pulling.

@cooperspencer
Copy link
Owner

cooperspencer commented Sep 2, 2024

can you remove password: GOGS_PASSWORD from your configuration and re-run it?
the password parameter won't be resolved via an environment variable, only token.
if you remove the password key, it will use the token for the clone.

you can remove username too.

@gerardnico
Copy link
Author

Thanks.

Same result.

With

source:
  gogs:
    - url: https://gogs.bytle.net/
      # GOGS_TOKEN is an env
      token: GOGS_TOKEN
      # the user you want to clone the repositories from.
      user: nickeau
      username: nickeau
      ssh: false
      filter:
        excludeforks: true # exclude forked repositories
      # this includes the repo "aap"
      include:
        - aap
destination:
  local:
    # Export this path from Docker with a volume to make it accessible and more permanent.
    - path: /tmp/gickup

Result:

2024-09-02T09:43:41Z INF Reading /gickup/conf.yml file=/gickup/conf.yml
2024-09-02T09:43:41Z INF Configuration loaded destinations=1 pairs=1 sources=1
2024-09-02T09:43:41Z INF Backup run starting
2024-09-02T09:43:41Z INF grabbing repositories from nickeau stage=gogs url=https://gogs.bytle.net/
2024-09-02T09:43:42Z INF starting backup for https://gogs.bytle.net/nickeau/aap.git stage=backup
2024-09-02T09:43:42Z INF cloning aap path=/tmp/gickup stage=locally
2024-09-02T09:43:42Z WRN retry 1 from 5 error="authentication required" path=/tmp/gickup stage=locally

How do you do the auth, like that?

git clone --mirror https://nickeau:$GOGS_TOKEN@gogs.bytle.net/nickeau/algo /tmp/algo
Cloning into bare repository '/tmp/algo'...
fatal: Authentication failed for 'https://gogs.bytle.net/nickeau/algo/'

@gerardnico
Copy link
Author

With or without username, it does not matter. Same behavior.

@gerardnico
Copy link
Author

Found. How it works.

git clone --mirror https://$GOGS_TOKEN@gogs.bytle.net/nickeau/algo /tmp/algo
Cloning into bare repository '/tmp/algo'...
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 12 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (12/12), 3.76 KiB | 1.25 MiB/s, done.

@gerardnico
Copy link
Author

The token is working because it can list the repositories, by the way.

Last Yaml, same output:

source:
  gogs:
    - url: https://gogs.bytle.net/
      # GOGS_TOKEN is an env
      token: GOGS_TOKEN
      # the user you want to clone the repositories from.
      user: nickeau
      ssh: false
      filter:
        excludeforks: true # exclude forked repositories
      # this includes the repo "aap"
      include:
        - aap
destination:
  local:
    # Export this path from Docker with a volume to make it accessible and more permanent.
    - path: /tmp/gickup

@gerardnico
Copy link
Author

gerardnico commented Sep 2, 2024

With the --debug option

docker run --rm \
    -v ~/.config/gickup/gogs-to-local-conf.yml:/gickup/conf.yml \
    -e GITHUB_TOKEN=$GITHUB_TOKEN \
    -e GOGS_TOKEN=$GOGS_TOKEN \
    --mount type=tmpfs,destination=/tmp \
    ghcr.io/cooperspencer/gickup:0.10.34
    /gickup/conf.yml --debug
2024-09-02T09:56:00Z INF Reading /gickup/conf.yml file=/gickup/conf.yml
2024-09-02T09:56:00Z INF Configuration loaded destinations=1 pairs=1 sources=1
2024-09-02T09:56:00Z INF Backup run starting
2024-09-02T09:56:00Z INF grabbing repositories from nickeau stage=gogs url=https://gogs.bytle.net/
2024-09-02T09:56:01Z DBG https://gogs.bytle.net/nickeau/examenly stage=gogs url=https://gogs.bytle.net/
2024-09-02T09:56:01Z DBG https://gogs.bytle.net/nickeau/aap stage=gogs url=https://gogs.bytle.net/
2024-09-02T09:56:01Z DBG https://gogs.bytle.net/nickeau/adserver stage=gogs url=https://gogs.bytle.net/
2024-09-02T09:56:01Z DBG https://gogs.bytle.net/nickeau/algo stage=gogs url=https://gogs.bytle.net/
2024-09-02T09:56:01Z INF starting backup for https://gogs.bytle.net/nickeau/aap.git stage=backup
2024-09-02T09:56:01Z INF cloning aap path=/tmp/gickup stage=locally
2024-09-02T09:56:01Z WRN retry 1 from 5 error="authentication required" path=/tmp/gickup stage=locally

@cooperspencer
Copy link
Owner

can you remove everything in /tmp/gickup and retry it.

@gerardnico
Copy link
Author

There is nothing, it's a temporary mount because it's required when you run the docker image

--mount type=tmpfs,destination=/tmp

I moved it to /target

New conf:

source:
  gogs:
    - url: https://gogs.bytle.net/
      # GOGS_TOKEN is an env
      token: GOGS_TOKEN
      # the user you want to clone the repositories from.
      user: nickeau
      ssh: false
      filter:
        excludeforks: true # exclude forked repositories
      # this includes the repo "aap"
      include:
        - aap
destination:
  local:
    # Export this path from Docker with a volume to make it accessible and more permanent.
    - path: /target

New run:

docker run --rm \
    -v ~/.config/gickup/gogs-to-local-conf.yml:/gickup/conf.yml \
    -e GITHUB_TOKEN=$GITHUB_TOKEN \
    -e GOGS_TOKEN=$GOGS_TOKEN \
    --mount type=tmpfs,destination=/tmp \
    --mount type=tmpfs,destination=/target \
    ghcr.io/cooperspencer/gickup:0.10.34
    /gickup/conf.yml --debug

Same output:

2024-09-02T10:03:14Z INF Reading /gickup/conf.yml file=/gickup/conf.yml
2024-09-02T10:03:14Z INF Configuration loaded destinations=1 pairs=1 sources=1
2024-09-02T10:03:14Z INF Backup run starting
2024-09-02T10:03:14Z INF grabbing repositories from nickeau stage=gogs url=https://gogs.bytle.net/
2024-09-02T10:03:15Z INF starting backup for https://gogs.bytle.net/nickeau/aap.git stage=backup
2024-09-02T10:03:15Z INF cloning aap path=/target stage=locally
2024-09-02T10:03:15Z WRN retry 1 from 5 error="authentication required" path=/target stage=locally

@cooperspencer
Copy link
Owner

cooperspencer commented Sep 2, 2024

It is really weird, because I can't reproduce this at all.
I created a gogs instance via docker, created a repo, created a token and used this config:

source:
  gogs:
    - token: GOGS_TOKEN
      user: buddy
      url: http://127.0.0.1:3000

destination:
  local:
  - path: /tmp/

And it works perfectly fine.

Is https://gogs.bytle.net/ publicly reachable? Would I be able to get an account there to investigate the issue?

Repository owner deleted a comment from gerardnico Sep 2, 2024
@cooperspencer
Copy link
Owner

fixed with #268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants