repman-io / repman

Repman - PHP Repository Manager: packagist proxy and host for private packages
https://repman.io
MIT License
519 stars 107 forks source link

Can't synchronize GitLab repositories anymore #594

Open gsusI opened 2 years ago

gsusI commented 2 years ago

Can't synchronize GitLab repositories anymore

Steps to reproduce the issue:

  1. Go to Gitlab and open User Settings > Applications
  2. Revoke Repman from the list of Authorized Applications
  3. Unlink GitLab from Repman User settings
  4. Go to https://app.repman.io/organization//package
  5. Click on Add package
  6. Select GitLab
  7. Authenticate with GitLab
  8. Authorize Repman to access your GitLab repositories
  9. Select the repositories to be synchronized
  10. Click Add
  11. In the list of packages, all packages appear with a red message saying "SYNCHRONIZATION ERROR"

SYNCHRONIZATION ERROR

Error: Failed to execute git clone --mirror -- 'https://oauth2:***@gitlab.com/<organization>/<package>.git' '/home/repman/.composer/cache/vcs/git-gitlab.com-<organization>-<package>.git/'

Cloning into bare repository '/home/repman/.composer/cache/vcs/git-gitlab.com-<organization>-<package>.git/'...
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://oauth2:***@gitlab.com/<organization>/<package>.git/'

Logs:
Failed to clone the git@gitlab.com:<organization>/<package>.git repository, try running in interactive mode so that you can enter your credentials
gsusI commented 2 years ago

A colleague of mine managed to add the packages without any issue following the same steps as me. Unsure why.

Could it be related to this issue?

Fahl-Design commented 2 years ago

looks more like #589

gsusI commented 2 years ago

Doesn't feel like. Repman was able to get the list of repositories, suggesting that the tokens were fine.

Also, I didn't get a 500 error, nor a Bad Request.

Fahl-Design commented 2 years ago

hm ok, did you check the token itself? there is an endpoint for that:

https://gitlab.com/oauth/token/info?access_token=<YOUR_TOKEN>

maybe it is missing a scope

althaus commented 2 years ago

We also get the same since updating our Gitlab from 14 to 15. It's just happening to existing packages if someone releases a new version.

grafik

prhost commented 2 years ago

I'm getting this error when downloading the source, only dist is working.

Screen Shot 2022-07-06 at 11 41 20

shochdoerfer commented 2 years ago

Having the same issue with our self-hosted GitLab instance. Sync stopped working after the upgrade to GitLab 15. I had to remove the OAuth application configuration in GitLab and set it up again. After that things seem to work normally again.

temp commented 2 years ago

Same Problem here. Tried to re-register the oauth app in gitlab (self hosted), as stated by @shochdoerfer , but still the same git error as mentioned above. Any hints? We also upgrade from gitlab 14.x to 15.1 on friday, so this seems related.

shochdoerfer commented 2 years ago

@temp I gave the OAuth app in GitLab almost all (read-only permissions) because I was not sure which ones are the correct ones. Maybe you could give this a try as well.

Fahl-Design commented 2 years ago

I still think it's related to https://github.com/repman-io/repman/issues/589 with it's root cause of expired refresh tokens. The refresh token is never updated without https://github.com/repman-io/repman/pull/596

temp commented 2 years ago

We applied MR #596 and emptied the user_oauth_token table, after that it worked again. @shochdoerfer we tried that before, but without success. Now we are back to api and read_users, as stated in the docs.

temp commented 2 years ago

... and now it's not working anymore -_- Now I'm getting a Bad Request when he tries to fetch a new token from gitlab via /oauth/token.

f3l1x commented 2 years ago

Same error at me.

shochdoerfer commented 2 years ago

Ran into the issue again. After truncating the user_oauth_token db table, deleting and re-creating the GitLab app, it works again.

pavkatar commented 2 years ago

Found a workaround:

The token expires every day. Go to the database > user_oauth_token. Delete token for the GitLab. After that, go to the Admin UI > Packages > Add new package > Select GitLab and wait. This will generate a new token and will work for a day.

prhost commented 2 years ago

Found a workaround:

The token expires every day. Go to the database > user_oauth_token. Delete token for the GitLab. After that, go to the Admin UI > Packages > Add new package > Select GitLab and wait. This will generate a new token and will work for a day.

I already did that, you don't even need to go to the database to delete, just go to your user in the interface, and unlink Gitlab Account.

prhost commented 2 years ago

I think that even the only solution will be to create a schedule in the project that does this every day from time to time.

prhost commented 1 year ago

Now I'm getting this error when selecting repositories from gitlab:

Screenshot 2023-03-02 at 12 06 20