mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
a3073a8c5c
|
|
@ -338,7 +338,7 @@ function getSupportedOauth2Array()
|
|||
'urlforcredentials' => 'https://portal.azure.com/',
|
||||
// User.Read is a microsoftgraph scope, if it's not working, do not select it
|
||||
'availablescopes' => 'openid,offline_access,profile,email,User.Read,https://outlook.office.com/.default',
|
||||
'returnurl' => '/core/modules/oauth/microsoft_oauthcallback.php'
|
||||
'returnurl' => '/core/modules/oauth/microsoft2_oauthcallback.php'
|
||||
);
|
||||
|
||||
// Add a generic Oauth token handler. Tested with Mastodon.
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ $genericstring = 'MICROSOFT2';
|
|||
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
|
||||
//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
|
||||
//$currentUri->setQuery('');
|
||||
|
||||
$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/microsoft2_oauthcallback.php');
|
||||
|
||||
|
||||
|
|
@ -65,19 +66,21 @@ $httpClient = new \OAuth\Common\Http\Client\CurlClient();
|
|||
//$httpClient->setCurlParameters($params);
|
||||
$serviceFactory->setHttpClient($httpClient);
|
||||
|
||||
// Dolibarr storage
|
||||
$storage = new DoliStorage($db, $conf, $keyforprovider);
|
||||
|
||||
// Setup the credentials for the requests
|
||||
$keyforparamid = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_ID';
|
||||
$keyforparamsecret = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET';
|
||||
$keyforparamtenant = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_TENANT';
|
||||
|
||||
// Dolibarr storage
|
||||
$storage = new DoliStorage($db, $conf, $keyforprovider, getDolGlobalString($keyforparamtenant));
|
||||
|
||||
$credentials = new Credentials(
|
||||
getDolGlobalString($keyforparamid),
|
||||
getDolGlobalString($keyforparamsecret),
|
||||
$currentUri->getAbsoluteUri()
|
||||
);
|
||||
|
||||
|
||||
$state = GETPOST('state');
|
||||
|
||||
$requestedpermissionsarray = array();
|
||||
|
|
|
|||
|
|
@ -64,13 +64,14 @@ $httpClient = new \OAuth\Common\Http\Client\CurlClient();
|
|||
//$httpClient->setCurlParameters($params);
|
||||
$serviceFactory->setHttpClient($httpClient);
|
||||
|
||||
// Dolibarr storage
|
||||
$storage = new DoliStorage($db, $conf, $keyforprovider);
|
||||
|
||||
// Setup the credentials for the requests
|
||||
$keyforparamid = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_ID';
|
||||
$keyforparamsecret = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET';
|
||||
$keyforparamtenant = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_TENANT';
|
||||
|
||||
// Dolibarr storage
|
||||
$storage = new DoliStorage($db, $conf, $keyforprovider, getDolGlobalString($keyforparamtenant));
|
||||
|
||||
$credentials = new Credentials(
|
||||
getDolGlobalString($keyforparamid),
|
||||
getDolGlobalString($keyforparamsecret),
|
||||
|
|
|
|||
|
|
@ -72,14 +72,16 @@ class DoliStorage implements TokenStorageInterface
|
|||
* @param DoliDB $db Database handler
|
||||
* @param \Conf $notused Conf object (not used as parameter, used with global $conf)
|
||||
* @param string $keyforprovider Key to manage several providers of the same type. For example 'abc' will be added to 'Google' to defined storage key.
|
||||
* @param string $tenant Value of tenant if used
|
||||
*/
|
||||
public function __construct(DoliDB $db, \Conf $notused, $keyforprovider = '')
|
||||
public function __construct(DoliDB $db, \Conf $notused, $keyforprovider = '', $tenant = '')
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->keyforprovider = $keyforprovider;
|
||||
$this->token = '';
|
||||
$this->tokens = array();
|
||||
$this->states = array();
|
||||
$this->tenant = $tenant;
|
||||
//$this->key = $key;
|
||||
//$this->stateKey = $stateKey;
|
||||
}
|
||||
|
|
@ -381,7 +383,7 @@ class DoliStorage implements TokenStorageInterface
|
|||
{
|
||||
// Set/Reset tenant now so it will be defined for.
|
||||
// TODO We must store it into the table llx_oauth_token
|
||||
$this->tenant = getDolGlobalString('OAUTH_MICROSOFT'.($this->keyforprovider ? '-'.$this->keyforprovider : '').'_TENANT');
|
||||
//$this->tenant = getDolGlobalString('OAUTH_MICROSOFT'.($this->keyforprovider ? '-'.$this->keyforprovider : '').'_TENANT');
|
||||
|
||||
return $this->tenant;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use OAuth\Common\Http\Client\ClientInterface;
|
|||
use OAuth\Common\Storage\TokenStorageInterface;
|
||||
use OAuth\Common\Http\Uri\UriInterface;
|
||||
|
||||
class Microsoft extends AbstractService
|
||||
class Microsoft2 extends AbstractService
|
||||
{
|
||||
const SCOPE_BASIC = 'basic';
|
||||
const SCOPE_OFFLINE_ACCESS = 'offline_access';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user