Skip to content

[identity] Email domain Blacklist provider for register/create-user#973

Merged
cleftheris merged 27 commits intodevelopfrom
feature/support-blacklist-email-domains
Mar 30, 2026
Merged

[identity] Email domain Blacklist provider for register/create-user#973
cleftheris merged 27 commits intodevelopfrom
feature/support-blacklist-email-domains

Conversation

@avraimakis
Copy link
Copy Markdown
Contributor

@avraimakis avraimakis commented Mar 26, 2026

  • Fix corrupted TryGetDomain method in EmailDomainBlacklistValidator.cs (last commit broke method signature with incorrect autofix)
  • Remove misleading ValidateAsync_WithCancellation_StillValidatesEmail test that didn't actually test cancellation behavior (since ValidateAsync has no CancellationToken parameter)
  • All 24 EmailDomainBlacklist tests pass on net8.0 and net9.0

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Άγγελος Βραϊμάκης added 4 commits March 24, 2026 19:25
Introduced EmailDomainBlacklistValidator with support for multiple providers (default, config, file-based) to prevent registration with disposable or blacklisted email domains. Added extension methods for easy DI registration and configuration-based enable/disable. Included a comprehensive disposable email domain blocklist file. Validator is now invoked during user registration.
- Introduce EmailBlacklist config section and file-based domain list
- Refactor EmailDomainBlacklistValidator and providers for clarity
- Enable/disable validator via config; support file/config providers
- Always copy disposable_email_blocklist.conf.txt to output
- Update Microsoft.Azure.SignalR to 1.33.0 and add Management package
@avraimakis avraimakis requested a review from travlos March 26, 2026 11:02
@travlos travlos marked this pull request as ready for review March 27, 2026 10:23
Copilot AI review requested due to automatic review settings March 27, 2026 10:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an email-domain blacklist validation feature into the Identity registration pipeline, aiming to block signups (or updates) using disposable/blocked email domains.

Changes:

  • Wires an email-domain blacklist validator into Identity’s AddIdentityDefaults setup.
  • Adds EmailDomainBlacklistValidator (with config/file-backed blacklist providers).
  • Adds a large disposable-domain blocklist file and copies it to build output.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/Indice.Features.Identity.Server/Extensions/ServiceCollectionExtensions.cs Enables the new validator in the IdentityServer default Identity setup chain.
src/Indice.Features.Identity.Core/Extensions/IdentityBuilderExtensions.cs Adds the AddEmailDomainBlacklistValidator registration method and provider wiring.
src/Indice.Features.Identity.Core/EmailValidation/EmailDomainBlacklistValidator.cs Implements the validator and provider types (config + file + default).
src/Indice.Features.Identity.Core/EmailValidation/disposable_email_blocklist.conf.txt Adds the domain blacklist data file used for disposable-email blocking.
src/Indice.Features.Identity.Core/Indice.Features.Identity.Core.csproj Ensures the blocklist file is copied to the output directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cleftheris cleftheris changed the title Feature/support blacklist email domains [identity] Email domain Blacklist provider for register/create-user Mar 27, 2026
travlos added 2 commits March 27, 2026 16:33
- Introduce EmailBlacklistOptions for flexible blacklist configuration.
- Replace old providers with injectable Config/File providers.
- Use embedded resource for blacklist file (email_blocklist.conf).
- Improve domain extraction and validation logic (RFC-compliant).
- Update IdentityBuilderExtensions for new DI/config pattern.
- Remove hardcoded file paths and legacy provider code.
- Modernize codebase and improve null handling.
- Switch blacklist config to comma-separated string in options
- Rename provider method to IsDomainBlacklistedAsync
- Config provider now uses IOptions<EmailBlacklistOptions>
- File provider loads blacklist from embedded resource, not file
- Treat null/invalid emails as blacklisted in validator
- Remove configKey param from IdentityBuilderExtensions
- Embed blacklist file in assembly, remove file I/O
- Update tests for new config and embedded resource usage
- Clean up code, improve resource handling and test reliability
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

travlos and others added 5 commits March 30, 2026 11:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Renamed the email blacklist config section to "IdentityOptions:Email:Blacklist" for clarity and consistency. Improved XML documentation for blacklist providers to clarify configuration usage and correct file references. Removed unused using directives from IdentityBuilderExtensions.cs.
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
travlos
travlos previously approved these changes Mar 30, 2026
Copy link
Copy Markdown
Contributor

@travlos travlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀🚀🚀

Renamed EmailBlacklistOptions properties for consistency:
- Changed section name to "IdentityOptions:EmailBlacklist"
- Renamed EnableDomainBlacklist to Enabled
- Renamed Domain to Domains (comma-separated list)
Updated all references and documentation to use new names.
travlos added 3 commits March 30, 2026 13:57
Changed EmailBlacklistOptions.Name to "EmailBlacklist" for a simpler config section name. Updated IdentityBuilderExtensions to load EmailBlacklistOptions properties individually using GetIdentityOption<T>(), improving clarity and flexibility in configuration binding.
Renamed 'Domain' to 'Domains' in unit tests to match property changes in EmailBlacklistOptions. Commented out <VersionSuffix>rc02</VersionSuffix> in Directory.Build.props to disable the RC version suffix during builds.
Copy link
Copy Markdown
Contributor

@cleftheris cleftheris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@cleftheris cleftheris merged commit b319b1d into develop Mar 30, 2026
1 check passed
@cleftheris cleftheris deleted the feature/support-blacklist-email-domains branch March 30, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants