diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 51048ac85a7fb..5d0db624825b9 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -172,15 +172,15 @@ $callbacktodel .= '/core/modules/oauth/google_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); } elseif ($label == 'OAUTH_GITHUB') { $callbacktodel .= '/core/modules/oauth/github_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); - } elseif ($label == 'OAUTH_STRIPE_LIVE') { + } elseif ($label == 'OAUTH_STRIPELIVE') { $callbacktodel .= '/core/modules/oauth/stripelive_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); - } elseif ($label == 'OAUTH_STRIPE_TEST') { + } elseif ($label == 'OAUTH_STRIPETEST') { $callbacktodel .= '/core/modules/oauth/stripetest_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); } elseif ($label == 'OAUTH_MICROSOFT') { $callbacktodel .= '/core/modules/oauth/microsoft_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); } elseif ($label == 'OAUTH_MICROSOFT2') { $callbacktodel .= '/core/modules/oauth/microsoft2_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); - } elseif ($label == 'OAUTH_OTHER') { + } elseif ($label == 'OAUTH_GENERIC') { $callbacktodel .= '/core/modules/oauth/generic_oauthcallback.php?action=delete&keyforprovider='.$provider.'&token='.newToken().'&backtourl='.urlencode($backtourl); } header("Location: ".$callbacktodel); @@ -238,9 +238,11 @@ print ''.$langs->trans("ListOfSupportedOauthProviders").'

