Can I set a `User cap` for a particular domain in Gitlab?

Hello:

I want to limit the number of users from a particular domain that can register into my Gitlab instance. I noticed that I could set a “user cap”, but it wasn’t specific to a domain.

For example:

I want to limit the number of users registered from these domains. 20 users from testdomain1.com and 30 users fromtestdomain2.com are allowed to sign up. So, if there are already 20 users registered sucessfully from testdomain1.com, new user from testdomain1.com will not be allowed to sign up.

What should I do for it?

As far as I read on Sign-up restrictions | GitLab that is not a (current) option. I guess you could submit a feature request for this.

Since the related issue does not get any response yet. I asked a question in stackoverflow and I edited the question today.

I’m tring to implement it by myself and it seems like that I need to extend the UI of the Admin Settings page and add some related tables to database to set different “user cap” for different email domain.

I do see your use-case, but I do think you’ll have to implement it yourself. Perhaps contribute it back, so others can benefit from it. The core of GitLab is open source.

I haven’t looked at that part of the code, but from a short look at the code you shared on stack overflow, I would guess you need to add a new table to the underlying database to store the cap for each domain and add some default (no cap) for domains that can’t be found in that table.

Right, a particular table is needed to store the caps. But I don’t have enough time now to modify the UI so I found a simple way to do this:

The Allowed domains for sign-ups which called domain_allowlist in database is a text:

gitlabhq_production=# \d application_settings
...
domain_allowlist         | text         |           |          | 
...

gitlabhq_production=# select domain_allowlist from application_settings;
 domain_allowlist  
-------------------
 ---              +
 - testdomain1.com+
 - testdomain2.com+
 
(1 row)

I can modify the testdomain1.com to testdomain1.com#30 to store the user cap and use Regex to get the number 30.

I will modify the UI and add the database table later. And I’ll create a pull request on Gitlab when I’m done.