Skip to content

Commit

Permalink
show default group prefix in settings
Browse files Browse the repository at this point in the history
- and have group related settings next to each other
- and a little cleanup

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Nov 4, 2022
1 parent ec35de9 commit 9556523
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/GroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function addGroup(IUser $user, string $gid): void {
//FIXME: probably need config flag. Previous to 17, gid was used as displayname
$providerId = $this->settings->getProviderId();
$settings = $this->settings->get($providerId);
$groupPrefix = $settings['saml-attribute-mapping-group_mapping_prefix'] ?? 'SAML_';
$groupPrefix = $settings['saml-attribute-mapping-group_mapping_prefix'] ?? SAMLSettings::DEFAULT_GROUP_PREFIX;
$group = $this->createGroupInBackend($groupPrefix . $gid, $gid);
} else {
throw $e;
Expand Down
15 changes: 6 additions & 9 deletions lib/SAMLSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use OCA\User_SAML\Db\ConfigurationsMapper;
use OCP\DB\Exception;
use OCP\IConfig;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use OneLogin\Saml2\Constants;
Expand All @@ -35,6 +34,10 @@ class SAMLSettings {
private const LOADED_CHOSEN = 1;
private const LOADED_ALL = 2;

// list of global settings which are valid for every idp:
// 'general-require_provisioned_account', 'general-allow_multiple_user_back_ends', 'general-use_saml_auth_for_desktop'

// IdP-specific keys
public const IDP_CONFIG_KEYS = [
'general-idp0_display_name',
'general-uid_mapping',
Expand Down Expand Up @@ -71,27 +74,21 @@ class SAMLSettings {
'sp-privateKey',
];

public const DEFAULT_GROUP_PREFIX = 'SAML_';

/** @var IURLGenerator */
private $urlGenerator;
/** @var IConfig */
private $config;
/** @var ISession */
private $session;
/** @var array list of global settings which are valid for every idp */
private $globalSettings = ['general-require_provisioned_account', 'general-allow_multiple_user_back_ends', 'general-use_saml_auth_for_desktop'];
/** @var array<int, array<string, string>> */
private $configurations;
/** @var int */
private $configurationsLoadedState = self::LOADED_NONE;
/** @var ConfigurationsMapper */
private $mapper;

/**
* @param IURLGenerator $urlGenerator
* @param IConfig $config
* @param IRequest $request
* @param ISession $session
*/
public function __construct(
IURLGenerator $urlGenerator,
IConfig $config,
Expand Down
10 changes: 5 additions & 5 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ public function getForm() {
'type' => 'line',
'required' => false,
],
'group_mapping' => [
'text' => $this->l10n->t('Attribute to map the users groups to.'),
'home_mapping' => [
'text' => $this->l10n->t('Attribute to map the users home to.'),
'type' => 'line',
'required' => true,
],
'home_mapping' => [
'text' => $this->l10n->t('Attribute to map the users home to.'),
'group_mapping' => [
'text' => $this->l10n->t('Attribute to map the users groups to.'),
'type' => 'line',
'required' => true,
],
'group_mapping_prefix' => [
'text' => $this->l10n->t('Group Mapping Prefix'),
'text' => $this->l10n->t('Group Mapping Prefix, default: %s', [SAMLSettings::DEFAULT_GROUP_PREFIX]),
'type' => 'line',
'required' => true,
],
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function formDataProvider() {
'required' => true,
],
'group_mapping_prefix' => [
'text' => $this->l10n->t('Group Mapping Prefix'),
'text' => $this->l10n->t('Group Mapping Prefix, default: SAML_'),
'type' => 'line',
'required' => true,
],
Expand Down

0 comments on commit 9556523

Please sign in to comment.