Skip to content

fix(smtp): try to authenticate with the UPN from OAuth#256

Open
lucaasmth wants to merge 1 commit intoabhinavxd:mainfrom
lucaasmth:fix/office-smtp-auth
Open

fix(smtp): try to authenticate with the UPN from OAuth#256
lucaasmth wants to merge 1 commit intoabhinavxd:mainfrom
lucaasmth:fix/office-smtp-auth

Conversation

@lucaasmth
Copy link
Copy Markdown

Summary

This pull request improves the handling of OAuth authentication for Microsoft SMTP by ensuring the XOAUTH2 username matches the User Principal Name (UPN) in the JWT access token, which is required for successful authentication. The changes introduce a helper function to extract the UPN from the token and update the authentication logic accordingly.

In my case I had two different emails on the Microsoft account and I couldn't authenticate to the SMTP server with the first, which is the one present in the email field of the JWT access token.

Changes

  • Added a new helper function extractUPNFromToken in internal/inbox/channel/email/smtp.go to extract the UPN (or fallback to unique_name) from a JWT access token, ensuring proper username selection for Microsoft SMTP.
  • Updated the NewSmtpPool function to use the extracted UPN as the XOAUTH2 username if available, otherwise defaulting to the configured username, improving compatibility with Microsoft SMTP requirements.

- Add function to extract the UPN from the OAuth access token
- Use this UPN to authenticate to the SMTP server, fallback to the username
@abhinavxd
Copy link
Copy Markdown
Owner

hey thanks for the PR!

This needs to be also done for imap I believe not just SMTP.

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.

2 participants