mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-03-15 11:24:52 -05:00
[PR #6388] Add XoAuth2 support #7410
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/dani-garcia/vaultwarden/pull/6388
Author: @hnolde
Created: 10/22/2025
Status: 🔄 Open
Base:
main← Head:main📝 Commits (10+)
e5934c1Add XoAuth2 support to fetch the token from the SMTP Provider and refresh used by Google or Microsoftbfbedb0Fix: is_some_and and formatting issues1269330Fix: formatting issuesf6a5e53Fix: handlebars oauth2_success, http_client, urle5c0655Fix: formatting96fe363Merge branch 'main' into main7e3acf2Fix: update OAuth2 state storage initialization and state token encoding2be8e7eFix: reorder imports and clean up whitespace in admin.rs25fd440Merge branch 'main' into main1441d08Merge branch 'main' into main📊 Changes
19 files changed (+550 additions, -9 deletions)
View changed files
📝
.env.template(+12 -0)➕
migrations/mysql/2025-12-26-143000_create_xoauth2/down.sql(+1 -0)➕
migrations/mysql/2025-12-26-143000_create_xoauth2/up.sql(+4 -0)➕
migrations/postgresql/2025-12-26-143000_create_xoauth2/down.sql(+1 -0)➕
migrations/postgresql/2025-12-26-143000_create_xoauth2/up.sql(+4 -0)➕
migrations/sqlite/2025-12-26-143000_create_xoauth2/down.sql(+1 -0)➕
migrations/sqlite/2025-12-26-143000_create_xoauth2/up.sql(+4 -0)📝
src/api/admin.rs(+149 -1)📝
src/config.rs(+75 -2)📝
src/db/mod.rs(+8 -0)📝
src/db/models/mod.rs(+2 -0)➕
src/db/models/xoauth2.rs(+51 -0)📝
src/db/schema.rs(+7 -0)📝
src/error.rs(+6 -0)📝
src/mail.rs(+149 -6)📝
src/main.rs(+1 -0)📝
src/static/scripts/admin_settings.js(+35 -0)➕
src/static/templates/admin/oauth2_success.hbs(+10 -0)📝
src/static/templates/admin/settings.hbs(+30 -0)📄 Description
This pull request adds comprehensive support for SMTP OAuth2 (XOAUTH2) authentication, enabling the system to send emails via providers that require OAuth2 (like Gmail). It introduces new configuration options, admin panel endpoints, and user interface controls for managing OAuth2 tokens and authorization flows. The implementation includes secure handling of OAuth2 state for CSRF protection, token caching, and robust validation of configuration parameters.
SMTP OAuth2 (XOAUTH2) Support
smtp_oauth2_client_id,smtp_oauth2_client_secret,smtp_oauth2_auth_url,smtp_oauth2_token_url,smtp_oauth2_refresh_token, andsmtp_oauth2_scopes. These allow the system to be configured for OAuth2-based SMTP authentication.Backend OAuth2 Flow and Token Management
/admin/oauth2/authorizeand/admin/oauth2/callback) and a token refresh endpoint (/admin/test/oauth2) in the admin API, including secure state storage for CSRF protection during the OAuth2 flow. [1] [2] [3] [4]SMTP Transport and Authentication Logic
Admin UI Enhancements
General Improvements
update_config_partialpublic to allow saving OAuth2 tokens from the OAuth2 callback handler.From<&str>implementation for theErrortype to simplify error handling.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.