Email OAuth2 Proxy

Microsoft Screws Their Users… Again…

 

Desktop Outlook Banned From Outlook.com and Hotmail.com POP3

Microsoft had stopped allowing users of their premium Outlook desktop product (versus the useless, neutered “Outlook” wannabe bloatware “Outlook for Windows” included force installed in Windows 11) to access their “free” @hotmail.com and @outlook.com emails via POP3 and SMTP (secured or not), forcing everyone to use effectively use IMAP mode (links here and here, backup here).

Leaving discussions over any reasons (e.g. financial greed trying to force clueless desktop Outlook + “free” MS email-using people to pay for more storage) and the sheer stupidity of forcing this down Outlook users’ throats (against, say, everyone else like those using Thunderbird or other third-party email clients) aside, I had simply left this aside, relying on my trusty K-9 Mail on Android to access any emails on these “throw-away” accounts…

Unfortunately, there were a few emails (mainly shopping-related receipts) that I wanted to keep – so once again, I had to roll-up my sleeves and fix shit Microsoft breaks get things working…

Google search basically found me Email OAUTH2 Proxy nearly immediately… Attempts at simply using the Docker image did not go so smoothly, so I ended up using pipx and did a “bare metal” install..

 

Trying To Understand/Explain Things

Furthermore, I found the author’s README.md hard to understand, so I decided to whip up my “own” documentation, based more around an intended outcome (that may require multiple switches/options used together), than say, explaining individual switches.

Since some explanation sections covers multiple points, I have used separate multiple sub-section headers denoting what/which point/s a singular section would resolve/be relevant to/answer.

 

OAUTH2 Client_ID and Microsoft

For the “free” @outlook.com and @hotmail.com services (it’s never free – you pay with your information), the bastards people at Microsoft have disabled the use of custom clients (unless you jump through a lot of hoops and/or pay a lot of money). Therefore, this configuration uses Thunderbird’s public client_id (i.e. the proxy is identifying itself, during OAUTH2 token generation, that it is “a Thunderbird email client”).

 

Headless Mode

This configuration runs “headless” (i.e. --no-gui) and as a background service (i.e. no manual input interaction) with all console output pushed to a log file. There are considerations to be aware of due to the latter point – refer to the section “New Accounts and OAUTH2 Token Generation“.

Refer to * footnote.

 

Single Domain Configuration

Wildcard Mode

Adding Users Semi-Automatically

To prevent me from having to manually create and repeat configuration snippets for every account, and also minimise the ports count (i.e. one port per domain and service vs. one for each account and service), I configured emailproxy to use wildcards per domain (i.e. allow_catch_all_accounts), allowing me to configure each server type (and service port) once, where any attempts to log in with a here-to-fore unknown email address (on said domain) or unknown password (refer to ‘How EmailProxy Determines An Account as “New”‘) would trigger the OAUTH2 token generation ceremony.

Refer to * footnote.

 

New Accounts and OAUTH2 Token Generation

Disabling “ANY” User Creation

Any manual actions required of the OAUTH2 token generation ceremony (like copying the temporary authentication URL for actual browser-based authentication then “pasting” the token as input) has to be done only in interactive mode (i.e. run the email-oauth2-proxy-manual.sh script). By virtue of this point, not just anyone, because of your use of “wildcard” domain, can use/abuse your proxy.

  • stop  the service
    • systemctl stop emailoauth2proxy
  • run the script interactively in the foreground
    • /opt/emailproxy/email-oauth2-proxy-manual.sh
  • run the email client with the “new” account, using a complex password (that has to be re-used for this account henceforth)
    • copy the authentication URL and access using standard browser with no existing logged in sessions for said OAUTH2 domain (e.g. use “incognito mode”)
    • run through the authentication process
      • it will end in a redirect to “http://localhost:8080” with a 404 – this is expected
      • copy the entire URL and paste it back (as input) to the running emailproxy process (which will be waiting for the input on the console)
    • force a check again (e.g. using Outlook’s “Send/Receive Groups” pull-down and selecting the correct Hotmail.com/Outlook.com account to “pull” the “Inbox”)
  • stop (CTRL-C) the emailproxy process/thread and (re)start the service
    • systemctl start emailoauth2proxy

