feat: Restrict account creation to users from specific organizations or domains #948
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This feature adds the ability to restrict user registration to specific email domains when registration is enabled. Currently, when
DISALLOW_REGISTRATIONis set to false, any user with any email address can register. This feature will allow administrators to configure a whitelist of allowed email domains, ensuring that only users with email addresses from approved domains can create accounts.Glossary
Requirements
Requirement 1
User Story: As an administrator, I want to configure allowed email domains for registration, so that I can restrict account creation to users from specific organizations or domains.
Acceptance Criteria
REGISTRATION_ALLOWED_DOMAINSenvironment variable THEN the System SHALL parse it as a comma-separated list of allowed email domainsREGISTRATION_ALLOWED_DOMAINSvariable is empty or not set THEN the System SHALL allow registration from any email domainREGISTRATION_ALLOWED_DOMAINSvariable contains whitespace around domain names THEN the System SHALL trim the whitespace and normalize the domains to lowercaseREGISTRATION_ALLOWED_DOMAINSvariable contains invalid domain formats THEN the System SHALL log a warning and skip the invalid entriesDISALLOW_REGISTRATIONis true, THEN the System SHALL ignore theREGISTRATION_ALLOWED_DOMAINSsetting and prevent all registrationRequirement 2
User Story: As a user attempting to register, I want clear feedback when my email domain is not allowed, so that I understand why my registration was rejected.
Acceptance Criteria
Requirement 3
User Story: As an administrator, I want the domain restriction to apply consistently across all registration methods, so that the security policy is enforced uniformly.
Acceptance Criteria
Requirement 4
User Story: As a developer, I want the domain restriction logic to be testable and maintainable, so that I can verify correct behavior and easily modify the feature.
Acceptance Criteria