Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server input plugin - Enable Azure Active Directory (AAD) authentication support #8822

Merged
merged 48 commits into from Apr 21, 2021

Conversation

avinash-nigam
Copy link
Contributor

Required for all PRs:

  • Associated README.md updated.
  • Has appropriate unit tests.

Associated to feature request - Azure Active Directory (AAD) authentication support in SQL Server input plugin

Copy link
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

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

🤝 ✅ CLA has been signed. Thank you!

go.mod Outdated Show resolved Hide resolved
@srebhan srebhan self-assigned this Feb 8, 2021
@masree
Copy link
Contributor

masree commented Feb 11, 2021

I think we should update SQL Server plugin doc (readme) to indicate AAD support using MSI. Also indicate how an AAD login is created on SQL side using TSQL

@avinash-nigam
Copy link
Contributor Author

I think we should update SQL Server plugin doc (readme) to indicate AAD support using MSI. Also indicate how an AAD login is created on SQL side using TSQL

Added content to readme file about its usage and instructions

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Please check my comments in the code. @masree any comments?

@masree
Copy link
Contributor

masree commented Feb 23, 2021

Please check my comments in the code. @masree any comments?

Thank you for the review! Valid comments.

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

I have some comments in the code. The most sever is the potential deadlock when an error occurs in getTokenProvider(). Please take a look and fix the leaking lock.

Copy link
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

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

Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
@avinash-nigam
Copy link
Contributor Author

I have some comments in the code. The most sever is the potential deadlock when an error occurs in getTokenProvider(). Please take a look and fix the leaking lock.

Thank you @srebhan for the review, I've addressed your comments.

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Only some small (cosmetic) things left. Looks good so far.

@avinash-nigam
Copy link
Contributor Author

Only some small (cosmetic) things left. Looks good so far.

Thank you @srebhan for quick review, I've addressed your comments.

Copy link
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@srebhan srebhan added area/sqlserver feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. labels Apr 19, 2021
@sspaink
Copy link
Contributor

sspaink commented Apr 20, 2021

How have you been testing it? is there a testing plan you would like to link for us to take a look?
Example -
Scenario1: Telegraf installed on VM and with connection strings using sqlauth only
Scenario2: Telegraf installed on VM with connection strings using sqlauth and aadMSI (multiple connection strings)
and so on

@avinash-nigam I was also wondering about how you tested this? There aren't any unit tests covering this new auth method, what are your thoughts on including tests?

@avinash-nigam
Copy link
Contributor Author

How have you been testing it? is there a testing plan you would like to link for us to take a look?
Example -
Scenario1: Telegraf installed on VM and with connection strings using sqlauth only
Scenario2: Telegraf installed on VM with connection strings using sqlauth and aadMSI (multiple connection strings)
and so on

@avinash-nigam I was also wondering about how you tested this? There aren't any unit tests covering this new auth method, what are your thoughts on including tests?

@sspaink - This has been manually tested for databases of following variants individually and a combination of multiple variants by deploying the bits on an Ubuntu VM and settings connection strings to use SqlAuth and AADAuth (both as supported cases and not supported cases) -

Azure SQL Database - S1, S2 (AAD supported)
Azure SQL Elastic Pool Database - S0, S2 (AAD supported)
SQL VM - 2012, 2014, 2016, 2019 (AAD not supported)
SQL AG (HADR) - 2019 (AAD not supported)

Currently this plugin does not support integration testing, so there are no tests for authentication yet. Once we build a mechanism to write integration tests, then we would be able to add tests for the same.

@sspaink sspaink merged commit f39d68d into influxdata:master Apr 21, 2021
@cerilewis
Copy link

This change appears to break Windows Integrated authentication where no User ID or Password is given in the connection string. If I run telegraf version 1.19.0-rc0 with configuration that works with 1.18.3 I get the following error:
2021-06-14T09:35:28Z E! [inputs.sqlserver] Error in plugin: database connection failed : AAD auth is not supported for SQL VM i.e. DatabaseType=SQLServer

This appears to come from the check for Password attribute being used to determine whether to user SQL Server authentication or AAD.

@srebhan
Copy link
Contributor

srebhan commented Jun 14, 2021

@cerilewis thanks for reporting this problem! Can you please open an issue and link to this PR. I fear that we need to add an option to specify which auth-scheme to use as the magic here will likely not be able to detect it... :-(

@cerilewis
Copy link

@srebhan I have created the issue #9362 but either can't or don't know how to link this PR to it correctly.

@srebhan
Copy link
Contributor

srebhan commented Jun 14, 2021

You already did by mentioning this PR in the issue. :-) Thank you for reporting.

@arkapravasinha
Copy link

can anyone please share any example how to enable AAD?

@srebhan
Copy link
Contributor

srebhan commented Sep 6, 2023

@arkapravasinha please do not post support questions to old PRs! Nobody will notice them besides me. ;-) Better use the forum or Slack!

This being said, how about reading the docs and use auth_method = "aad"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sqlserver feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure Active Directory (AAD) authentication support in SQL Server input plugin
6 participants