-
Notifications
You must be signed in to change notification settings - Fork 13.8k
fix: enforce default blocked email domains list on a stock install #41767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Osamaali313
wants to merge
2
commits into
RocketChat:develop
Choose a base branch
from
Osamaali313:fix-default-blocked-email-domains
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+63
−6
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Fixes the default blocked email domains list (`Accounts_UseDefaultBlockedDomainsList`) being ignored during registration unless a custom `Accounts_BlockedDomainsList` was also set. The two settings are now independent, so the built-in list of disposable/throwaway domains is enforced on a stock install as intended. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { isEmailDomainBlocked } from './isEmailDomainBlocked'; | ||
|
|
||
| // `0-mail.com` is present in the built-in default list; `gmail.com` is not. | ||
| describe('isEmailDomainBlocked', () => { | ||
| it('blocks a default-listed domain when the default list is enabled, even with an empty custom list', () => { | ||
| // Regression: previously the default list was only consulted when the | ||
| // custom list was non-empty, so on a stock install this returned false. | ||
| expect(isEmailDomainBlocked('0-mail.com', [], true)).toBe(true); | ||
| }); | ||
|
|
||
| it('does not block a default-listed domain when the default list is disabled', () => { | ||
| expect(isEmailDomainBlocked('0-mail.com', [], false)).toBe(false); | ||
| }); | ||
|
|
||
| it('blocks a domain on the custom list', () => { | ||
| expect(isEmailDomainBlocked('evil.example', ['evil.example'], false)).toBe(true); | ||
| }); | ||
|
|
||
| it('does not block a domain that is on neither list', () => { | ||
| expect(isEmailDomainBlocked('gmail.com', ['evil.example'], true)).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { emailDomainDefaultBlackList } from './defaultBlockedDomainsList'; | ||
|
|
||
| /** | ||
| * Decide whether an email domain should be blocked at registration. | ||
| * | ||
| * The admin-configured blocklist (`Accounts_BlockedDomainsList`) and the | ||
| * built-in default list (`Accounts_UseDefaultBlockedDomainsList`) are | ||
| * independent controls, so the default list must apply on its own even when no | ||
| * custom domain has been configured. Previously both checks were gated behind | ||
| * the custom list being non-empty, so on a stock install the default list was | ||
| * never consulted. | ||
| */ | ||
| export const isEmailDomainBlocked = (emailDomain: string, blockList: string[], useDefaultList: boolean): boolean => | ||
| (blockList.length > 0 && blockList.includes(emailDomain)) || (useDefaultList && emailDomainDefaultBlackList.includes(emailDomain)); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.