Skip to content

Commit

Permalink
FIX OAuth generation of token for Microsoft, Stripe and Generic
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 1, 2024
1 parent 075d0de commit 83cf2c8
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 261 deletions.
14 changes: 8 additions & 6 deletions htdocs/admin/oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -238,9 +238,11 @@
print '<span class="opacitymedium">'.$langs->trans("ListOfSupportedOauthProviders").'</span><br><br>';


$list = getAllOauth2Array();


print '<select name="provider" id="provider" class="minwidth150">';
print '<option name="-1" value="-1">'.$langs->trans("OAuthProvider").'</option>';
$list = getAllOauth2Array();
// TODO Make a loop directly on getSupportedOauth2Array() and remove getAllOauth2Array()
foreach ($list as $key) {
$supported = 0;
Expand Down Expand Up @@ -368,7 +370,7 @@
print '<td></td>';
print '</tr>';

if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
if ($keyforsupportedoauth2array == 'OAUTH_GENERIC_NAME') {
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("URLOfServiceForAuthorization").'</td>';
print '<td><input style="width: 80%" type="text" name="'.$key[3].'" value="'.getDolGlobalString($key[3]).'" >';
Expand Down Expand Up @@ -413,7 +415,7 @@

// TODO Move this into token generation ?
if ($supported) {
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
if ($keyforsupportedoauth2array == 'OAUTH_GENERIC_NAME') {
print '<tr class="oddeven value">';
print '<td>'.$langs->trans("Scopes").'</td>';
print '<td>';
Expand Down
5 changes: 3 additions & 2 deletions htdocs/admin/oauthlogintokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
Loading

0 comments on commit 83cf2c8

Please sign in to comment.