HEX
Server: Apache
System: Linux server1.ariadata.co 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: nepi (1051)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,show_source,popen,proc_open
Upload Files
File: /home/nepi/public_html/src/core/Directus/Authentication/Sso/TwoSocialProvider.php
<?php

namespace Directus\Authentication\Sso;

use Directus\Util\ArrayUtils;
use League\OAuth2\Client\Token\AccessToken;

abstract class TwoSocialProvider extends AbstractSocialProvider
{
    /**
     * @inheritDoc
     */
    public function getRequestAuthorizationUrl()
    {
        $options = [
            'scope' => $this->getScopes()
        ];

        return $this->provider->getAuthorizationUrl($options);
    }

    /**
     * @inheritDoc
     */
    public function request()
    {
        $requestUrl = $this->getRequestAuthorizationUrl();

        header('Location: ' . $requestUrl);
    }

    /**
     * @inheritdoc
     */
    public function handle()
    {
        return $this->getUserFromCode([
            'code' => ArrayUtils::get($_GET, 'code')
        ]);
    }

    /**
     * @inheritdoc
     */
    public function getUserFromCode(array $data)
    {
        // Try to get an access token (using the authorization code grant)
        $token = $this->provider->getAccessToken('authorization_code', [
            'code' => ArrayUtils::get($data, 'code')
        ]);

        return new SocialUser([
            'email' => $this->getResourceOwnerEmail($token)
        ]);
    }

    /**
     * Gets the resource owner email
     *
     * @param AccessToken $token
     *
     * @return string
     */
    protected function getResourceOwnerEmail(AccessToken $token)
    {
        $user = $this->provider->getResourceOwner($token);

        return $user->getEmail();
    }

    /**
     * Get the list of scopes for the current service
     *
     * @return array
     */
    abstract public function getScopes();
}