mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
Socialite's GitLab provider fetches the user from /api/v3/user, which GitLab removed in 11.0 (410 Gone). Add App\Auth\GitlabProvider that reads /api/v4/user with a bearer token and register it in the socialite helper, for both gitlab.com and self-hosted base URLs. Environment variable copyValue now checks the 'update' policy on the variable instead of the member role of the current team, so members can no longer copy values after switching to a team they own. Remove the redundant member check from ShowHardcoded. Add tests for the GitLab v4 user lookup and the team-switch copy case.
27 lines
706 B
PHP
27 lines
706 B
PHP
<?php
|
|
|
|
namespace App\Auth;
|
|
|
|
use GuzzleHttp\RequestOptions;
|
|
use Laravel\Socialite\Two\GitlabProvider as SocialiteGitlabProvider;
|
|
|
|
/**
|
|
* Socialite's GitLab provider reads the user from /api/v3/user, which GitLab
|
|
* removed in 11.0 (410 Gone). Read it from API v4 instead.
|
|
*/
|
|
class GitlabProvider extends SocialiteGitlabProvider
|
|
{
|
|
/**
|
|
* @param string $token
|
|
* @return array<string, mixed>
|
|
*/
|
|
protected function getUserByToken($token)
|
|
{
|
|
$response = $this->getHttpClient()->get($this->host.'/api/v4/user', [
|
|
RequestOptions::HEADERS => ['Authorization' => 'Bearer '.$token],
|
|
]);
|
|
|
|
return json_decode((string) $response->getBody(), true);
|
|
}
|
|
}
|