Skip to content

Linux: "Unable to open default system browser" using ActiveDirectoryInteractive authenticationΒ #1610

Open
@tjlee

Description

@tjlee

Driver version

9.2.0

Client Operating System

Linux (5.8.0-50-generic, amd64)

JAVA/JVM version

JRE: 11.0.10+8-b1304.1 (JetBrains s.r.o.)
JVM: 11.0.10+8-b1304.1 (Dynamic Code Evolution 64-Bit Server VM)

Problem description

When user tries to authenticate using ActiveDirectoryInteractive in DataGrip, IDE immediately jumps back without opening a browser window and provides the message "The specified database user/password combination is rejected: Failed to authenticate the user alowed in Active Directory (Authentication=ActiveDirectoryInteractive)."

Current implementation relies on java.awt.Desktop#browse that does not work at least on some linux distributions without required gtk, gvfs libraries.
MSAL4J provides an option to override this behaviour https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/01bb6793bd77c0793a16a4c6091be60b17b54764/src/main/java/com/microsoft/aad/msal4j/SystemBrowserOptions.java#L56
JDBC driver does not expose that functionality
So the problem is with JDBC driver

It looks like OS specific since it works on other Linux machines in our team.

JDBC trace logs

<record>
  <date>2021-05-07T14:21:11.424336Z</date>
  <millis>1620397271424</millis>
  <nanos>336000</nanos>
  <sequence>146</sequence>
  <logger>com.microsoft.sqlserver.jdbc.internals.SQLServerConnection</logger>
  <level>FINE</level>
  <class>com.microsoft.sqlserver.jdbc.SQLServerConnection</class>
  <method>processFedAuthInfo</method>
  <thread>18</thread>
  <message>ConnectionID:1 ClientConnectionId: f5b9ae9a-f0cc-45c8-8ee5-c7ae6a19ffba FedAuthInfoData: https://login.windows.net/644ABBED-2AFC-4AF3-8BEA-ED3FB105FE8C</message>
</record>
<record>
  <date>2021-05-07T14:21:12.276153Z</date>
  <millis>1620397272276</millis>
  <nanos>153000</nanos>
  <sequence>147</sequence>
  <logger>com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils</logger>
  <level>FINE</level>
  <class>com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils</class>
  <method>getSqlFedAuthTokenInteractive</method>
  <thread>18</thread>
  <message>java.util.logging.Logger@5f091686Interactive authentication</message>
</record>
<record>
  <date>2021-05-07T14:21:13.030106Z</date>
  <millis>1620397273030</millis>
  <nanos>106000</nanos>
  <sequence>148</sequence>
  <logger>com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils</logger>
  <level>FINE</level>
  <class>com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils</class>
  <method>getCorrectedException</method>
  <thread>18</thread>
  <message>java.util.logging.Logger@5f091686 MSAL exception:com.microsoft.aad.msal4j.MsalClientException: Unable to open default system browser</message>
</record>
<record>
  <date>2021-05-07T14:21:13.032500Z</date>
  <millis>1620397273032</millis>
  <nanos>500000</nanos>
  <sequence>149</sequence>
  <logger>com.microsoft.sqlserver.jdbc.internals.SQLServerException</logger>
  <level>FINE</level>
  <class>com.microsoft.sqlserver.jdbc.SQLServerException</class>
  <method>logException</method>
  <thread>18</thread>
  <message>*** SQLException: com.microsoft.sqlserver.jdbc.SQLServerException: Failed to authenticate the user alowe in Active Directory (Authentication=ActiveDirectoryInteractive). Failed to authenticate the user alowe in Active Directory (Authentication=ActiveDirectoryInteractive).</message>
</record>
<record>
  <date>2021-05-07T14:21:13.034211Z</date>
  <millis>1620397273034</millis>
  <nanos>211000</nanos>
  <sequence>150</sequence>
  <logger>com.microsoft.sqlserver.jdbc.internals.SQLServerException</logger>
  <level>FINE</level>
  <class>com.microsoft.sqlserver.jdbc.SQLServerException</class>
  <method>logException</method>
  <thread>18</thread>
  <message>com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils.getCorrectedException(SQLServerMSAL4JUtils.java:227)com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils.getSqlFedAuthTokenInteractive(SQLServerMSAL4JUtils.java:183)com.microsoft.sqlserver.jdbc.SQLServerConnection.getFedAuthToken(SQLServerConnection.java:4632)com.microsoft.sqlserver.jdbc.SQLServerConnection.onFedAuthInfo(SQLServerConnection.java:4497)com.microsoft.sqlserver.jdbc.SQLServerConnection.processFedAuthInfo(SQLServerConnection.java:4460)com.microsoft.sqlserver.jdbc.TDSTokenHandler.onFedAuthInfo(tdsparser.java:289)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:125)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:37)com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:5332)com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:4068)com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:85)com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:4006)com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7418)com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3274)com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2768)com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2418)com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2265)com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1291)com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:881)com.intellij.database.remote.jdbc.helpers.JdbcHelperImpl.connect(JdbcHelperImpl.java:617)com.intellij.database.remote.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:43)java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.base/java.lang.reflect.Method.invoke(Method.java:566)java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)java.base/java.security.AccessController.doPrivileged(Native Method)java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)java.base/java.security.AccessController.doPrivileged(Native Method)java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)java.base/java.lang.Thread.run(Thread.java:834)
 
caused by java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to open default system browser
com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils.getCorrectedException(SQLServerMSAL4JUtils.java:225)com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils.getSqlFedAuthTokenInteractive(SQLServerMSAL4JUtils.java:183)com.microsoft.sqlserver.jdbc.SQLServerConnection.getFedAuthToken(SQLServerConnection.java:4632)com.microsoft.sqlserver.jdbc.SQLServerConnection.onFedAuthInfo(SQLServerConnection.java:4497)com.microsoft.sqlserver.jdbc.SQLServerConnection.processFedAuthInfo(SQLServerConnection.java:4460)com.microsoft.sqlserver.jdbc.TDSTokenHandler.onFedAuthInfo(tdsparser.java:289)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:125)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:37)com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:5332)com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:4068)com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:85)com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:4006)com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7418)com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3274)com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2768)com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2418)com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2265)com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1291)com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:881)com.intellij.database.remote.jdbc.helpers.JdbcHelperImpl.connect(JdbcHelperImpl.java:617)com.intellij.database.remote.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:43)java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.base/java.lang.reflect.Method.invoke(Method.java:566)java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)java.base/java.security.AccessController.doPrivileged(Native Method)java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)java.base/java.security.AccessController.doPrivileged(Native Method)java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)java.base/java.lang.Thread.run(Thread.java:834)</message>
</record>

Based on #1586

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementAn enhancement to the driver. Lower priority than bugs.

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions