Skip to content

Commit

Permalink
fix apply group based roles
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Oct 5, 2021
1 parent 31b8407 commit 8becdd2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Thruk/Authentication/User.pm
Expand Up @@ -110,6 +110,7 @@ sub set_dynamic_attributes {
$data->{'email'} = $email if defined $email;
$data->{'can_submit_commands'} = $can_submit_commands if defined $can_submit_commands;
$data->{'contactgroups'} = $groups if defined $groups;
$data->{'timestamp'} = time();
}

$self->_apply_user_data($c, $data);
Expand Down Expand Up @@ -261,7 +262,6 @@ sub _apply_user_data {
$data->{'roles'} = Thruk::Base::array_uniq($roles);
$data->{'can_submit_commands'} = $can_submit_commands;
$data->{'roles_by_group'} = $roles_by_group;
$data->{'timestamp'} = time();

return;
}
Expand Down
14 changes: 11 additions & 3 deletions lib/Thruk/Config.pm
Expand Up @@ -711,6 +711,8 @@ sub set_default_config {
$config->{'omd_apache_proto'} = $proto;
}

_normalize_auth_config($config);

return $config;
}

Expand Down Expand Up @@ -1247,15 +1249,21 @@ sub merge_cgi_cfg {
$c->config->{$key} = $cfg->{$key};
}

###################################################
# normalize authorized_for_* lists
_normalize_auth_config($c->config);

return;
}

########################################
# normalize authorized_for_* lists
sub _normalize_auth_config {
my($config) = @_;
for my $key (keys %{$config}) {
if($key =~ m/^(authorized_for|authorized_contactgroup_for_)/mx) {
$config->{$key} = Thruk::Base::comma_separated_list($config->{$key});
next;
}
}

return;
}

Expand Down
2 changes: 1 addition & 1 deletion t/110-thruk_authentication_user.t
Expand Up @@ -14,7 +14,7 @@ sub new {
sub config {
my $this = shift;

my $config = { map({ $_ => $this->{user} } @{$this->{roles}}) };
my $config = { map({ $_ => [$this->{user}] } @{$this->{roles}}) };
$config->{var_path} = ".";
return($config);
}
Expand Down

0 comments on commit 8becdd2

Please sign in to comment.