Fix: We must use external URL for OAuth.
This commit is contained in:
parent
1bcda200e3
commit
cd68ea9d0f
@ -294,7 +294,14 @@ print '<input type="hidden" name="action" value="update">';
|
||||
/*
|
||||
* Parameters
|
||||
*/
|
||||
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
||||
dol_fiche_head(array(), '', '', 0, 'technic');
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -307,6 +314,24 @@ foreach ($list as $key)
|
||||
$label = $langs->trans($key[0]);
|
||||
print '<td colspan="2">'.$label.'</td></tr>';
|
||||
|
||||
if (in_array($key[0], array('OAUTH_GOOGLE_NAME')))
|
||||
{
|
||||
$redirect_uri=$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php';
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].' class="value">';
|
||||
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
|
||||
print '<td><textarea style="width: 80%">'.$redirect_uri.'</textarea>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].' class="value">';
|
||||
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
|
||||
print '<td>'.$langs->trans("FeatureNotYetSupported").'</td>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Api Id
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].' class="value">';
|
||||
|
||||
@ -58,8 +58,13 @@ class printing_printgcp extends PrintingDriver
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $dolibarr_main_url_root;
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
$this->db = $db;
|
||||
$this->google_id = $conf->global->OAUTH_GOOGLE_ID;
|
||||
$this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET;
|
||||
@ -70,7 +75,7 @@ class printing_printgcp extends PrintingDriver
|
||||
$credentials = new Credentials(
|
||||
$this->google_id,
|
||||
$this->google_secret,
|
||||
DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php'
|
||||
$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'
|
||||
);
|
||||
$access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken');
|
||||
$serviceFactory = new \OAuth\ServiceFactory();
|
||||
@ -103,6 +108,7 @@ class printing_printgcp extends PrintingDriver
|
||||
if (!$conf->oauth->enabled) {
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'ModuleAuthNotActive', 'type'=>'info');
|
||||
} else {
|
||||
|
||||
if ($this->google_id != '' && $this->google_secret != '') {
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info');
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info');
|
||||
@ -112,7 +118,7 @@ class printing_printgcp extends PrintingDriver
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info');
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(date("Y-m-d H:i:s", $token->getEndOfLife())), 'type'=>'info');
|
||||
}
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink');
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink');
|
||||
} else {
|
||||
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info');
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
# Dolibarr language file - Source file is en_US - oauth
|
||||
ConfigOAuth=Oauth Configuration
|
||||
NoAccessToken=No token access saved.
|
||||
UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credential on your OAuth provider:
|
||||
OAUTH_AMAZON_NAME=Api Amazon
|
||||
OAUTH_AMAZON_ID=Api Amazon Id
|
||||
OAUTH_AMAZON_SECRET=Api Amazon Secret
|
||||
|
||||
@ -81,3 +81,5 @@ STATE_IPP_none=None
|
||||
MEDIA_IPP_stationery=Stationery
|
||||
MEDIA_IPP_thermal=Thermal
|
||||
IPP_COLOR_print-black=BW Printer
|
||||
GoogleAuthNotConfigured=Google OAuth setup not done. Enable module OAuth and set a Google ID/Secret.
|
||||
GoogleAuthConfigured=Google OAuth credentials found.
|
||||
@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/printing/lib/printing.lib.php';
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("printing");
|
||||
$langs->load("oauth");
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
|
||||
@ -178,15 +179,17 @@ if ($mode == 'setup' && $user->admin)
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
if (! empty($driver))
|
||||
{
|
||||
if ($submit_enabled) {
|
||||
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></div>';
|
||||
}
|
||||
}
|
||||
print '</form>';
|
||||
dol_fiche_end();
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
if ($mode == 'config' && $user->admin)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user