* Because of the out-of-band authentication and no HTTP interface of emailproxy, the process can only be, at best, semi-automated. i.e. You will need to execute any new OAUTH2 token generation process from the server directly.

 

Disabling Auto Force New Token Generation

Separating Credentials Best Practice

Enforcing “Basic/Simple” Authentication

How EmailProxy Determines An Account Is “New”

Since --cache-store specifies a separate file, any actual accounts’ tokens and other (copied) settings (from the “wildcard” source service) will be stored in said separate file, encrypted by the initial password used during OAUTH2 token generation.

I consider this “best practice” as I only need to review said file for changes.

By default (i.e. “delete_account_token_on_password_error = True“), emailproxy assumes any failure to decrypt any existing data (or finds missing data) from individual account sections means (re-)triggering a new OAUTH2 token generation ceremony/process.

By using “delete_account_token_on_password_error = False“, any failure in decrypting encrypted data of the account would not (re-)trigger a new OAUTH2 token generation ceremony/process.

Although if missing data, or if the account section was completely missing (i.e. new), the OAUTH2 token generation ceremony/process would still be triggered (and correctly so).

This acts as a sort of “basic/simple” security check – not anyone can just attempt to use your generated token and get access to your email – only when attempting to authenticate with the same password used during the initial OAUTH2 token generation ceremony/process will the client be successful.

 

Continue reading

Upgrading WSL2 Ubuntu LTS 22.04 to LTS 24.04…

After fixing WSL networking issues, I had to upgrade the Ubuntu LTS instance… The sequence should have been:

  • apt update
  • apt upgrade -y
  • apt dist-update
  • lsb_release -a   # to confirm version before upgrade
  • do-release-upgrade
  • lsb_release -a   # to confirm version after upgrade

But, as per usual, I hit another issue attempting to upgrade (i.e. while running do-release-upgrade):

error: cannot list snaps: cannot communicate with server: Get "http://localhost/v2/snaps": dial unix /run/snapd.socket: connect: no such file or directory

A quick ‘net search brought up the point that snapd was not running…

Continue reading

Windows 11 Host Network Service (HNS) and Windows Subsystem for Linux (WSL)…

For the longest time, my Ubuntu LTS 22.04 on my (forced-to-be-updated-to) Windows 11 (replete with other networking horrors) was not working properly – I could only access the Internet from within the WSL2 container when Windows Firewall was disabled.

Despite shenanigans like attempting to whitelist a whole plethora of executables:

  • C:\Windows\System32\vmcompute.exe
  • C:\Windows\System32\vmms.exe
  • C:\Windows\System32\vmwp.exe
  • C:\Windows\System32\wsl.exe
  • C:\Program Files\WSL\wsl.exe
  • C:\Program Files\WSL\wslservice.exe

Even attempting to whitelist the usual services suspects via C:\Windows\System32\svchost.exe like the following:

  • Host Network Service
  • Internet Connection Sharing (ICS)

All were to no avail. I could resolve domain names, but no traffic went out unless the host’s Windows Firewall was disabled.

I could not even see any blocked traffic from the logs, despite having the correct set up (tip: just use WFC‘s logging interface).

Searching ChatGPT and Perplexity sent me on various wild-goose chases, from changing WSL networking modes (NAT vs. “mirrored” in %USERPROFILE%/.wslconfig), to setting up dubious firewall rules referencing InterfaceAlias using New-NetFirewallRule (but which actual interface UUIDs change every boot). Continue reading

Making the Intel X710-DA4 Work…

