Skip to content

FEAT: Adding authentication module and adding new auth types #135

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

Merged
merged 15 commits into from
Jul 17, 2025

Conversation

jahnvi480
Copy link
Contributor

@jahnvi480 jahnvi480 commented Jul 14, 2025

ADO Work Item Reference

AB#37905
AB#37927
AB#37926


Summary

This pull request introduces significant enhancements to the mssql-python package, focusing on expanding authentication support and improving connection string handling. The most notable changes include adding support for new Azure Active Directory (AAD) authentication methods, implementing a dedicated authentication module, and integrating these updates into the connection handling logic.

Authentication Enhancements:

  • Expanded AAD Authentication Methods: The documentation (README.md) now reflects support for additional authentication methods, including ActiveDirectoryInteractive (via browser), ActiveDirectoryDeviceCode (for environments without browser access), and ActiveDirectoryDefault (which selects the best method based on the environment). Notes were added to clarify usage and constraints for these methods.

  • New auth.py Module: Introduced a dedicated module (mssql_python/auth.py) to handle AAD authentication. This module includes:

    • Support for DefaultAzureCredential, DeviceCodeCredential, and InteractiveBrowserCredential for token retrieval.
    • Utility functions for processing connection string parameters, removing sensitive data, and generating SQL Server-compatible token structures.

Connection Handling Updates:

  • Integration of Authentication Logic: The process_connection_string function from the new auth.py module was integrated into the connection initialization process in mssql_python/connection.py. If the connection string specifies an AAD authentication type, it is processed to remove sensitive parameters and include the appropriate authentication token in attrs_before.

  • Import Update: The process_connection_string function was imported into mssql_python/connection.py to enable the integration of the new authentication logic.

@Copilot Copilot AI review requested due to automatic review settings July 14, 2025 06:54
@github-actions github-actions bot added the pr-size: medium Moderate update size label Jul 14, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces comprehensive Azure Active Directory (AAD) authentication enhancements to the mssql-python package, expanding authentication method support and implementing a dedicated authentication module for improved connection handling.

  • Adds support for three new AAD authentication methods: ActiveDirectoryInteractive, ActiveDirectoryDeviceCode, and ActiveDirectoryDefault
  • Implements a new authentication module (auth.py) with token handling and credential management
  • Integrates the authentication logic into the existing connection initialization process

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
mssql_python/auth.py New authentication module implementing AAD token handling, credential management, and connection string processing
mssql_python/connection.py Integrates authentication processing into connection initialization with import and conditional logic
README.md Updates documentation to reflect new authentication methods and cross-platform support with usage notes

@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Jul 14, 2025
Copy link
Collaborator

@bewithgaurav bewithgaurav left a comment

Choose a reason for hiding this comment

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

need to add tests here. logic looks good.

@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Jul 15, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Jul 15, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Jul 16, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Jul 16, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Jul 16, 2025
bewithgaurav
bewithgaurav previously approved these changes Jul 16, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Jul 16, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Jul 16, 2025
@jahnvi480 jahnvi480 merged commit 0374aa2 into main Jul 17, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-size: medium Moderate update size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants