Skip to content

Commit d93fd9d

Browse files
authored
Merge pull request #258 from ursinn/feature/sso/develop
Add missing http proxy support for oidc
2 parents 129f62b + 9e7d14d commit d93fd9d

File tree

7 files changed

+94
-4
lines changed

7 files changed

+94
-4
lines changed

www/controllers/App/Config/Settings.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function get()
3535
/**
3636
* Following parameters can be empty (or equal to 0), we don't increment the error counter in their case
3737
*/
38-
$ignoreEmptyParam = array('EMAIL_RECIPIENT', 'PROXY', 'RPM_DEFAULT_ARCH', 'DEB_DEFAULT_ARCH', 'DEB_DEFAULT_TRANSLATION', 'REPO_CONF_FILES_PREFIX', 'RETENTION', 'OIDC_PROVIDER_URL', 'OIDC_AUTHORIZATION_ENDPOINT', 'OIDC_TOKEN_ENDPOINT', 'OIDC_USERINFO_ENDPOINT', 'OIDC_SCOPES', 'OIDC_CLIENT_ID', 'OIDC_CLIENT_SECRET');
38+
$ignoreEmptyParam = array('EMAIL_RECIPIENT', 'PROXY', 'RPM_DEFAULT_ARCH', 'DEB_DEFAULT_ARCH', 'DEB_DEFAULT_TRANSLATION', 'REPO_CONF_FILES_PREFIX', 'RETENTION', 'OIDC_PROVIDER_URL', 'OIDC_AUTHORIZATION_ENDPOINT', 'OIDC_TOKEN_ENDPOINT', 'OIDC_USERINFO_ENDPOINT', 'OIDC_SCOPES', 'OIDC_CLIENT_ID', 'OIDC_CLIENT_SECRET', 'OIDC_HTTP_PROXY', 'OIDC_CERT_PATH');
3939

4040
if (in_array($key, $ignoreEmptyParam)) {
4141
continue;
@@ -499,6 +499,22 @@ public static function get()
499499
define('OIDC_GROUP_SUPER_ADMINISTRATOR', 'super-administrator');
500500
}
501501
}
502+
503+
if (!defined('OIDC_HTTP_PROXY')) {
504+
if (!empty($settings['OIDC_HTTP_PROXY'])) {
505+
define('OIDC_HTTP_PROXY', $settings['OIDC_HTTP_PROXY']);
506+
} else {
507+
define('OIDC_HTTP_PROXY', '');
508+
}
509+
}
510+
511+
if (!defined('OIDC_CERT_PATH')) {
512+
if (!empty($settings['OIDC_CERT_PATH'])) {
513+
define('OIDC_CERT_PATH', $settings['OIDC_CERT_PATH']);
514+
} else {
515+
define('OIDC_CERT_PATH', '');
516+
}
517+
}
502518
}
503519

504520
if (!defined('__LOAD_SETTINGS_ERROR')) {
@@ -604,6 +620,14 @@ public static function getYaml()
604620
define('OIDC_GROUP_SUPER_ADMINISTRATOR', Common::validateData($appYaml['oidc']['group_super_administrator']));
605621
}
606622

623+
if (!defined('OIDC_HTTP_PROXY') and isset($appYaml['oidc']['http_proxy'])) {
624+
define('OIDC_HTTP_PROXY', Common::validateData($appYaml['oidc']['http_proxy']));
625+
}
626+
627+
if (!defined('OIDC_CERT_PATH') and isset($appYaml['oidc']['cert_path'])) {
628+
define('OIDC_CERT_PATH', Common::validateData($appYaml['oidc']['cert_path']));
629+
}
630+
607631
if (!defined('__LOAD_SETTINGS_YAML_ERROR')) {
608632
define('__LOAD_SETTINGS_YAML_ERROR', $__LOAD_SETTINGS_YAML_ERROR);
609633
}

www/controllers/Settings.php

+10
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,16 @@ public function apply(array $sendSettings) : void
401401
$settingsToApply['OIDC_GROUP_SUPER_ADMINISTRATOR'] = $oidcGroupSuperAdministrator;
402402
}
403403

404+
if (!empty($sendSettings['oidcHttpProxy'])) {
405+
$oidcHttpProxy = Common::validateData($sendSettings['oidcHttpProxy']);
406+
$settingsToApply['OIDC_HTTP_PROXY'] = $oidcHttpProxy;
407+
}
408+
409+
if (!empty($sendSettings['oidcCertPath'])) {
410+
$oidcCertPath = Common::validateData($sendSettings['oidcCertPath']);
411+
$settingsToApply['OIDC_CERT_PATH'] = $oidcCertPath;
412+
}
413+
404414
/**
405415
* Write settings to database
406416
*/

www/controllers/User/Login.php

+14
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,20 @@ public function ssoLogin(): void
149149
$oidc->addScope($scopes);
150150
}
151151

152+
/**
153+
* Use OIDC_HTTP_PROXY as httpProxy if defined
154+
*/
155+
if (!empty(OIDC_HTTP_PROXY)) {
156+
$oidc->setHttpProxy(OIDC_HTTP_PROXY);
157+
}
158+
159+
/**
160+
* Use OIDC_CERT_PATH as certPath if defined
161+
*/
162+
if (!empty(OIDC_CERT_PATH)) {
163+
$oidc->setCertPath(OIDC_CERT_PATH);
164+
}
165+
152166
/**
153167
* Try to authenticate user
154168
*/

www/models/Connection.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,9 @@ private function generateMainTables()
592592
OIDC_EMAIL VARCHAR(255),
593593
OIDC_GROUPS VARCHAR(255),
594594
OIDC_GROUP_ADMINISTRATOR VARCHAR(255),
595-
OIDC_GROUP_SUPER_ADMINISTRATOR VARCHAR(255))");
595+
OIDC_GROUP_SUPER_ADMINISTRATOR VARCHAR(255),
596+
OIDC_HTTP_PROXY VARCHAR(255),
597+
OIDC_CERT_PATH VARCHAR(255))");
596598

597599
/**
598600
* If settings table is empty then populate it
@@ -636,6 +638,8 @@ private function generateMainTables()
636638
$oidcGroups = defined('OIDC_GROUPS') ? OIDC_GROUPS : 'groups';
637639
$oidcGroupAdministrator = defined('OIDC_GROUP_ADMINISTRATOR') ? OIDC_GROUP_ADMINISTRATOR : 'administrator';
638640
$oidcGroupSuperAdministrator = defined('OIDC_GROUP_SUPER_ADMINISTRATOR') ? OIDC_GROUP_SUPER_ADMINISTRATOR : 'super-administrator';
641+
$oidcHttpProxy = defined('OIDC_HTTP_PROXY') ? OIDC_HTTP_PROXY : '';
642+
$oidcCertPath = defined('OIDC_CERT_PATH') ? OIDC_CERT_PATH : '';
639643

640644
$this->exec("INSERT INTO settings (
641645
EMAIL_RECIPIENT,
@@ -682,7 +686,9 @@ private function generateMainTables()
682686
OIDC_EMAIL,
683687
OIDC_GROUPS,
684688
OIDC_GROUP_ADMINISTRATOR,
685-
OIDC_GROUP_SUPER_ADMINISTRATOR
689+
OIDC_GROUP_SUPER_ADMINISTRATOR,
690+
OIDC_HTTP_PROXY,
691+
OIDC_CERT_PATH
686692
)
687693
VALUES (
688694
'',
@@ -729,7 +735,9 @@ private function generateMainTables()
729735
'$oidcEmail',
730736
'$oidcGroups',
731737
'$oidcGroupAdministrator',
732-
'$oidcGroupSuperAdministrator'
738+
'$oidcGroupSuperAdministrator',
739+
'$oidcHttpProxy',
740+
'$oidcCertPath'
733741
)");
734742
}
735743

www/templates/app.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,11 @@ oidc:
6565
# Groups value for Super Administrator
6666
# Default Value: super-administrator
6767
#group_super_administrator: super-administrator
68+
69+
# HTTP Proxy
70+
# Default Value: not set
71+
#http_proxy:
72+
73+
# Path to cert file
74+
# Default Value: not set
75+
#cert_path:

www/update/database/4.x.0.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* 4.x.0 update
4+
*/
5+
6+
/**
7+
* Add 'OIDC_HTTP_PROXY' column to settings table
8+
*/
9+
if (!$this->db->columnExist('settings', 'OIDC_HTTP_PROXY')) {
10+
$this->db->exec("ALTER TABLE settings ADD COLUMN OIDC_HTTP_PROXY VARCHAR(255)");
11+
}
12+
13+
/**
14+
* Add 'OIDC_CERT_PATH' column to settings table
15+
*/
16+
if (!$this->db->columnExist('settings', 'OIDC_CERT_PATH')) {
17+
$this->db->exec("ALTER TABLE settings ADD COLUMN OIDC_CERT_PATH VARCHAR(255)");
18+
}

www/views/includes/containers/settings/settings.inc.php

+8
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,14 @@
493493
<!-- <h6>GROUP SUPER ADMINISTRATOR</h6>
494494
<p class="note">Groups value for Super Administrator.</p>
495495
<input class="settings-param" param-name="oidcGroupSuperAdministrator" type="text" value="<?= OIDC_GROUP_SUPER_ADMINISTRATOR ?>"> -->
496+
497+
<h6>HTTP PROXY</h6>
498+
<p class="note">Http proxy.</p>
499+
<input class="settings-param" param-name="oidcHttpProxy" type="text" value="<?= OIDC_HTTP_PROXY ?>">
500+
501+
<h6>CERT FILE</h6>
502+
<p class="note">Path to cert file.</p>
503+
<input class="settings-param" param-name="oidcCertPath" type="text" value="<?= OIDC_CERT_PATH ?>">
496504
<?php
497505
endif; ?>
498506

0 commit comments

Comments
 (0)