I found the solution following https://stackoverflow.com/questions/3817478/setting-up-git-server-on-windows-with-git-http-backend-exe and https://stackoverflow.com/questions/8021167/git-debian-apache-and-smart-http which was to add the
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
to my apache configuration and use $REMOTE_USER
in my script which contains indeed the authenticated user name. I'm really wondering how the sample in the tutorial is supposed to work.