Skip to content

Commit

Permalink
Managed Identity dev experience improvements (#1936)
Browse files Browse the repository at this point in the history
* New MSI logic with azure identity

* Added new MSI tests

* Added DefaultAzureCredential support

* Amended MSI exception msg

* DefaultAzureCredential tests

* Removed deprecated APIs

* Major version bump

* Revert "Removed deprecated APIs"

This reverts commit ecd0a2a.

* PR comment changes

* Code review changes

* Additional CR comment changes; Deprecated get/set msiClientId; Using user property for managed identity client ID

* Updated tests

* Additonal PR comments

* Formatting changes
  • Loading branch information
tkyc authored Oct 26, 2022
1 parent bf7adc0 commit 095c7ee
Show file tree
Hide file tree
Showing 19 changed files with 393 additions and 325 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

apply plugin: 'java'

version = '11.3.0-SNAPSHOT'
version = '12.1.0-SNAPSHOT'
def jreVersion = ""
def testOutputDir = file("build/classes/java/test")
def archivesBaseName = 'mssql-jdbc'
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>11.3.0-SNAPSHOT</version>
<version>12.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
Expand Down Expand Up @@ -64,7 +64,7 @@
<!-- Driver Dependencies -->
<org.osgi.core.version>6.0.0</org.osgi.core.version>
<azure-security-keyvault-keys.version>4.4.4</azure-security-keyvault-keys.version>
<azure-identity.version>1.5.3</azure-identity.version>
<azure-identity.version>1.7.0-beta.2</azure-identity.version>
<msal.version>1.13.0</msal.version>
<org.osgi.compendium.version>5.0.0</org.osgi.compendium.version>
<antlr-runtime.version>4.9.3</antlr-runtime.version>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@ final class TDS {
static final int TDS_FEDAUTH_LIBRARY_RESERVED = 0x7F;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYPASSWORD = 0x01;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYINTEGRATED = 0x02;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYMSI = 0x03;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYMANAGEDIDENTITY = 0x03;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYINTERACTIVE = 0x03;
static final byte ADALWORKFLOW_DEFAULTAZURECREDENTIAL = 0x03;
static final byte ADALWORKFLOW_ACTIVEDIRECTORYSERVICEPRINCIPAL = 0x01; // Using the Password byte as that is the
// closest we have.
static final byte FEDAUTH_INFO_ID_STSURL = 0x01; // FedAuthInfoData is token endpoint URL from which to acquire fed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,35 +391,34 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold,
* boolean value for 'delayLoadingLobs'.
*/
void setDelayLoadingLobs(boolean delayLoadingLobs);

/**
* Sets the name of the preferred type of IP Address.
*
* @param iPAddressPreference
* A String that contains the preferred type of IP Address.
*/
void setIPAddressPreference(String iPAddressPreference);

/**
* Gets the name of the preferred type of IP Address.
*
* @return IPAddressPreference
* A String that contains the preferred type of IP Address.
* A String that contains the preferred type of IP Address.
*/
String getIPAddressPreference();

/**
* Gets the time-to-live for the the cached MSI token
*
* @return time-to-live for the cached MSI token
* Deprecated. Time-to-live is no longer supported for the cached Managed Identity tokens.
* This method will always return 0 and is for backwards compatibility only.
*/
@Deprecated
int getMsiTokenCacheTtl();

/**
* Sets time-to-live for the the cached MSI token
*
* @param timeToLive
* Changes the setting as per description
* Deprecated. Time-to-live is no longer supported for the cached Managed Identity tokens.
* This method is a no-op for backwards compatibility only.
*/
@Deprecated
void setMsiTokenCacheTtl(int timeToLive);
}
Original file line number Diff line number Diff line change
Expand Up @@ -932,18 +932,24 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
void setUseBulkCopyForBatchInsert(boolean useBulkCopyForBatchInsert);

/**
* Sets the client id to be used to retrieve access token from MSI EndPoint.
* This method is deprecated. Use {@link ISQLServerDataSource#setUser(String user)} instead.
*
* Sets the client id to be used to retrieve the access token for a user-assigned Managed Identity.
*
* @param msiClientId
* Client ID of User Assigned Managed Identity
* @param managedIdentityClientId
* Client ID of the user-assigned Managed Identity.
*/
void setMSIClientId(String msiClientId);
@Deprecated
void setMSIClientId(String managedIdentityClientId);

/**
* This method is deprecated. Use {@link ISQLServerDataSource#getUser()} instead.
*
* Returns the value for the connection property 'msiClientId'.
*
* @return msiClientId property value
*/
@Deprecated
String getMSIClientId();

/**
Expand Down Expand Up @@ -1129,7 +1135,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
/**
* Sets the 'AADSecurePrincipalId' connection property used for Active Directory Service Principal authentication.
*
* @deprecated Use {@link ISQLServerDataSource#setUser(String password)} instead
* @deprecated Use {@link ISQLServerDataSource#setUser(String user)} instead
* @param AADSecurePrincipalId
* Active Directory Service Principal Id.
*/
Expand Down Expand Up @@ -1208,17 +1214,16 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
String getPrepareMethod();

/**
* Sets time-to-live for the the cached MSI token
*
* @param timeToLive
* Changes the setting as per description
* Deprecated. Time-to-live is no longer supported for the cached Managed Identity tokens.
* This method is a no-op for backwards compatibility only.
*/
@Deprecated
void setMsiTokenCacheTtl(int timeToLive);

/**
* Gets the time-to-live for the the cached MSI token
*
* @return time-to-live for the cached MSI token
* Deprecated. Time-to-live is no longer supported for the cached Managed Identity tokens.
* This method will always return 0 and is for backwards compatibility only.
*/
@Deprecated
int getMsiTokenCacheTtl();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package com.microsoft.sqlserver.jdbc;

final class SQLJdbcVersion {
static final int major = 11;
static final int minor = 3;
static final int major = 12;
static final int minor = 1;
static final int patch = 0;
static final int build = 0;
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public SQLServerColumnEncryptionAzureKeyVaultProvider(TokenCredential tokenCrede
* @throws SQLServerException
* when an error occurs
*/
@Deprecated
public SQLServerColumnEncryptionAzureKeyVaultProvider(
SQLServerKeyVaultAuthenticationCallback authenticationCallback) throws SQLServerException {
if (null == authenticationCallback) {
Expand Down
Loading

0 comments on commit 095c7ee

Please sign in to comment.