microsoft / go-sqlcmd

The new sqlcmd, CLI for SQL Server and Azure SQL (winget install sqlcmd / sqlcmd create mssql / sqlcmd open ads)
https://learn.microsoft.com/sql/tools/sqlcmd/go-sqlcmd-utility
MIT License
323 stars 56 forks source link

Add support for Azure AD device code authentication #449

Open maskati opened 10 months ago

maskati commented 10 months ago

Currently --authentication-method supports ActiveDirectoryInteractive which uses azidentity.InteractiveBrowserCredential. This limits usage to windowed environments with a web browser.

Consider supporting a new authentication method ActiveDirectoryDeviceCode which would use azidentity.DeviceCodeCredential.

shueybubbles commented 10 months ago

thx for opening an issue! We need to add this method to the driver first.

maskati commented 10 months ago

Now that i think about it, even better would be support for AzureCliCredential, which would allow using an ambient Azure CLI authenticated context (which supports device code authentication) in an SSO manner. Support for this would mean no need to authenticate sqlcmd at all if Azure CLI was already authenticated, which it often is. Should this be a separate request?

shueybubbles commented 10 months ago

--authentication-method ActiveDirectoryDefault includes AzureCliCredential in the search

maskati commented 10 months ago

@shueybubbles great! I didn’t notice that since i assumed ActiveDirectoryDefault was a combination of the other methods directly supported by go-sqlcmd rather than those supported by azidentity.