'; +$list = getAllOauth2Array(); + + print ''; @@ -413,7 +415,7 @@ // TODO Move this into token generation ? if ($supported) { - if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { + if ($keyforsupportedoauth2array == 'OAUTH_GENERIC_NAME') { print ''; print ''.$langs->trans("Scopes").''; print ''; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index fdd7f86e0b383..1d80659c1765d 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -179,8 +179,9 @@ $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; - - $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : '')); + $nameofservice = ucfirst(strtolower(empty($supportedoauth2array[$keyforsupportedoauth2array]['callbackfile']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'])); + $nameofservice .= ($keyforprovider ? '-'.$keyforprovider : ''); + $OAUTH_SERVICENAME = $nameofservice; $shortscope = ''; if (getDolGlobalString($key[4])) { diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index 0131a05d32c5b..31c9c9a45e9ec 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -33,238 +33,238 @@ function getAllOauth2Array() { $list = array( - array( - 'OAUTH_AMAZON_NAME', - 'OAUTH_AMAZON_ID', - 'OAUTH_AMAZON_SECRET', - ), - array( - 'OAUTH_BITBUCKET_NAME', - 'OAUTH_BITBUCKET_ID', - 'OAUTH_BITBUCKET_SECRET', - ), - array( - 'OAUTH_BITLY_NAME', - 'OAUTH_BITLY_ID', - 'OAUTH_BITLY_SECRET', - ), - array( - 'OAUTH_BITRIX24_NAME', - 'OAUTH_BITRIX24_ID', - 'OAUTH_BITRIX24_SECRET', - ), - array( - 'OAUTH_BOX_NAME', - 'OAUTH_BOX_ID', - 'OAUTH_BOX_SECRET', - ), - array( - 'OAUTH_BUFFER_NAME', - 'OAUTH_BUFFER_ID', - 'OAUTH_BUFFER_SECRET', - ), - array( - 'OAUTH_DAILYMOTION_NAME', - 'OAUTH_DAILYMOTION_ID', - 'OAUTH_DAILYMOTION_SECRET', - ), - array( - 'OAUTH_DEVIANTART_NAME', - 'OAUTH_DEVIANTART_ID', - 'OAUTH_DEVIANTART_SECRET', - ), - array( - 'OAUTH_DROPBOX_NAME', - 'OAUTH_DROPBOX_ID', - 'OAUTH_DROPBOX_SECRET', - ), - array( - 'OAUTH_ETSY_NAME', - 'OAUTH_ETSY_ID', - 'OAUTH_ETSY_SECRET', - ), - array( - 'OAUTH_EVEONLINE_NAME', - 'OAUTH_EVEONLINE_ID', - 'OAUTH_EVEONLINE_SECRET', - ), - array( - 'OAUTH_FACEBOOK_NAME', - 'OAUTH_FACEBOOK_ID', - 'OAUTH_FACEBOOK_SECRET', - ), - array( - 'OAUTH_FITBIT_NAME', - 'OAUTH_FITBIT_ID', - 'OAUTH_FITBIT_SECRET', - ), - array( - 'OAUTH_FIVEHUNDREDPX_NAME', - 'OAUTH_FIVEHUNDREDPX_ID', - 'OAUTH_FIVEHUNDREDPX_SECRET', - ), - array( - 'OAUTH_FLICKR_NAME', - 'OAUTH_FLICKR_ID', - 'OAUTH_FLICKR_SECRET', - ), - array( - 'OAUTH_FOURSQUARE_NAME', - 'OAUTH_FOURSQUARE_ID', - 'OAUTH_FOURSQUARE_SECRET', - ), - array( - 'OAUTH_GITHUB_NAME', - 'OAUTH_GITHUB_ID', - 'OAUTH_GITHUB_SECRET', - 'OAUTH_GITHUB_DESC', - ), - array( - 'OAUTH_GOOGLE_NAME', - 'OAUTH_GOOGLE_ID', - 'OAUTH_GOOGLE_SECRET', - 'OAUTH_GOOGLE_DESC', - ), - array( - 'OAUTH_HUBIC_NAME', - 'OAUTH_HUBIC_ID', - 'OAUTH_HUBIC_SECRET', - ), - array( - 'OAUTH_INSTAGRAM_NAME', - 'OAUTH_INSTAGRAM_ID', - 'OAUTH_INSTAGRAM_SECRET', - ), - array( - 'OAUTH_LINKEDIN_NAME', - 'OAUTH_LINKEDIN_ID', - 'OAUTH_LINKEDIN_SECRET', - ), - array( - 'OAUTH_MAILCHIMP_NAME', - 'OAUTH_MAILCHIMP_ID', - 'OAUTH_MAILCHIMP_SECRET', - ), - array( - 'OAUTH_MICROSOFT_NAME', - 'OAUTH_MICROSOFT_ID', - 'OAUTH_MICROSOFT_SECRET', - ), - array( - 'OAUTH_MICROSOFT2_NAME', - 'OAUTH_MICROSOFT2_ID', - 'OAUTH_MICROSOFT2_SECRET', - ), - array( - 'OAUTH_NEST_NAME', - 'OAUTH_NEST_ID', - 'OAUTH_NEST_SECRET', - ), - array( - 'OAUTH_NETATMO_NAME', - 'OAUTH_NETATMO_ID', - 'OAUTH_NETATMO_SECRET', - ), - array( - 'OAUTH_PARROTFLOWERPOWER_NAME', - 'OAUTH_PARROTFLOWERPOWER_ID', - 'OAUTH_PARROTFLOWERPOWER_SECRET', - ), - array( - 'OAUTH_PAYPAL_NAME', - 'OAUTH_PAYPAL_ID', - 'OAUTH_PAYPAL_SECRET', - ), - array( - 'OAUTH_POCKET_NAME', - 'OAUTH_POCKET_ID', - 'OAUTH_POCKET_SECRET', - ), - array( - 'OAUTH_QUICKBOOKS_NAME', - 'OAUTH_QUICKBOOKS_ID', - 'OAUTH_QUICKBOOKS_SECRET', - ), - array( - 'OAUTH_REDDIT_NAME', - 'OAUTH_REDDIT_ID', - 'OAUTH_REDDIT_SECRET', - ), - array( - 'OAUTH_REDMINE_NAME', - 'OAUTH_REDMINE_ID', - 'OAUTH_REDMINE_SECRET', - ), - array( - 'OAUTH_RUNKEEPER_NAME', - 'OAUTH_RUNKEEPER_ID', - 'OAUTH_RUNKEEPER_SECRET', - ), - array( - 'OAUTH_SCOOPIT_NAME', - 'OAUTH_SCOOPIT_ID', - 'OAUTH_SCOOPIT_SECRET', - ), - array( - 'OAUTH_SOUNDCLOUD_NAME', - 'OAUTH_SOUNDCLOUD_ID', - 'OAUTH_SOUNDCLOUD_SECRET', - ), - array( - 'OAUTH_SPOTIFY_NAME', - 'OAUTH_SPOTIFY_ID', - 'OAUTH_SPOTIFY_SECRET', - ), - array( - 'OAUTH_STRAVA_NAME', - 'OAUTH_STRAVA_ID', - 'OAUTH_STRAVA_SECRET', - ), - array( - 'OAUTH_STRIPE_TEST_NAME', - 'OAUTH_STRIPE_TEST_ID', - 'STRIPE_TEST_SECRET_KEY', - ), - array( - 'OAUTH_STRIPE_LIVE_NAME', - 'OAUTH_STRIPE_LIVE_ID', - 'STRIPE_LIVE_SECRET_KEY', - ), - array( - 'OAUTH_TUMBLR_NAME', - 'OAUTH_TUMBLR_ID', - 'OAUTH_TUMBLR_SECRET', - ), - array( - 'OAUTH_TWITTER_NAME', - 'OAUTH_TWITTER_ID', - 'OAUTH_TWITTER_SECRET', - ), - array( - 'OAUTH_USTREAM_NAME', - 'OAUTH_USTREAM_ID', - 'OAUTH_USTREAM_SECRET', - ), - array( - 'OAUTH_VIMEO_NAME', - 'OAUTH_VIMEO_ID', - 'OAUTH_VIMEO_SECRET', - ), - array( - 'OAUTH_YAHOO_NAME', - 'OAUTH_YAHOO_ID', - 'OAUTH_YAHOO_SECRET', - ), - array( - 'OAUTH_YAMMER_NAME', - 'OAUTH_YAMMER_ID', - 'OAUTH_YAMMER_SECRET', - ), - array( - 'OAUTH_OTHER_NAME', - 'OAUTH_OTHER_ID', - 'OAUTH_OTHER_SECRET', - ) + array( + 'OAUTH_AMAZON_NAME', + 'OAUTH_AMAZON_ID', + 'OAUTH_AMAZON_SECRET', + ), + array( + 'OAUTH_BITBUCKET_NAME', + 'OAUTH_BITBUCKET_ID', + 'OAUTH_BITBUCKET_SECRET', + ), + array( + 'OAUTH_BITLY_NAME', + 'OAUTH_BITLY_ID', + 'OAUTH_BITLY_SECRET', + ), + array( + 'OAUTH_BITRIX24_NAME', + 'OAUTH_BITRIX24_ID', + 'OAUTH_BITRIX24_SECRET', + ), + array( + 'OAUTH_BOX_NAME', + 'OAUTH_BOX_ID', + 'OAUTH_BOX_SECRET', + ), + array( + 'OAUTH_BUFFER_NAME', + 'OAUTH_BUFFER_ID', + 'OAUTH_BUFFER_SECRET', + ), + array( + 'OAUTH_DAILYMOTION_NAME', + 'OAUTH_DAILYMOTION_ID', + 'OAUTH_DAILYMOTION_SECRET', + ), + array( + 'OAUTH_DEVIANTART_NAME', + 'OAUTH_DEVIANTART_ID', + 'OAUTH_DEVIANTART_SECRET', + ), + array( + 'OAUTH_DROPBOX_NAME', + 'OAUTH_DROPBOX_ID', + 'OAUTH_DROPBOX_SECRET', + ), + array( + 'OAUTH_ETSY_NAME', + 'OAUTH_ETSY_ID', + 'OAUTH_ETSY_SECRET', + ), + array( + 'OAUTH_EVEONLINE_NAME', + 'OAUTH_EVEONLINE_ID', + 'OAUTH_EVEONLINE_SECRET', + ), + array( + 'OAUTH_FACEBOOK_NAME', + 'OAUTH_FACEBOOK_ID', + 'OAUTH_FACEBOOK_SECRET', + ), + array( + 'OAUTH_FITBIT_NAME', + 'OAUTH_FITBIT_ID', + 'OAUTH_FITBIT_SECRET', + ), + array( + 'OAUTH_FIVEHUNDREDPX_NAME', + 'OAUTH_FIVEHUNDREDPX_ID', + 'OAUTH_FIVEHUNDREDPX_SECRET', + ), + array( + 'OAUTH_FLICKR_NAME', + 'OAUTH_FLICKR_ID', + 'OAUTH_FLICKR_SECRET', + ), + array( + 'OAUTH_FOURSQUARE_NAME', + 'OAUTH_FOURSQUARE_ID', + 'OAUTH_FOURSQUARE_SECRET', + ), + array( + 'OAUTH_GITHUB_NAME', + 'OAUTH_GITHUB_ID', + 'OAUTH_GITHUB_SECRET', + 'OAUTH_GITHUB_DESC', + ), + array( + 'OAUTH_GOOGLE_NAME', + 'OAUTH_GOOGLE_ID', + 'OAUTH_GOOGLE_SECRET', + 'OAUTH_GOOGLE_DESC', + ), + array( + 'OAUTH_HUBIC_NAME', + 'OAUTH_HUBIC_ID', + 'OAUTH_HUBIC_SECRET', + ), + array( + 'OAUTH_INSTAGRAM_NAME', + 'OAUTH_INSTAGRAM_ID', + 'OAUTH_INSTAGRAM_SECRET', + ), + array( + 'OAUTH_LINKEDIN_NAME', + 'OAUTH_LINKEDIN_ID', + 'OAUTH_LINKEDIN_SECRET', + ), + array( + 'OAUTH_MAILCHIMP_NAME', + 'OAUTH_MAILCHIMP_ID', + 'OAUTH_MAILCHIMP_SECRET', + ), + array( + 'OAUTH_MICROSOFT_NAME', + 'OAUTH_MICROSOFT_ID', + 'OAUTH_MICROSOFT_SECRET', + ), + array( + 'OAUTH_MICROSOFT2_NAME', + 'OAUTH_MICROSOFT2_ID', + 'OAUTH_MICROSOFT2_SECRET', + ), + array( + 'OAUTH_NEST_NAME', + 'OAUTH_NEST_ID', + 'OAUTH_NEST_SECRET', + ), + array( + 'OAUTH_NETATMO_NAME', + 'OAUTH_NETATMO_ID', + 'OAUTH_NETATMO_SECRET', + ), + array( + 'OAUTH_PARROTFLOWERPOWER_NAME', + 'OAUTH_PARROTFLOWERPOWER_ID', + 'OAUTH_PARROTFLOWERPOWER_SECRET', + ), + array( + 'OAUTH_PAYPAL_NAME', + 'OAUTH_PAYPAL_ID', + 'OAUTH_PAYPAL_SECRET', + ), + array( + 'OAUTH_POCKET_NAME', + 'OAUTH_POCKET_ID', + 'OAUTH_POCKET_SECRET', + ), + array( + 'OAUTH_QUICKBOOKS_NAME', + 'OAUTH_QUICKBOOKS_ID', + 'OAUTH_QUICKBOOKS_SECRET', + ), + array( + 'OAUTH_REDDIT_NAME', + 'OAUTH_REDDIT_ID', + 'OAUTH_REDDIT_SECRET', + ), + array( + 'OAUTH_REDMINE_NAME', + 'OAUTH_REDMINE_ID', + 'OAUTH_REDMINE_SECRET', + ), + array( + 'OAUTH_RUNKEEPER_NAME', + 'OAUTH_RUNKEEPER_ID', + 'OAUTH_RUNKEEPER_SECRET', + ), + array( + 'OAUTH_SCOOPIT_NAME', + 'OAUTH_SCOOPIT_ID', + 'OAUTH_SCOOPIT_SECRET', + ), + array( + 'OAUTH_SOUNDCLOUD_NAME', + 'OAUTH_SOUNDCLOUD_ID', + 'OAUTH_SOUNDCLOUD_SECRET', + ), + array( + 'OAUTH_SPOTIFY_NAME', + 'OAUTH_SPOTIFY_ID', + 'OAUTH_SPOTIFY_SECRET', + ), + array( + 'OAUTH_STRAVA_NAME', + 'OAUTH_STRAVA_ID', + 'OAUTH_STRAVA_SECRET', + ), + array( + 'OAUTH_STRIPETEST_NAME', + 'OAUTH_STRIPETEST_ID', + 'OAUTH_STRIPETEST_SECRET_KEY', + ), + array( + 'OAUTH_STRIPELIVE_NAME', + 'OAUTH_STRIPELIVE_ID', + 'OAUTH_STRIPELIVE_SECRET_KEY', + ), + array( + 'OAUTH_TUMBLR_NAME', + 'OAUTH_TUMBLR_ID', + 'OAUTH_TUMBLR_SECRET', + ), + array( + 'OAUTH_TWITTER_NAME', + 'OAUTH_TWITTER_ID', + 'OAUTH_TWITTER_SECRET', + ), + array( + 'OAUTH_USTREAM_NAME', + 'OAUTH_USTREAM_ID', + 'OAUTH_USTREAM_SECRET', + ), + array( + 'OAUTH_VIMEO_NAME', + 'OAUTH_VIMEO_ID', + 'OAUTH_VIMEO_SECRET', + ), + array( + 'OAUTH_YAHOO_NAME', + 'OAUTH_YAHOO_ID', + 'OAUTH_YAHOO_SECRET', + ), + array( + 'OAUTH_YAMMER_NAME', + 'OAUTH_YAMMER_ID', + 'OAUTH_YAMMER_SECRET', + ), + array( + 'OAUTH_GENERIC_NAME', + 'OAUTH_GENERIC_ID', + 'OAUTH_GENERIC_SECRET', + ) ); return $list; @@ -291,7 +291,7 @@ function getSupportedOauth2Array() ), ); if (isModEnabled('stripe')) { - $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array( + $supportedoauth2array['OAUTH_STRIPETEST_NAME'] = array( 'callbackfile' => 'stripetest', 'picto' => 'stripe', 'urlforapp' => '', @@ -300,7 +300,7 @@ function getSupportedOauth2Array() 'availablescopes' => 'read_write', 'returnurl' => '/core/modules/oauth/stripetest_oauthcallback.php' ); - $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array( + $supportedoauth2array['OAUTH_STRIPELIVE_NAME'] = array( 'callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', @@ -341,10 +341,10 @@ function getSupportedOauth2Array() 'returnurl' => '/core/modules/oauth/microsoft_oauthcallback.php' ); if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { - $supportedoauth2array['OAUTH_OTHER_NAME'] = array( + $supportedoauth2array['OAUTH_GENERIC_NAME'] = array( 'callbackfile' => 'generic', 'picto' => 'generic', - 'urlforapp' => 'OAUTH_OTHER_DESC', + 'urlforapp' => 'OAUTH_GENERIC_DESC', 'name' => 'Other', 'urlforcredentials' => '', 'availablescopes' => 'Standard', diff --git a/htdocs/core/modules/oauth/generic_oauthcallback.php b/htdocs/core/modules/oauth/generic_oauthcallback.php index b2c75f381b4f9..c8bf1951f4ca7 100644 --- a/htdocs/core/modules/oauth/generic_oauthcallback.php +++ b/htdocs/core/modules/oauth/generic_oauthcallback.php @@ -40,7 +40,7 @@ if (empty($keyforprovider) && !empty($_SESSION["oauthkeyforproviderbeforeoauthjump"]) && (GETPOST('code') || $action == 'delete')) { $keyforprovider = $_SESSION["oauthkeyforproviderbeforeoauthjump"]; } -$genericstring = 'OTHER'; +$genericstring = 'GENERIC'; /** @@ -138,7 +138,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); // This was a callback request from service, get the token try { diff --git a/htdocs/core/modules/oauth/github_oauthcallback.php b/htdocs/core/modules/oauth/github_oauthcallback.php index 23f9be9272411..07153e9de326e 100644 --- a/htdocs/core/modules/oauth/github_oauthcallback.php +++ b/htdocs/core/modules/oauth/github_oauthcallback.php @@ -118,7 +118,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); // This was a callback request from service, get the token try { diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 2b6d484c51ace..7e9288af27e15 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -219,7 +219,7 @@ exit(); } else { // We are coming from the return of an OAuth2 provider page. - dol_syslog("We are coming from the oauth provider page keyforprovider=".$keyforprovider." code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page keyforprovider=".$keyforprovider." code=".dol_trunc(GETPOST('code'), 5)); // We must validate that the $state is the same than the one into $_SESSION['oauthstateanticsrf'], return error if not. if (isset($_SESSION['oauthstateanticsrf']) && $state != $_SESSION['oauthstateanticsrf']) { diff --git a/htdocs/core/modules/oauth/microsoft2_oauthcallback.php b/htdocs/core/modules/oauth/microsoft2_oauthcallback.php index 6ee6ca64430ca..fc5090364bee6 100644 --- a/htdocs/core/modules/oauth/microsoft2_oauthcallback.php +++ b/htdocs/core/modules/oauth/microsoft2_oauthcallback.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/modules/oauth/microsoft_oauthcallback.php + * \file htdocs/core/modules/oauth/microsoft2_oauthcallback.php * \ingroup oauth * \brief Page to get oauth callback */ @@ -49,7 +49,7 @@ $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); //$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); //$currentUri->setQuery(''); -$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/microsoft_oauthcallback.php'); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/microsoft2_oauthcallback.php'); /** @@ -94,7 +94,8 @@ // $requestedpermissionsarray contains list of scopes. // Conversion into URL is done by Reflection on constant with name SCOPE_scope_in_uppercase try { - $apiService = $serviceFactory->createService(ucfirst(strtolower($genericstring)), $credentials, $storage, $requestedpermissionsarray); + $nameofservice = ucfirst(strtolower($genericstring)); + $apiService = $serviceFactory->createService($nameofservice, $credentials, $storage, $requestedpermissionsarray); } catch (Exception $e) { print $e->getMessage(); exit; @@ -122,6 +123,9 @@ if (!getDolGlobalString($keyforparamsecret)) { accessforbidden('Setup of service is not complete. Secret key is missing'); } +if (!getDolGlobalString($keyforparamtenant)) { + accessforbidden('Setup of service is not complete. Tenant/Annuary ID key is missing'); +} /* @@ -148,7 +152,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); // This was a callback request from service, get the token try { diff --git a/htdocs/core/modules/oauth/microsoft_oauthcallback.php b/htdocs/core/modules/oauth/microsoft_oauthcallback.php index c8cd593bf078c..53df4f9653a6e 100644 --- a/htdocs/core/modules/oauth/microsoft_oauthcallback.php +++ b/htdocs/core/modules/oauth/microsoft_oauthcallback.php @@ -42,7 +42,6 @@ } $genericstring = 'MICROSOFT'; - /** * Create a new instance of the URI class with the current URI, stripping the query string */ @@ -94,7 +93,8 @@ // $requestedpermissionsarray contains list of scopes. // Conversion into URL is done by Reflection on constant with name SCOPE_scope_in_uppercase try { - $apiService = $serviceFactory->createService(ucfirst(strtolower($genericstring)), $credentials, $storage, $requestedpermissionsarray); + $nameofservice = ucfirst(strtolower($genericstring)); + $apiService = $serviceFactory->createService($nameofservice, $credentials, $storage, $requestedpermissionsarray); } catch (Exception $e) { print $e->getMessage(); exit; @@ -122,6 +122,9 @@ if (!getDolGlobalString($keyforparamsecret)) { accessforbidden('Setup of service is not complete. Secret key is missing'); } +if (!getDolGlobalString($keyforparamtenant)) { + accessforbidden('Setup of service is not complete. Tenant/Annuary ID key is missing'); +} /* @@ -148,7 +151,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)." error=".GETPOST('error')); // This was a callback request from service, get the token try { diff --git a/htdocs/core/modules/oauth/stripelive_oauthcallback.php b/htdocs/core/modules/oauth/stripelive_oauthcallback.php index 3fde132ea258f..f8cf42ab46ad5 100644 --- a/htdocs/core/modules/oauth/stripelive_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripelive_oauthcallback.php @@ -67,8 +67,8 @@ $storage = new DoliStorage($db, $conf, $keyforprovider); // Setup the credentials for the requests -$keyforparamid = 'OAUTH_STRIPE_LIVE'.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; -$keyforparamsecret = 'OAUTH_STRIPE_LIVE'.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; +$keyforparamid = 'OAUTH_STRIPELIVE'.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; +$keyforparamsecret = 'OAUTH_STRIPELIVE'.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; $credentials = new Credentials( getDolGlobalString($keyforparamid), getDolGlobalString($keyforparamsecret), @@ -128,7 +128,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); // This was a callback request from service, get the token try { diff --git a/htdocs/core/modules/oauth/stripetest_oauthcallback.php b/htdocs/core/modules/oauth/stripetest_oauthcallback.php index a9f50b95fc4fd..6189de2e25547 100644 --- a/htdocs/core/modules/oauth/stripetest_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripetest_oauthcallback.php @@ -67,8 +67,8 @@ $storage = new DoliStorage($db, $conf, $keyforprovider); // Setup the credentials for the requests -$keyforparamid = 'OAUTH_STRIPE_TEST'.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; -$keyforparamsecret = 'OAUTH_STRIPE_TEST'.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; +$keyforparamid = 'OAUTH_STRIPETEST'.($keyforprovider ? '-'.$keyforprovider : '').'_ID'; +$keyforparamsecret = 'OAUTH_STRIPETEST'.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET'; $credentials = new Credentials( getDolGlobalString($keyforparamid), getDolGlobalString($keyforparamsecret), @@ -124,7 +124,7 @@ // We should have //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16)) - dol_syslog("We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); + dol_syslog(basename(__FILE__)." We are coming from the oauth provider page code=".dol_trunc(GETPOST('code'), 5)); // This was a callback request from service, get the token try {