Apparently, making this 4x SFP+ card work is not as straight forwards as I thought…

  • LACP (aka Link Aggregation aka 802.3ad) would not work properly under Linux, Windows, VMware or FreeBSD unless a “private flag” was disabled using ethtool (source #1, #2)

Sigh, so much for “plug and play pray”…

As per the source/s instructions, I created a /etc/networkd-dispatcher/configuring.d/90-disable-on-chip-LLDP.sh:

#!/bin/sh
if expr "$IFACE" : <interface prefix> >/dev/null; then /sbin/ethtool --set-priv-flags "$IFACE" disable-fw-lldp on fi

WARNING: Make sure your <interface prefix> is able to only address the X710 interfaces, or you will likely get errors or, worse, brick your NIC. As an example, my X710 interfaces are all named enp1s0fN so I use the <interface prefix> of “enp1s0f”

To check, simply give the command ethtool --show-priv-flags <interface prefix>.

 

2026/04/21 Update:

After recently rebuilding and using passthrough of the X710-DA4 ports to pfSense in an attempt to boot performance, the instructions have to change since FreeBSD (and pfSense in turn) do not have ethtool. Instead, set the System Tunabledev.ixl.n.fw_lldp” to “0“, where n is the 0-based port number (0 to 3 in my case of a four-port card).

netplan Not Going To Plan…

With a /etc/netplan/00-global.yaml having the following contents:

network:
  version: 2
  renderer: networkd

And all other .yaml files in the /etc/netplan directory not having an explicit renderer, the system should default to networkd… Just netplan apply and done! Simple, right?

Yeah, right.

Seems like netplan apply still thinks to use NetworkManager even when no single .yaml file declares its use; and since I disabled and masked the service, netplan apply was complaining NetworkManager was masked.

The secret sauce?

Continue reading

Forcing Graphics Mode/s on Ubuntu…

I found myself wrestling with XGA (1024×768) output on a system with only VGA output, although I was aware the display controller could get up to FHD easily (xrandr output shows the maximum “width” and “height” values surpassing that of FHD – see screenshot/s below).

I managed to wrangle the output to FHD by doing the following:

  • get existing displays and note current display
    • xrandr --listmonitors
  • get existing modes
    • xrandr
  • if adding a new mode (e.g. forcing FHD aka 1080p aka 1920×1080 on a VGA output):
    • get new mode details
      • cvt <width> <height> <refresh rate>
      • e.g. cvt 1920 1080 60
    • copy the output after the “Modeline” – this will be the input for next command
    • create the new mode
      • xrandr --newmode <text after "Modeline" from cvt output>
    • add the new mode
      • xrandr --addmode <display> <mode name>
      • e.g. xrandr --addmode VGA-1 "1920x1080_60.00"
  • change the mode
    • xrandr --output <display> --mode <mode name>

Making this stick was a completely different story in frustration…

Continue reading

update-initramfs Couldn’t Identify Root File System for fsck Hook…

Well, as the title implies, I was running update-initramfs -u on my Ubuntu installation after having (i) duplicated the SSD from another existing system, and (ii) having rebuilt a kernel driver (which then required the aforementioned update-initramfs command).

Unfortunately, the command threw back a “W: Couldn't identify type of root file system for fsck hook” error…

Continue reading

x11vnc Copy-and-Paste…

To prevent typos and OS line break-type kerfuffles, I typically copy files instead of copy-pasting any files’ contents across VNC sessions.

Somehow, I came across wanting to just copy-paste a file via a VNC session, which used to work ye long ago… But it just was not happening…

Diving into the ‘net for answers, I came across autocutsel… Although some places stated to use xstartup files, as I was using x11vnc, this was not possible, so I simply ended up creating a services file (with a dependency on the x11vnc service):

Continue reading

The Qotom C3758R Unit Continued…

Just a quick update on networking experiences with this fanless (but hot) unit…

 

Why Is It Not In Sync? (buy buy buy)…

For some odd reason, throughput on stock Ubuntu 24.04 LTS via a 10GbE SFP+ module was showing asymmetrical speeds on iperf3 – ~10Gbps in, but only ~6Gbps out. Checking the firewall, ensuring jumbo packets (9000 byte MTU), ensuring ufw was disabled, disabling all forms of NIC offloading (although this may actually be inverse to the intended) did not change anything. Furthermore, htop showed one core constantly maxing out when sending (but hovering 60% to 75% on receiving).

Continue reading