Skip to content

Commit

Permalink
VPN: IPsec: Connections - remote authentication. Add support for radi…
Browse files Browse the repository at this point in the history
…s class groups, fix missing mapping in 928d2f8 for #3295
  • Loading branch information
AdSchellevis committed Nov 22, 2023
1 parent 1dab8ca commit af46866
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/IPsec/Swanctl.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

use Phalcon\Messages\Message;
use OPNsense\Base\BaseModel;
use OPNsense\Core\Config;
use OPNsense\Firewall\Util;

/**
Expand All @@ -38,6 +39,27 @@
*/
class Swanctl extends BaseModel
{
/**
* convert group ids to group (class) names
*/
private function gidToNames($gids)
{
$result = [];
$cnf = Config::getInstance()->object();
$mapping = [];
if (isset($cnf->system->group)) {
foreach ($cnf->system->group as $group) {
$mapping[(string)$group->gid] = (string)$group->name;
}
}
foreach (explode(',', $gids) as $gid) {
if (!empty($mapping[$gid])) {
$result[] = $mapping[$gid];
}
}
return implode(',', $result);
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -175,6 +197,8 @@ public function getConfig()
$pool_names[$node_uuid] = (string)$attr;
}
continue;
} elseif (is_a($attr, 'OPNsense\Base\FieldTypes\AuthGroupField')) {
$thisnode[$attr_name] = $this->gidToNames((string)$attr);
} elseif (is_a($attr, 'OPNsense\Base\FieldTypes\BooleanField')) {
$thisnode[$attr_name] = (string)$attr == '1' ? 'yes' : 'no';
} elseif (is_a($attr, 'OPNsense\Base\FieldTypes\CertificateField')) {
Expand Down

0 comments on commit af46866

Please sign in to comment.