Skip to content

Client credentials authentication - token cache returns unintended auth token #2334

@malkaviancz

Description

@malkaviancz

Driver version

> 12.2.x

SQL Server version

Microsoft Azure SQL Data Warehouse (RTM) - 12.0.2000.8

Client Operating System

macOS Sonoma 14.3.1

JAVA/JVM version

jdk 17

Problem description

Using client credentials to authenticate, create 2 connections with a valid and an invalid client secret (in that order)

Expected behavior

The second connection attempt should throw SQLException stating invalid client secret provided

Actual behavior

The second connection succeeds, no exception was thrown

Any other details that can be helpful

With client credentials, after any successful authentication attempt, the auth token will be saved in the token cache, and subsequent connection with only client secret changed incorrectly returns the previous token
Tested and reproduceable on versions > 12.2.x
Previous versions doesn't use the token cache and behaved as expected

Repro code

public class Application {

    public static void main(String[] args) throws SQLException {
        String url = "jdbc:sqlserver://**************************-**************************.datawarehouse.fabric.microsoft.com;authentication=ActiveDirectoryServicePrincipal";
        String clientId = "clientId";
        String clientSecret = "clientSecret";
        String invalidClientSecret = "invalidClientSecret";

        try (Connection connection = DriverManager.getConnection(url, clientId, clientSecret);
             Connection invalidConnection = DriverManager.getConnection(url, clientId, invalidClientSecret)) {
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Closed Issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions