Third-party service unable to fetch token from GitLab using OAuth

Hello

I have self hosted GitLab instance that available through bundled nginx on https endpoint. I’m trying to configure Harbor to use GitLab as OAuth provider. Actually this worked half year ago.

The OAuth process failing at stage when token should be acquired by harbor from Gitlab with following logs on GitLab side:

==> /var/log/gitlab/gitlab-rails/production.log <==
Started POST "/oauth/token" for 10.0.100.2 at 2021-11-05 14:15:57 +0000
Processing by Gitlab::RequestForgeryProtection::Controller#index as HTML
Can't verify CSRF token authenticity.
Completed 422 Unprocessable Entity in 2ms (ActiveRecord: 0.0ms | Elasticsearch: 0.0ms | Allocations: 152)
Processing by Oauth::TokensController#create as HTML
  Parameters: {"code"=>"[FILTERED]", "grant_type"=>"authorization_code", "redirect_uri"=>"https://harbor.my/c/oidc/callback"}
Completed 401 Unauthorized in 14ms (Views: 0.5ms | ActiveRecord: 3.3ms | Elasticsearch: 0.0ms | Allocations: 869)

==> /var/log/gitlab/gitlab-rails/production_json.log <==
{"method":"POST","path":"/oauth/token","format":"html","controller":"Oauth::TokensController","action":"create","status":401,"time":"2021-11-05T14:15:58.022Z","params":[{"key":"code","value":"[FILTERED]"},{"key":"grant_type","value":"authorization_code"},{"key":"redirect_uri","value":"https://harbor.my/c/oidc/callback"}],"remote_ip":null,"user_id":null,"username":null,"ua":null,"redis_calls":2,"redis_duration_s":0.000998,"redis_read_bytes":5,"redis_write_bytes":154,"redis_rate_limiting_calls":2,"redis_rate_limiting_duration_s":0.000998,"redis_rate_limiting_read_bytes":5,"redis_rate_limiting_write_bytes":154,"db_count":3,"db_write_count":0,"db_cached_count":0,"db_replica_count":0,"db_replica_cached_count":0,"db_replica_wal_count":0,"db_replica_wal_cached_count":0,"db_primary_count":3,"db_primary_cached_count":0,"db_primary_wal_count":0,"db_primary_wal_cached_count":0,"db_replica_duration_s":0.0,"db_primary_duration_s":0.01,"rack_attack_redis_count":1,"rack_attack_redis_duration_s":0.0016837911680340767,"cpu_s":0.056041,"mem_objects":6889,"mem_bytes":880038,"mem_mallocs":2080,"mem_total_bytes":1155598,"pid":813,"correlation_id":"01FKR79J83EQBA9NQHGNRKBHZA","db_duration_s":0.00327,"view_duration_s":0.00051,"duration_s":0.01465}

And on following log on harbor side:

[ERROR] [/core/controllers/oidc.go:92]: Failed to exchange token, error: oauth2: cannot fetch token: 400 Bad Request   

Please, have someone any idea what can cause this behavior?