Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #3022

Closed
Open
Created Feb 18, 2013 by Administrator@rootOwner

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?

Assignee
Assign to
Time tracking