Skip to content

[Bug] OPTIONS preflight check is beaking the connection #803

Open
@sgadot

Description

@sgadot

Library version used

1.14.3

Java version

--

Scenario

Other - please specify

Is this a new or an existing app?

The app is in production, I haven't upgraded MSAL, but started seeing this issue

Issue description and reproduction steps

The context :

Third party app using MSAL4J for database Auth is trying to connect to a database using Microsoft JDBC driver.
This has been reproduced using :

  • Knime Analytics platform
  • DBEAVER Comminity edition

Login and navigation has been tested with

  • Brave Version 1.64.109 Chromium: 123.0.6312.58 (Build officiel) (64 bits)
  • Microsoft EDGE Version 123.0.2420.53 (Version officielle) (64 bits)

The flow is as follow

  1. App tries to connect
  2. Opens browser and connects to https://login.microsoftonline.com/common/oauth2/v2.0/authorize?scope=openid+profile+offline_access+https%3A%2F%2Fdatabase.windows.net%2Fuser_impersonation&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A51355%2F
  3. User logs in
  4. The browser then does a preflight check to localhost:
    image
    image
  5. the library fails with error:
    ERROR Microsoft Authentication 4:2 com.microsoft.aad.msal4j.MsalClientException: No Authorization code was returned from the server
  6. the POST to localhost fails because socket has been closed

Relevant code snippets

No response

Expected behavior

OPTION Preflight check from the browser should be ignored and it should wait for the real POST payload

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

Things are OK if the browser does not perform preflight check

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working, needs an investigation and a fixRequires more infoMore information is needed, from either the person who opened the issue or another teampublic-clientFor questions/issues related to public client apps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions