Skip to content

Commit a43fa2e

Browse files
committed
Merge branch 'issue-213' into main. Closes #213
2 parents 3a4c50a + 183bf9f commit a43fa2e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ The [sample configuration file](https://github.com/simonrob/email-oauth2-proxy/b
7575

7676
The proxy also supports the [client credentials grant](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow) and [resource owner password credentials grant](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth-ropc) OAuth 2.0 flows if needed.
7777
Please note that currently only Office 365 is known to support these methods.
78-
In addition, when using the client credentials grant flow, Office 365 only supports IMAP/POP, [_not_ SMTP](https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth#use-client-credentials-grant-flow-to-authenticate-imap-and-pop-connections) (use [smtp2graph](https://github.com/EvanTrow/smtp2graph) instead here).
7978
See the [sample configuration file](https://github.com/simonrob/email-oauth2-proxy/blob/main/emailproxy.config) for further details.
8079

8180

emailproxy.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ def save(store_id, config_dict):
340340

341341

342342
class AWSSecretsManagerCacheStore(CacheStore):
343-
# noinspection PyGlobalUndefined,PyPackageRequirements
344343
@staticmethod
345344
def _get_boto3_client(store_id):
346345
try:
346+
# noinspection PyGlobalUndefined
347347
global boto3, botocore
348348
import boto3
349349
import botocore.exceptions
@@ -752,7 +752,11 @@ def get_account_with_catch_all_fallback(option):
752752
try:
753753
# if both secret values are present we use the unencrypted version (as it may have been user-edited)
754754
if client_secret_encrypted and not client_secret:
755-
client_secret = cryptographer.decrypt(client_secret_encrypted)
755+
try:
756+
client_secret = cryptographer.decrypt(client_secret_encrypted)
757+
except InvalidToken as e: # needed to avoid looping as we don't remove secrets on decryption failure
758+
Log.error('Invalid password to decrypt', username, 'secret - aborting login:', Log.error_string(e))
759+
return False, '%s: Login failed - the password for account %s is incorrect' % (APP_NAME, username)
756760

757761
if access_token or refresh_token: # if possible, refresh the existing token(s)
758762
if not access_token or access_token_expiry - current_time < TOKEN_EXPIRY_MARGIN:
@@ -2272,7 +2276,9 @@ class App:
22722276
"""Manage the menu bar icon, server loading, authorisation and notifications, and start the main proxy thread"""
22732277

22742278
def __init__(self, args=None):
2275-
global CONFIG_FILE_PATH, CACHE_STORE, EXITING, prompt_toolkit
2279+
# noinspection PyGlobalUndefined
2280+
global prompt_toolkit
2281+
global CONFIG_FILE_PATH, CACHE_STORE, EXITING
22762282
EXITING = False # needed to allow restarting when imported from parent scripts (or an interpreter)
22772283

22782284
parser = argparse.ArgumentParser(description='%s: transparently add OAuth 2.0 support to IMAP/POP/SMTP client '

0 commit comments

Comments
 (0)