* Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/openid_connect.php * \ingroup openid_connect * \brief Page to setup openid_connect module */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/openid_connect.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/openid_connect.lib.php'; /** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Translate $langs * @var User $user */ $langs->loadLangs(array("users", "admin", "other")); if (!$user->admin) { accessforbidden(); } $action = GETPOST('action', 'alpha'); /* * Actions */ $errors = []; $error = 0; if ($action == 'set') { $client_id = GETPOST('MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM', 'alpha'); $res = dolibarr_set_const($db, 'MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM', $client_id, 'chaine', 0, '', 0); if (!$res > 0) { $errors[] = $db->lasterror(); $error++; } $client_id = GETPOST('MAIN_AUTHENTICATION_OIDC_CLIENT_ID', 'alpha'); $res = dolibarr_set_const($db, 'MAIN_AUTHENTICATION_OIDC_CLIENT_ID', $client_id, 'chaine', 0, '', 0); if (!$res > 0) { $errors[] = $db->lasterror(); $error++; } $client_secret = GETPOST('MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET', 'alpha'); $res = dolibarr_set_const($db, 'MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET', $client_secret, 'chaine', 0, '', 0); if (!$res > 0) { $errors[] = $db->lasterror(); $error++; } $scopes = GETPOST('MAIN_AUTHENTICATION_OIDC_SCOPES', 'alpha'); $res = dolibarr_set_const($db, 'MAIN_AUTHENTICATION_OIDC_SCOPES', $scopes, 'chaine', 0, '', 0); if (!$res > 0) { $errors[] = $db->lasterror(); $error++; } $authorize_url = GETPOST('MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL', 'alpha'); $res = dolibarr_set_const($db, 'MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL', $authorize_url, 'chaine', 0, '', 0); if (!$res > 0) { $errors[] = $db->lasterror(); $error++; } $value = GETPOST('MAIN_AUTHENTICATION_OIDC_TOKEN_URL', 'alpha'); $res = dolibarr_set_const($db, 'MAIN_AUTHENTICATION_OIDC_TOKEN_URL', $value, 'chaine', 0, '', 0); if (!$res > 0) { $errors[] = $db->lasterror(); $error++; } $value = GETPOST('MAIN_AUTHENTICATION_OIDC_USERINFO_URL', 'alpha'); $res = dolibarr_set_const($db, 'MAIN_AUTHENTICATION_OIDC_USERINFO_URL', $value, 'chaine', 0, '', 0); if (!$res > 0) { $errors[] = $db->lasterror(); $error++; } $logout_url = GETPOST('MAIN_AUTHENTICATION_OIDC_LOGOUT_URL', 'alpha'); $res = dolibarr_set_const($db, 'MAIN_AUTHENTICATION_OIDC_LOGOUT_URL', $logout_url, 'chaine', 0, '', 0); if (!$res > 0) { $errors[] = $db->lasterror(); $error++; } } if ($action != '') { if (!$error) { setEventMessage($langs->trans("SetupSaved")); header("Location: " . $_SERVER["PHP_SELF"]); exit; } else { setEventMessages('', $errors, 'errors'); } } /* * View */ $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; llxHeader('', $langs->trans("Miscellaneous"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-security_other'); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); print ''.$langs->trans("OpenIDDesc")."
\n"; print "
\n"; $head = security_prepare_head(); print dol_get_fiche_head($head, 'openid', '', -1); print $langs->trans("SeeWikiDocForHelpInSetupOpenIDCOnnect"); print ' - '; print img_picto('', 'url', 'class="pictofixedwidth"').''; print $langs->trans("SeeHere"); print ''; print dol_get_fiche_end(); print '
'; print ''; print ''; print '
'; print ''; print ''; print ''."\n"; print ''."\n"; print ''."\n"; print "\n"; // MAIN_AUTHENTICATION_OIDC_LOGIN_CLAIM print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // MAIN_AUTHENTICATION_OIDC_CLIENT_ID print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // MAIN_AUTHENTICATION_OIDC_CLIENT_SECRET print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // MAIN_AUTHENTICATION_OIDC_SCOPES print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // MAIN_AUTHENTICATION_OIDC_TOKEN_URL print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // MAIN_AUTHENTICATION_OIDC_USERINFO_URL print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // MAIN_AUTHENTICATION_OIDC_LOGOUT_URL print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // REDIRECT_URL print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; // LOGOUT_URL print '' . "\n"; print ''."\n"; print ''."\n"; print ''; print '' . "\n"; print '
'.$langs->trans("Parameters").'
'.$langs->trans("MainAuthenticationOidcLoginClaimName").''.$langs->trans("MainAuthenticationOidcLoginClaimDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcClientIdName").''.$langs->trans("MainAuthenticationOidcClientIdDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcClientSecretName").''.$langs->trans("MainAuthenticationOidcClientSecretDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcScopesName").''.$langs->trans("MainAuthenticationOidcScopesDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcAuthorizeUrlName").''.$langs->trans("MainAuthenticationOidcAuthorizeUrlDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcTokenUrlName").''.$langs->trans("MainAuthenticationOidcTokenUrlDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcUserinfoUrlName").''.$langs->trans("MainAuthenticationOidcUserinfoUrlDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcLogoutUrlName").''.$langs->trans("MainAuthenticationOidcLogoutUrlDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcRedirectUrlName").''.$langs->trans("MainAuthenticationOidcRedirectUrlDesc").'' . "\n"; print '
'.$langs->trans("MainAuthenticationOidcLogoutRedirectUrlName").''.$langs->trans("MainAuthenticationOidcLogoutRedirectUrlDesc").'' . "\n"; print '
'."\n"; print '
'; print '
'; print '
'; print ''; print '
'; print '
'; print '
'; llxFooter(); $db->close();