dolibarr 21.0.0-alpha
openid_connect.lib.php
1<?php
2/* Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
30function openid_connect_prepare_head()
31{
32 global $langs, $conf, $user;
33 $h = 0;
34 $head = array();
35
36 $head[$h][0] = dol_buildpath("/admin/openid_connect.php", 1);
37 $head[$h][1] = $langs->trans("Parameters");
38 $head[$h][2] = 'settings';
39 $h++;
40
41 complete_head_from_modules($conf, $langs, null, $head, $h, 'openid_connect_admin');
42
43 return $head;
44}
45
46
52function openid_connect_get_state()
53{
54 return hash('sha256', session_id());
55}
56
57
63function openid_connect_get_redirect_url()
64{
65 return DOL_MAIN_URL_ROOT . '/core/modules/openid_connect/callback.php';
66}
67
68
74function openid_connect_get_url()
75{
76 return getDolGlobalString('MAIN_AUTHENTICATION_OIDC_AUTHORIZE_URL') . '?client_id=' . getDolGlobalString('MAIN_AUTHENTICATION_OIDC_CLIENT_ID') . '&redirect_uri=' . openid_connect_get_redirect_url() . '&scope=' . getDolGlobalString('MAIN_AUTHENTICATION_OIDC_SCOPES') . '&response_type=code&state=' . openid_connect_get_state();
77}
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.