Skip to content

Commit 4c3dc34

Browse files
committed
Merge branch 'main' into build
2 parents 44e5775 + 39a0086 commit 4c3dc34

File tree

4 files changed

+117
-35
lines changed

4 files changed

+117
-35
lines changed

.github/workflows/pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
skip-existing: true # avoid failing when repeating this action
5151

5252
# sign the built packages
53-
- uses: sigstore/gh-action-sigstore-python@v3.0.0
53+
- uses: sigstore/gh-action-sigstore-python@v3.0.1
5454
with:
5555
inputs: >-
5656
./dist/*.tar.gz

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ Transparently add OAuth 2.0 support to IMAP/POP/SMTP client applications, script
77
<picture>
88
<source width="300" media="(prefers-color-scheme: dark)" srcset="https://auth-email.com/static/img/logo-full-dark.svg">
99
<source width="300" media="(prefers-color-scheme: light)" srcset="https://auth-email.com/static/img/logo-full-light.svg">
10-
<img width="300" src="https://auth-email.com/static/img/logo-full.png" alt="Email-Auth logo">
10+
<img width="300" src="https://auth-email.com/static/img/logo-full.png" alt="Auth-Email.com logo">
1111
</picture><br>
1212
<b>Email OAuth made simple</b><br>
13-
<sub>Auth-Email.com is a unified proxy for all your OAuth 2.0 email accounts.</sub><br>
14-
<sup>Use any app or client to access your accounts with ease.</sup>
13+
<sup>Use any app, client or device to access your OAuth mail accounts with ease.</sup>
1514
</a><br><br>
1615
</div>
1716

1817

1918
## Motivation and capabilities<a id="motivation-and-capabilities"></a>
2019
Email services that support IMAP, POP and/or SMTP access are increasingly requiring the use of OAuth 2.0 to authenticate connections, but not all clients support this method.
21-
This tool creates a local proxy that intercepts the traditional IMAP/POP/SMTP authentication commands and transparently replaces them with the appropriate SASL (X)OAuth 2.0 commands and credentials.
22-
Your email client can continue to use the `login` or `auth`/`authenticate` options, with no need to make it aware of OAuth's existence.
20+
This tool is a local proxy that intercepts the traditional IMAP/POP/SMTP authentication commands and transparently replaces them with the appropriate SASL (X)OAuth 2.0 commands and credentials.
21+
Your email client, app or device can continue to use the `login` or `auth`/`authenticate` options, with no need to make it aware of OAuth's existence.
2322
The proxy works in the background with a menu bar/taskbar helper or as a headless system service, and is compatible with macOS, Windows and Linux.
23+
It can be used with any email provider that supports OAuth 2.0 authentication, including Outlook, Office 365, Hotmail, 21Vianet, Gmail, Google Workspace, Fastmail, Yahoo, Comcast, AOL and many others.
2424

2525
### Example use-cases<a id="example-use-cases"></a>
2626
- You need to use an Office 365 email account, but don't get on with Outlook.
@@ -29,6 +29,7 @@ The email client you like doesn't support OAuth 2.0, which became mandatory [in
2929
- You have an account already set up in an email client, and you need to switch it to OAuth 2.0 authentication.
3030
You can edit the server details, but the client forces you to delete and re-add the account to enable OAuth 2.0, and you don't want to do this.
3131
- You have made your own script or application that sends or receives email, but it doesn't support OAuth 2.0, and you don't want to have to modify it to implement this.
32+
- You use a device or business application that provides functions such as scan to email, email alerts or email to print, but you can't set it up to use the official OAuth 2.0 workarounds from [Microsoft](https://learn.microsoft.com/exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365) or [Google](https://support.google.com/a/answer/176600).
3233
- You work with multiple services or applications that use IMAP/POP/SMTP, and you don't want to have to set up OAuth 2.0 independently for each one.
3334

3435
In all of these cases and more, this proxy can help – just follow the instructions below to get started.
@@ -41,7 +42,7 @@ Begin by downloading the proxy via one of the following methods:
4142

4243
<ol type="A">
4344
<li><b>Pick a <a href="https://github.com/simonrob/email-oauth2-proxy/releases/latest">pre-built release</a></b> for your platform (macOS or Windows; no installation needed); <i>or</i>,</li>
44-
<li><b>Install from <a href="https://pypi.org/project/emailproxy/">PyPI</a></b>: set up using <code>python -m pip install emailproxy\[gui\]</code>, download the <a href="https://github.com/simonrob/email-oauth2-proxy/raw/main/emailproxy.config">sample <code>emailproxy.config</code> file</a>, then <code>python -m emailproxy</code> to run; <i>or</i>,</li>
45+
<li><b>Install from <a href="https://pypi.org/project/emailproxy/">PyPI</a></b>: set up using <code>python -m pip install "emailproxy[gui]"</code>, download the <a href="https://github.com/simonrob/email-oauth2-proxy/raw/main/emailproxy.config">sample <code>emailproxy.config</code> file</a>, then <code>python -m emailproxy</code> to run; <i>or</i>,</li>
4546
<li><b>Clone or <a href="https://github.com/simonrob/email-oauth2-proxy/archive/refs/heads/main.zip">download</a></b> (and star :-) the <a href="https://github.com/simonrob/email-oauth2-proxy/">GitHub repository</a>, then: <code>python -m pip install -r requirements-core.txt -r requirements-gui.txt</code> to install requirements, and <code>python emailproxy.py</code> to run.</li>
4647
</ol>
4748

@@ -87,6 +88,7 @@ The [sample configuration file](https://github.com/simonrob/email-oauth2-proxy/b
8788
- Gmail / Google Workspace: register a [Google API desktop app client](https://developers.google.com/identity/protocols/oauth2/native-app).
8889
- Outlook / Hotmail (personal accounts): If you are part of the Microsoft 365 Developer Programme or have an Azure account (including free accounts), you can create your own app registration in the Entra admin centre – see [this discussion](https://github.com/simonrob/email-oauth2-proxy/discussions/301) for a guide.
8990
If not, you will need to reuse an existing client ID – see, for example, [this sample configuration](https://github.com/simonrob/email-oauth2-proxy/issues/297#issuecomment-2424200404).
91+
- Fastmail: register a new [Fastmail OAuth client](https://www.fastmail.com/dev/#registration).
9092
- AOL and Yahoo Mail (and subproviders such as AT&T) are not currently allowing new client registrations with the OAuth email scope – the only option here is to reuse the credentials from an existing client that does have this permission.
9193

9294
The proxy supports [Google Cloud service accounts](https://cloud.google.com/iam/docs/service-account-overview) for access to Google Workspace Gmail.
@@ -208,7 +210,7 @@ Please [open an issue](https://github.com/simonrob/email-oauth2-proxy/issues) if
208210

209211
When first launching on Linux in GUI mode you may encounter errors similar to `Namespace […] not available`, issues with the task bar icon display, or no browser popup when attempting to authorise your accounts.
210212
This is caused by missing dependencies for [pystray](https://github.com/moses-palmer/pystray/) and [pywebview](https://github.com/r0x0r/pywebview/), which are used to display the menu bar icon and authentication windows.
211-
See the [pywebview dependencies](https://pywebview.flowrl.com/guide/installation.html#dependencies) and [pystray FAQ](https://pystray.readthedocs.io/en/latest/faq.html) pages and [existing](https://github.com/simonrob/email-oauth2-proxy/issues/1#issuecomment-831746642) [closed](https://github.com/simonrob/email-oauth2-proxy/issues/136#issuecomment-1430417456) [issues](https://github.com/simonrob/email-oauth2-proxy/issues/305#issuecomment-2482989955) in this repository for a summary and suggestions about how to resolve this.
213+
See the [pywebview dependencies](https://pywebview.flowrl.com/guide/installation.html#dependencies) and [pystray FAQ](https://pystray.readthedocs.io/en/latest/faq.html) pages and [several](https://github.com/simonrob/email-oauth2-proxy/issues/1#issuecomment-831746642) [previous](https://github.com/simonrob/email-oauth2-proxy/issues/136#issuecomment-1430417456) [closed](https://github.com/simonrob/email-oauth2-proxy/issues/305#issuecomment-2482989955) [issues](https://github.com/simonrob/email-oauth2-proxy/issues/342#issuecomment-2775313239) in this repository for a summary and suggestions about how to resolve this.
212214

213215
A similar issue may occur on Windows with the [pythonnet](https://github.com/pythonnet/pythonnet) package, which is required by [pywebview](https://github.com/r0x0r/pywebview).
214216
The [pythonnet installation instructions](https://github.com/pythonnet/pythonnet/wiki/Installation) may offer alternative ways to install this package if the default installation fails.
@@ -259,6 +261,7 @@ See the [documentation and examples](https://github.com/simonrob/email-oauth2-pr
259261
Michael Stepner has created a [Terraform configuration](https://github.com/michaelstepner/email-oauth2-proxy-aws) that helps run this proxy on a lightweight cloud server (AWS EC2).
260262
Thiago Macieira has provided a [makefile and systemd configuration files](https://github.com/thiagomacieira/email-oauth2-proxy/tree/Add_a_Makefile_and_systemd_configuration_files_to_install_system_wide).
261263
For Docker, Moriah Morgan has an [example configuration](https://github.com/blacktirion/email-oauth2-proxy-docker).
264+
For Helm, Patrick Joyce has an [example chart](https://github.com/pjaudiomv/email-oauth2-proxy-helm).
262265

263266
If you already use postfix, the [sasl-xoauth2](https://github.com/tarickb/sasl-xoauth2) plugin is probably a better solution than running this proxy.
264267
Similarly, if you use an application that is able to handle OAuth 2.0 tokens but just cannot retrieve them itself, then [pizauth](https://github.com/ltratt/pizauth), [mailctl](https://github.com/pdobsan/mailctl) or [oauth-helper-office-365](https://github.com/ahrex/oauth-helper-office-365) may be more appropriate.

emailproxy.config

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ documentation = Accounts are specified using your email address as the section h
153153
2.0 flows (both currently only known to be available for Office 365). To use either of these flows, add an account
154154
entry as normal, but do not add a `permission_url` value (it does not apply, and its absence signals to the proxy to
155155
use the appropriate token retrieval mechanism). For CCG, set `oauth2_scope = https://outlook.office365.com/.default`
156-
and `oauth2_flow = client_credentials`. For ROPCG, set `oauth2_flow = password` (and use a standard scope value). An
157-
example is given for both methods towards the end of the sample account entries below.
156+
and `oauth2_flow = client_credentials`. For ROPCG, set `oauth2_flow = password` (and use a standard scope value).
157+
If you are using Microsoft services delivered by a regional provider (such as 21Vianet) that uses a non-standard
158+
ROPCG variant, remove the `oauth2_scope` value and instead use `oauth2_resource`. Examples are given for each of
159+
these cases towards the end of the sample account entries below.
158160

159161
- WARNING: Please note that by default the CCG flow has essentially no local access control when creating new
160162
accounts (no user consent is involved, so the proxy cannot validate login attempts unless an account entry
@@ -167,11 +169,11 @@ documentation = Accounts are specified using your email address as the section h
167169
script at https://github.com/simonrob/email-oauth2-proxy/issues/61#issuecomment-1259110336.
168170

169171
- The proxy supports the device authorisation grant (DAG) OAuth 2.0 flow (currently only known to be available for
170-
Office 365 / Outlook), which may better suit headless systems. To use this flow, set `oauth2_flow = device`. With
172+
Office 365 / Outlook), which may better suit headless systems. To use this flow, set `oauth2_flow = device`. With
171173
this flow, the proxy receives authorisation responses directly from the service provider, so no `redirect_uri` is
172174
needed. An example account configuration is given below. For additional customisation, the proxy modifications and
173175
scripts demonstrated at https://github.com/simonrob/email-oauth2-proxy/pull/317 show how the DAG flow authorisation
174-
message could be pushed to a separate device, which may be useful when running the proxy headless or without a GUI.
176+
message could be pushed to a separate device, which may be useful when running the proxy headless or without a GUI.
175177

176178
Gmail customisation:
177179
- The proxy supports the use of service accounts with Gmail for Google Workspace (note: normal Gmail accounts do not
@@ -211,6 +213,9 @@ documentation = Accounts are specified using your email address as the section h
211213
the same address. To avoid clashes, it is recommended that each account has a unique `redirect_uri` (or
212214
`redirect_listen_address`) value, for example by using a different port for each account.
213215

216+
- Some providers require the use of SHA-256 PKCE code challenges instead of client secrets. To use this method, set
217+
`client_secret = pkce` as shown in the Fastmail example below.
218+
214219
Integration with a secrets manager:
215220
- The proxy caches authenticated OAuth 2.0 tokens and associated metadata back into this configuration file by
216221
default, but can alternatively be configured to use either a separate local file (via `--cache-store /path/to/file`)
@@ -239,6 +244,13 @@ redirect_uri = http://localhost
239244
client_id = *** your client id here ***
240245
client_secret = *** your client secret here ***
241246

247+
[your.email@fastmail.com]
248+
permission_url = https://api.fastmail.com/oauth/authorize
249+
token_url = https://api.fastmail.com/oauth/refresh
250+
oauth2_scope = https://www.fastmail.com/dev/protocol-imap https://www.fastmail.com/dev/protocol-pop https://www.fastmail.com/dev/protocol-smtp
251+
client_id = *** your client id here ***
252+
client_secret = pkce
253+
242254
[your.email@yahoo.co.uk]
243255
permission_url = https://api.login.yahoo.com/oauth2/request_auth
244256
token_url = https://api.login.yahoo.com/oauth2/get_token
@@ -271,14 +283,22 @@ oauth2_flow = client_credentials
271283
client_id = *** your client id here ***
272284
client_secret = *** your client secret here (remove this entire line if a secret is not required) ***
273285

274-
[ropcg.flow.configured.address@your-tenant.com]
286+
[ropcg.flow.scope.configured.address@your-tenant.com]
275287
documentation = *** note: this is an advanced O365 account example; in most cases you want the version above instead ***
276288
token_url = https://login.microsoftonline.com/*** your tenant id here ***/oauth2/v2.0/token
277289
oauth2_scope = https://outlook.office365.com/IMAP.AccessAsUser.All https://outlook.office365.com/POP.AccessAsUser.All https://outlook.office365.com/SMTP.Send offline_access
278290
oauth2_flow = password
279291
client_id = *** your client id here ***
280292
client_secret = *** your client secret here (remove this entire line if a secret is not required) ***
281293

294+
[ropcg.flow.resource.configured.address@your-tenant.com]
295+
documentation = *** note: this is an advanced O365 account example specific to providers that use a non-standard version of the ROPCG flow (such as 21Vianet); in most cases you want the version above instead ***
296+
token_url = https://login.partner.microsoftonline.cn/*** your tenant id here ***/oauth2/token
297+
oauth2_resource = https://partner.outlook.cn
298+
oauth2_flow = password
299+
client_id = *** your client id here ***
300+
client_secret = *** your client secret here (remove this entire line if a secret is not required) ***
301+
282302
[service.account.accessible.address@your-domain.com]
283303
documentation = *** note: this is an advanced Google account example; in most cases you want the version above instead ***
284304
token_url = https://oauth2.googleapis.com/token

0 commit comments

Comments
 (0)