Skip to content

Conversation

@tkyc
Copy link
Contributor

@tkyc tkyc commented Oct 18, 2022

PR Resolves the following:

Deprecated the following:

New authentication property values:

  • authentication=ActiveDirectoryManagedIdentity
  • authentication=DefaultAzureCredential EDIT: Later changed to authentication=ActiveDirectoryDefault

New environment variables:

  • INTELLIJ_KEEPASS_PATH
  • ADDITIONALLY_ALLOWED_TENANTS (comma delimited list of additionally allowed tenant IDs, used with DefaultAzureCredential)

To use the IntellijCredential with the driver, supply the connection string property authentication=DefaultAzureCredential and set the INTELLIJ_KEEPASS_PATH environment variable to the path of the keepass database.

@lilgreenbird lilgreenbird added this to the 11.3.0 milestone Oct 19, 2022
@lilgreenbird lilgreenbird changed the title Jdbc msi improvements Managed Identity dev experience improvements Oct 20, 2022
Copy link
Collaborator

@David-Engel David-Engel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one other change we need to make to align the JDBC driver with other drivers. We should deprecate the msiClientId get/set methods (but they should continue to work. Comment: "Use the getUser/setUser method instead.") This will include changing the Authentication=ActiveDirectoryMSI validation to allow specifying User in the connection string. If both msiClientId and User are specified, User should override msiClientId.

Copy link
Contributor

@lilgreenbird lilgreenbird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please run formatter looks like a lot of these files aren't formatted

boolean isAzureFunction = null != identityEndpoint && !identityEndpoint.isEmpty() && null != identityHeader
&& !identityHeader.isEmpty();
throw new SQLServerException(SQLServerException
.getErrString("R_ManagedIdentityTokenAcquisitionFail"), null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add more info to the error message to make it easier to debug when there's a failure

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, do we have more info if the Optional task fails or doesn't return a result? I don't know the API well...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What additional info did you have in mind? I'll amend the error message to the following to be more clear as to the reason it is null.

Failed to acquire managed identity token. Request for the token succeeded, but no token was returned. The token is null.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. From the sounds of it, we don't have anything more available. The current iteration looks good.

Copy link
Collaborator

@David-Engel David-Engel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review

boolean isAzureFunction = null != identityEndpoint && !identityEndpoint.isEmpty() && null != identityHeader
&& !identityHeader.isEmpty();
throw new SQLServerException(SQLServerException
.getErrString("R_ManagedIdentityTokenAcquisitionFail"), null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, do we have more info if the Optional task fails or doesn't return a result? I don't know the API well...

@tkyc
Copy link
Contributor Author

tkyc commented Oct 25, 2022

@David-Engel For some reason there's no "reply" button for your comment. I'll just quote you and reply here.

Similarly, do we have more info if the Optional task fails or doesn't return a result? I don't know the API well...

If the Optional task fails, it will throw its own error. The resulting exception, since we're using the Azure Identity credentials, will be a CredentialUnavailableException.

A CredentialUnavailableException indicates the following:

  1. Error in the provided information for the credential eg. wrong client ID of the user-assigned Managed Identity
  2. Connection was dropped mid query for the token

Howerver, there isn't any more available information other than a null token if the Optional succeeds (eg. request for token went through but a null token was returned). In this case, as you suggested (since we shouldn't return null), we'll throw our own error.

@tkyc tkyc merged commit 095c7ee into main Oct 26, 2022
@tkyc tkyc deleted the jdbc-msi-improvements branch October 26, 2022 21:24
Jeffery-Wasty added a commit that referenced this pull request Jan 28, 2025
Jeffery-Wasty added a commit that referenced this pull request Mar 19, 2025
…date (#2602)

* Update build.gradle

* Update pom.xml

* Update pom.xml

* Update pom.xml

* Update pom.xml

* Update pom.xml

* Update pom.xml

* Update pom.xml

* ManagedIdentity I

Signed-off-by: Jeff Wasty <[email protected]>

* Updates for running tests with managed identity (#2416)

Signed-off-by: Jeff Wasty <[email protected]>

# Conflicts:
#	src/test/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionTest.java
#	src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java
#	src/test/java/com/microsoft/sqlserver/jdbc/TestUtils.java
#	src/test/java/com/microsoft/sqlserver/jdbc/connection/TimeoutTest.java
#	src/test/java/com/microsoft/sqlserver/jdbc/databasemetadata/DatabaseMetaDataTest.java
#	src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecutionTest.java

* Delete mistakenly added files

* Delete mistakenly added files

* Revert "Delete mistakenly added files"

This reverts commit 19abc22.

* Revert "Delete mistakenly added files"

This reverts commit 04f8c82.

* Revert "Updates for running tests with managed identity (#2416)"

This reverts commit b727a96.

* Revert "ManagedIdentity I"

This reverts commit 6d5c519.

* Delete garbage

* Fixed Managed Identity tests (#1935)

Signed-off-by: Jeff Wasty <[email protected]>

# Conflicts:
#	src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/MSITest.java

* Managed Identity dev experience improvements #1936

Signed-off-by: Jeff Wasty <[email protected]>

* Updates for running tests with managed identity #2416

Signed-off-by: Jeff Wasty <[email protected]>

* cleanup

Signed-off-by: Jeff Wasty <[email protected]>

* Update tests for Kerberos

Signed-off-by: Jeff Wasty <[email protected]>

* Remove unused test

* tsc=true for ae

Signed-off-by: Jeff Wasty <[email protected]>

* Add tags for testDefaultRetry

* Remove unstable test

Signed-off-by: Jeff Wasty <[email protected]>

* Add throttling error message to tests (#2044)

Signed-off-by: Jeff Wasty <[email protected]>

* Updated fedauth tests to run on diff test server (#2062)

Signed-off-by: Jeff Wasty <[email protected]>

* Update fedauth tests to use cached tokens and retry if throttled (#2077)

Signed-off-by: Jeff Wasty <[email protected]>

* Add back missing import

Signed-off-by: Jeff Wasty <[email protected]>

* Resolve static issue with IOBuffer

Signed-off-by: Jeff Wasty <[email protected]>

* Add back a missing import

* Fixed TestUtils

* Remove mistakenly added code

* Cleanup

* Cleanup testutils

* More cleanup

* Add more time for 'testDefaultRetry' &
Fix tests for testing encrypt options (#2215)

* Update setAEConnectionString

* Updated fedauth error tests (#2538)

Signed-off-by: Jeff Wasty <[email protected]>

# Conflicts:
#	src/test/java/com/microsoft/sqlserver/jdbc/fedauth/ErrorMessageTest.java
#	src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthCommon.java

* Update fedAuth tests

* Revert "Updated fedauth error tests (#2538)"

This reverts commit dfb4b77.

* Revert "Update fedAuth tests"

This reverts commit da5c58b.

* Added ActiveDirectoryServicePrincipalCertificate for tests

* Add 'requireSecret' exclude tag for tests which require adding a secret to app registration

* Version update

* Add connection retry changes from 2513 to ensure existing timing tests pass

* Adjust timings on tests as the fix requires code changes we should not incorporate for this release

* Changelog

* Update dependency versions

---------

Signed-off-by: Jeff Wasty <[email protected]>
Co-authored-by: lilgreenbird <[email protected]>
Co-authored-by: Terry Chow <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants