aboutsummaryrefslogtreecommitdiff
path: root/modules/private/gitolite/ldap_gitolite.sh
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-10-19 10:26:54 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-10-19 10:26:54 +0200
commit1b9150a54b5cb0b512265cdcf88ad10c9a4a55b1 (patch)
tree048eea0830161eda32bdec86a167d9b20050cca2 /modules/private/gitolite/ldap_gitolite.sh
parentb76b1d1f1678e329d0596e4403620f653a763d96 (diff)
downloadNix-1b9150a54b5cb0b512265cdcf88ad10c9a4a55b1.tar.gz
Nix-1b9150a54b5cb0b512265cdcf88ad10c9a4a55b1.tar.zst
Nix-1b9150a54b5cb0b512265cdcf88ad10c9a4a55b1.zip
Make ssh ldap connection by modules
Diffstat (limited to 'modules/private/gitolite/ldap_gitolite.sh')
-rw-r--r--modules/private/gitolite/ldap_gitolite.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/private/gitolite/ldap_gitolite.sh b/modules/private/gitolite/ldap_gitolite.sh
new file mode 100644
index 0000000..23cb2bf
--- /dev/null
+++ b/modules/private/gitolite/ldap_gitolite.sh
@@ -0,0 +1,33 @@
1### This snippet is not standalone and must be integrated in the global ldap_authorized_keys.sh
2LDAP_GITOLITE_MEMBER="cn=users,cn=gitolite,ou=services,dc=immae,dc=eu"
3GITOLITE_SHELL=$(which gitolite-shell)
4
5if [[ $user == gitolite ]]; then
6 ldap_search '(&(memberOf='$LDAP_GITOLITE_MEMBER')('$KEY'=*))' $KEY | \
7 while read line ;
8 do
9 if [ ! -z "$line" ]; then
10 if [[ $line == dn* ]]; then
11 user=$(sed -n 's/.*uid=\([^,]*\).*/\1/p' <<< "$line")
12 if [ -n "$user" ]; then
13 if [[ $user == "immae" ]] || [[ $user == "denise" ]]; then
14 # Capitalize first letter (backward compatibility)
15 user=$(sed -r 's/^([a-z])/\U\1/' <<< "$user")
16 fi
17 else
18 # Service fake user
19 user=$(sed -n 's/.*cn=\([^,]*\).*/\1/p' <<< "$line")
20 fi
21 elif [[ $line == $KEY* ]]; then
22 key=$(clean_key_line git "$line")
23 if [ ! -z "$key" ]; then
24 if [[ $key != *$'\n'* ]] && [[ $key == ssh-* ]]; then
25 echo -n 'command="'$GITOLITE_SHELL' '$user'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty '
26 echo $key
27 fi
28 fi
29 fi
30 fi
31 done
32 exit 0
33fi