Skip to content

Add Captcha to Necessary Secure Account Areas #752

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 11, 2025

This PR adds HCaptcha protection to three critical authentication pages that were missing captcha validation, enhancing security against automated attacks.

Changes Made

Login Page (Areas/Identity/Pages/Account/Login.cshtml)

  • Added HCaptcha widget to login form
  • Implemented backend validation before login attempts
  • Prevents automated brute force attacks

Resend Email Confirmation Page (Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml)

  • Added HCaptcha widget before email sending
  • Added validation to prevent email spam abuse
  • Protects against automated confirmation email requests

Reset Password Page (Areas/Identity/Pages/Account/ResetPassword.cshtml)

  • Added HCaptcha widget before password reset
  • Implemented validation to block automated reset attempts
  • Secures password recovery flow

Register Page

  • Already had captcha implementation (used as reference pattern)

Technical Implementation

Frontend Changes:

<div class="form-group">
    <div class="h-captcha" data-sitekey=@Model.CaptchaOptions.SiteKey></div>
</div>
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>

Backend Changes:

  • Injected existing ICaptchaService and IOptions<CaptchaOptions> into page models
  • Added captcha response validation using proven error handling patterns
  • Leveraged existing HCaptchaErrorDetails system for comprehensive error management

Security Benefits:

  • Prevents automated bot attacks on login attempts
  • Protects email systems from spam abuse
  • Secures password reset functionality against automated attacks
  • Maintains consistent user experience across all authentication flows

All implementations follow the same proven pattern as the existing Register page captcha, ensuring consistency and reliability.

Captcha Implementation Demo

Fixes #253.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits July 11, 2025 06:04
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add Captcha to Necessary Secure Account Areas Add Captcha to Necessary Secure Account Areas Jul 11, 2025
@Copilot Copilot AI requested a review from BenjaminMichaelis July 11, 2025 06:12
Copilot finished work on behalf of BenjaminMichaelis July 11, 2025 06:12
@BenjaminMichaelis
Copy link
Member

Does this fix #254?

@BenjaminMichaelis
Copy link
Member

@copilot Does this fix #254?

Copy link
Contributor Author

Copilot AI commented Jul 11, 2025

@copilot Does this fix #254?

No, this PR only addresses issue #253 (adding captcha to secure account areas like login/register/password reset). Issue #254 is about preventing content scraping by adding captcha after users browse multiple pages, which is a different use case and would require a separate implementation.

Copilot finished work on behalf of BenjaminMichaelis July 11, 2025 14:02
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.

Add Captcha to Necessary Secure Account Areas
2 participants