Restrict usernames created for whitelisted domains

Description

We want to require user names to match the user portion of an email address. This would be used in conjunction with a whitelisted domain. For example, someone whose email address is bob@domain.com would be restricted to the username "bob". We can already prevent users from changing their username (config setting), but we have no way of restricting signups to match email names.

This is very useful for organizations such as universities that don't want to deploy IMAP for all students, but do want students to use their "official" email ID as a username.

Proposal

We could easily integrate this into the whitelist feature; I've already done so myself, and a simple version is only 10 lines of code. It could be done like this:

domain.com

university.edu:{EMAILUSER}

This would require that an ID created from the university.edu domain be (exactly) the email user ID. Users from domain.com could choose any username.

Alternatively, we could do:

university.edu:{EMAILUSER}univ

In this case, alice@university.edu would have to have a GitLab username aliceuniv.

This is a short and simple fix; I implemented it inside signup_domain_valid?. I believe this is the only place that whitelisted domains are referenced, so making a small change to the whitelist domain format should be straightforward.

Links / references

Edited Aug 14, 2020 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading