LDAP -> User Field Procs
Created by: brocktimus
I think it would be really useful if we could configure procs for other fields for how the output of LDAP maps onto the User model.
At the moment we can map the username typed in into the internal uid field like so:
production:
ldap:
name_proc: Proc.new {|name| name.gsub(/@.*$/,'')} # Extract uid from email
It would be great if we could do the following which would allow for varied LDAP schemas without having to branch / monkey patch:
production:
ldap:
username_proc: Proc.new { |uid, email| email.match(/([\w\.]*)@/)[1] } # Extract username from front of email
email_proc: Proc.new { |uid, email| email.match(/[\w\.]*@[\w\.]*/)[0] } # Extract email from formatted field
Then something like the default proc which is currently used to convert emails into usernames could be defined as a default option for the username_proc.
The difference being these are applied to the output of the LDAP moreso than the input. I'd be willing to help make this happen since it means we don't have to maintain a local branch, just need some advice as to where these procs should go.
The main places I'm looking at are
- lib/gitlab/auth.rb as private methods
- somewhere in gitlab_omniauth-ldap
What're your thoughts?