Skip to content

fix(auth): reject login attempts with bare usernames and enforce domain validation#268

Open
Aravinda-HWK wants to merge 2 commits intoLSFLK:mainfrom
Aravinda-HWK:267-bug-imap-authentication-allows-login-with-username-only-and-mismatched-domain
Open

fix(auth): reject login attempts with bare usernames and enforce domain validation#268
Aravinda-HWK wants to merge 2 commits intoLSFLK:mainfrom
Aravinda-HWK:267-bug-imap-authentication-allows-login-with-username-only-and-mismatched-domain

Conversation

@Aravinda-HWK
Copy link
Copy Markdown
Collaborator

📌 Description

This PR is to enforce to send email address when logging in.


🔍 Changes Made

  • Update the auth.go for only accept email address not the username in the login process

✅ Checklist (Email System)

  • Core IMAP commands tested (LOGIN, CAPABILITY, LIST, SELECT, FETCH, LOGOUT).
  • Authentication is tested.
  • Docker build & run validated.
  • Configuration loading verified for default and custom paths.
  • Persistent storage with Docker volume verified.
  • Error handling and logging verified
  • Documentation updated (README, config samples).

🧪 Testing Instructions

To test the server, use the instructions in the README in the test directory.


📷 Screenshots / Logs (if applicable)


⚠️ Notes for Reviewers

@Aravinda-HWK Aravinda-HWK self-assigned this Mar 30, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the authentication process to require email-based identities, rejecting bare usernames. It refactors domain validation to compare the login domain against domains derived from the identity provider or organizational units. Integration and unit tests have been updated to enforce these requirements. Feedback was provided regarding a redundant check for an empty email string that can be removed to simplify the code.

Comment on lines 519 to 523
if email == "" {
log.Printf("LOGIN: unable to resolve mailbox email from login '%s' and auth id '%s'", username, authResp.ID)
log.Printf("LOGIN: unable to resolve mailbox email from login '%s'", loginEmail)
deps.SendResponse(conn, fmt.Sprintf("%s NO [AUTHENTICATIONFAILED] Authentication failed", tag))
return
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This check for an empty email is redundant. The loginEmail variable, from which email is assigned, is validated at the beginning of the authenticateUser function (lines 405-410) to ensure it's not an empty string. Therefore, this block of code is unreachable and can be removed to improve clarity.

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.

[BUG] IMAP authentication allows login with username-only and mismatched domain

1 participant