From 0f6b9170d126f5c3be7bd6ee9bd8646cd2aa7d94 Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Mon, 15 Jul 2013 18:57:06 +0200 Subject: Filter what user infos we keep from ldap --- README | 1 + config_default | 3 +++ lib/MGA/Git.pm | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README b/README index e411b41..d1246b9 100644 --- a/README +++ b/README @@ -35,6 +35,7 @@ The following configuration options are available : userbase: the base used to search ldap users userfilter: filter to search ldap users uid_username_re: regular expression to extract a username from ldap uid + ldap_users_infos: list of ldap user attributes that we should keep available group_re: regular expression to extract group name from cn pubkey_dir: directory containing users ssh keys, used by gitolite tmpl_dir: templates directory diff --git a/config_default b/config_default index d51aca8..a980bef 100644 --- a/config_default +++ b/config_default @@ -17,3 +17,6 @@ repos_config: - prefix: software include_dir: /var/lib/git/repos/software gl_template: soft_repo +ldap_users_infos: + - cn + - sshpublickey diff --git a/lib/MGA/Git.pm b/lib/MGA/Git.pm index e518189..6b8ac11 100644 --- a/lib/MGA/Git.pm +++ b/lib/MGA/Git.pm @@ -111,7 +111,12 @@ sub load_users { filter => $config->{userfilter}, ); my @users = grep { $_->{sshpublickey} } values %{$m->as_struct}; - @{$r->{users}}{map { $_->{uid}[0] } @users} = @users; + my %keepinfos = map { $_ => 1 } @{$config->{ldap_users_infos}}; + foreach my $user (@users) { + my $uid = $user->{uid}[0]; + my %u = map { $keepinfos{$_} ? ($_ => $user->{$_}) : () } keys %$user; + $r->{users}{$uid} = \%u; + } } sub get_tmpl { -- cgit v1.2.1