Skip to content

[Core] Make _enforce_https a module level function#45890

Open
pvaneck wants to merge 1 commit intoAzure:mainfrom
pvaneck:core-enforce-https
Open

[Core] Make _enforce_https a module level function#45890
pvaneck wants to merge 1 commit intoAzure:mainfrom
pvaneck:core-enforce-https

Conversation

@pvaneck
Copy link
Member

@pvaneck pvaneck commented Mar 25, 2026

Closes: #45402

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck marked this pull request as ready for review March 25, 2026 19:31
Copilot AI review requested due to automatic review settings March 25, 2026 19:31
Copy link
Contributor

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

Refactors bearer token credential policies to make _enforce_https a module-level helper, avoiding cross-class protected member access in async policies and aligning sync/async implementations.

Changes:

  • Introduced module-level _enforce_https(request) helper in both azure-core and corehttp authentication policy modules.
  • Updated sync and async bearer token policies to call _enforce_https directly instead of a base-class @staticmethod.
  • Simplified async policy imports by removing the dependency on _BearerTokenCredentialPolicyBase solely for HTTPS enforcement.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
sdk/core/corehttp/corehttp/runtime/policies/_authentication_async.py Switches async policy HTTPS enforcement to module-level _enforce_https.
sdk/core/corehttp/corehttp/runtime/policies/_authentication.py Moves _enforce_https out of _BearerTokenCredentialPolicyBase into module scope and updates call site.
sdk/core/azure-core/azure/core/pipeline/policies/_authentication_async.py Replaces protected cross-class call with direct _enforce_https usage.
sdk/core/azure-core/azure/core/pipeline/policies/_authentication.py Adds module-level _enforce_https, removes the old staticmethod, and updates call site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Refactor staticmethod usage in BearerTokenCredential policies

2 participants