Skip to content

Improving the auth handler configuration design - #644

Open
Rodrigo Brandão (rodrigobr-msft) wants to merge 5 commits into
mainfrom
users/robrandao/auth-handler
Open

Rodrigo Brandão (rodrigobr-msft) wants to merge 5 commits into
mainfrom
users/robrandao/auth-handler

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

Summary

Refactor OAuth handler configuration around AuthHandlerSettings, aligning it with the SDK's shared configuration infrastructure.

  • Introduce dataclass-based settings with from_mapping and from_configuration support.
  • Accept settings objects or mappings through the settings constructor argument across authorization handlers.
  • Preserve legacy AuthHandler construction and exports, while deprecating it and the auth_handler/auth_handler_settings arguments.
  • Preserve environment-based configuration, scope parsing, and alternate blueprint settings.

Tests

  • Add 38 cases covering initialization and configuration variants across user, agentic, and connector authorization.
  • Migrate tests from the removed private _from_settings helper.
  • Filter expected deprecation warnings while explicitly verifying warning emission.

Validation

  • 1,396 application and authentication telemetry tests passed.
  • Black, flake8, and whitespace checks passed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Directly constructed AuthHandlerSettings retain auth_type casing, causing supported settings-object paths to reject values such as "UserAuthorization" with a ValueError.

1 open issue
What changed in this PR

Refactors OAuth handler configuration around AuthHandlerSettings, integrating authorization handlers with the SDK’s shared configuration infrastructure while retaining deprecated legacy APIs.

Changes:

  • Adds dataclass-based settings with mapping and configuration loaders.
  • Updates authorization handlers and public exports to support the new settings API.
  • Adds configuration and compatibility tests, including deprecation-warning checks.
File Description
tests/​hosting_core/​app/​_oauth/​test_authorization.py Tests settings inputs, configuration loading, and legacy argument warnings.
tests/​hosting_core/​app/​_oauth/​test_auth_handler.py Tests settings normalization, defaults, and legacy construction.
pytest.ini Filters expected authentication deprecation warnings.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​oauth/​authorization.py Loads and dispatches handlers using the new settings type.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​oauth/​auth_handler.py Introduces AuthHandlerSettings and retains deprecated AuthHandler.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​oauth/​_handlers/​connector_user_authorization.py Accepts the new settings argument for connector authorization.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​oauth/​_handlers/​agentic_user_authorization.py Accepts settings and reads alternate blueprint configuration from resolved settings.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​oauth/​_handlers/​_user_authorization.py Removes an unused import.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​oauth/​_handlers/​_authorization_handler.py Resolves settings inputs and warns on deprecated arguments.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​oauth/​__init__.py Exports AuthHandlerSettings from OAuth.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​app_options.py Updates application authorization settings annotations.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​app/​__init__.py Exports the new settings type and adjusts the export list.
libraries/​microsoft-agents-hosting-core/​microsoft_agents/​hosting/​core/​__init__.py Exports the new settings type from core.
libraries/​microsoft-agents-authentication-msal/​microsoft_agents/​authentication/​msal/​msal_auth.py Removes an unused import.

Review effort: Balanced

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.

2 participants