-
-
Couldn't load subscription status.
- Fork 124
Description
Hi,
i'm trying to setup the proxy on an Azure VM. I've tried using CentOS 7.9 and currently Ubuntu 20.04.
But everytime it's ending with this error:
Authorisation result error for - aborting login. OAuth 2.0 authorisation response is missing or does not match redirect_uri
this is my configuration:
I'm using python3 (3.8.10)
Since this is a cloud server without GUI, I'm using the local auth server option. Azure does not set the public IP address on the VM, but set an internal IP on the interface. Therefor i'm using the redirect listening address option.
Also, the Azure AD Enterprise Applications require the Redirect UI to be HTTPS, so i'm proxying https to http via nginx on the server.
this is my configuration for the proxy:
[IMAP-1993]
local_address = 10.2.0.14
server_address = outlook.office365.com
server_port = 993
permission_url = https://login.microsoftonline.com/<tenant-id-redacted>/oauth2/v2.0/authorize
token_url = https://login.microsoftonline.com/<tenant-id-redacted>/oauth2/v2.0/token
oauth2_scope = https://outlook.office365.com/IMAP.AccessAsUser.All https://outlook.office365.com/POP.AccessAsUser.All https://outlook.office365.com/SMTP.Send
redirect_uri = https://public-azure-vm-fqdn:8443/oauth
redirect_listen_address = http://10.2.0.14:8080
client_id = <client-id-redacted>
client_secret = <client-secret-redacted>
the azure ad enterprise application / app registration has the following configuration:
redirect uri: https://public-azure-vm-fqdn:8443/oauth
delegated permissions for MS Graph: IMAP.AccessAsUser.All, offline_access, POP.AccessAsUser.All, SMTP.Send, User.Read
secret: <client-secret-redacted>
tenant: multi-tenant (any organization)
Allow public client flows: true
when im trying to authenticate this happens:
2022-11-28 09:02:55: Initialising Email OAuth 2.0 Proxy from config file /root/email-oauth2-proxy/emailproxy.config
2022-11-28 09:02:55: Starting IMAP server at 10.2.0.14:1993 (unsecured) proxying outlook.office365.com:993 (SSL/TLS)
2022-11-28 09:02:55: Starting POP server at 10.2.0.14:1995 (unsecured) proxying outlook.office365.com:995 (SSL/TLS)
2022-11-28 09:02:55: Starting SMTP server at 10.2.0.14:1587 (unsecured) proxying smtp.office365.com:587 (STARTTLS)
2022-11-28 09:02:55: Initialised Email OAuth 2.0 Proxy - listening for authentication requests. Connect your email client to begin
2022-11-28 09:03:01: New incoming connection to IMAP server at 10.2.0.14:1993 (unsecured) proxying outlook.office365.com:993 (SSL/TLS)
2022-11-28 09:03:01: Accepting new connection to IMAP server at 10.2.0.14:1993 (unsecured) proxying outlook.office365.com:993 (SSL/TLS) via ('<public-client-ip-redacted>', 54970)
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) --> [ Client connected ]
2022-11-28 09:03:01: IMAP (10.2.0.14:1993;<public-client-ip-redacted>:54970->outlook.office365.com:993) <-> [ Starting TLS handshake ]
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-> [ TLS handshake complete ]
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-- b'* OK The Microsoft Exchange IMAP4 service is ready. [QQBNADAAUABSADAAMwBDAEEAMAAwADIAOAAuAGUAdQByAHAAcgBkADAAMwAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A]\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; 93.229.197.194:54970->outlook.office365.com:993) <-- b'* OK The Microsoft Exchange IMAP4 service is ready. [QQBNADAAUABSADAAMwBDAEEAMAAwADIAOAAuAGUAdQByAHAAcgBkADAAMwAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A]\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) --> b'68 capability\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) --> b'68 capability\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-- b'* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-- b'* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-- b'68 OK CAPABILITY completed.\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-- b'68 OK CAPABILITY completed.\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) --> b'69 authenticate PLAIN\r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-- b'+ \r\n'
2022-11-28 09:03:01: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) --> b'[[ Credentials removed from proxy log ]]'
2022-11-28 09:03:02: Authorisation request received for <client-email-address-redacted> (local server auth mode)
2022-11-28 09:03:02: Email OAuth 2.0 Proxy Local server auth mode: please authorise a request for account <client-email-address-redacted>
2022-11-28 09:03:02: Local server auth mode (10.2.0.14:8080): starting server to listen for authentication response
2022-11-28 09:03:02: Please visit the following URL to authenticate account <client-email-address-redacted>: https://login.microsoftonline.com/<tenant-id-redacted>/oauth2/v2.0/authorize?client_id=<client-id-redacted>&redirect_uri=https%3A%2F%2F<public-azure-vm-fqdn>%3A8443%2Foauth&scope=https%3A%2F%2Foutlook.office365.com%2FIMAP.AccessAsUser.All%20https%3A%2F%2Foutlook.office365.com%2FPOP.AccessAsUser.All%20https%3A%2F%2Foutlook.office365.com%2FSMTP.Send&response_type=code&access_type=offline&login_hint=<client-email-address-redacted>
2022-11-28 09:03:08: Local server auth mode (10.2.0.14:8080): received authentication response GET /oauth?code=<code-payload-redacted>&session_state=437afde4-a618-4084-8b57-a0185851b504 HTTP/1.0 200 373
2022-11-28 09:03:08: Local server auth mode (10.2.0.14:8080): closing local server and returning response http://public-azure-vm-fqdn/oauth?code=<code-payload-redacted>&session_state=437afde4-a618-4084-8b57-a0185851b504
2022-11-28 09:03:08: Authorisation result error for <client-email-address-redacted> - aborting login. OAuth 2.0 authorisation response is missing or does not match `redirect_uri`
2022-11-28 09:03:08: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-- b'69 NO AUTHENTICATE Email OAuth 2.0 Proxy: Login failed for account <client-email-address-redacted>: OAuth 2.0 authorisation response is missing or does not match `redirect_uri`\r\n'
2022-11-28 09:03:08: IMAP (10.2.0.14:1993; <public-client-ip-redacted>:54970->outlook.office365.com:993) <-- b'* BYE Autologout; authentication failed\r\n'
Authorisation result error for <client-email-address-redacted>- aborting login. OAuth 2.0 authorisation response is missing or does not match `redirect_uri`
what can i do to get this working?