Repository navigation
Add :access_token option for Microsoft Entra ID token login - #616
Open
lucaspearson wants to merge 2 commits into
Open
lucaspearson wants to merge 2 commits into
lucaspearson wants to merge 2 commits into
Conversation
Azure SQL, Azure Synapse and Microsoft Fabric accept Microsoft Entra ID access tokens, and Fabric Warehouse accepts no other login. Add an :access_token connection option (a String, or a callable invoked at connect time so each connection gets a fresh token). It sets the token on the login with DBSETLACCESSTOKEN and drops :username and :password. It also selects TDS 7.4, which federated authentication requires, unless :tds_version is given. This needs FreeTDS with federated authentication support. Without DBSETLACCESSTOKEN, using the option raises TinyTds::Error. Refs rails-sqlserver#221, rails-sqlserver#512 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an
:access_tokenconnection option for Microsoft Entra ID (formerly Azure AD) token login to Azure SQL, Azure Synapse and Microsoft Fabric. Fabric Warehouse accepts no other login. Refs #221, #512.Change
:access_tokentakes a String, or a callable invoked at connect time so each new connection gets a fresh token.DBSETLACCESSTOKEN, drops:usernameand:password, and selects TDS 7.4 (which federated authentication needs) unless:tds_versionis given.DBSETLACCESSTOKEN, using the option raisesTinyTds::Error, so a stock FreeTDS build behaves as before for everyone else.Depends on FreeTDS support: FreeTDS/freetds#754 adds
DBSETLACCESSTOKEN(FEDAUTH security token). Fabric also needs FreeTDS/freetds#755 (routing tohost\instance). Until those ship, the option compiles out to the error above, so this PR is safe to merge before them. The ports' bundled FreeTDS would need a release that includes them.Testing:
TinyTds::Erroron the test server, which can't validate a token, and on stock FreeTDS.Questions for you: should the callable be re-invoked on reconnect inside TinyTDS, or is a new
Clientper connection (as ActiveRecord does) the expected pattern? And would you rather the error be anArgumentError?🤖 Generated with Claude Code