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

Corehttp auth flows #40084

Merged
merged 14 commits into from
Mar 26, 2025
Merged

Corehttp auth flows #40084

merged 14 commits into from
Mar 26, 2025

Conversation

xiangyan99
Copy link
Member

No description provided.

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@xiangyan99 xiangyan99 marked this pull request as ready for review March 17, 2025 19:10
@Copilot Copilot bot review requested due to automatic review settings March 17, 2025 19:10
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 PR introduces support for the auth_flows keyword in bearer token authentication flows across synchronous and asynchronous pipelines.

  • Updated tests to pass the new auth_flows parameter to request-handling methods.
  • Modified the _authentication and _authentication_async policies to incorporate auth_flows when obtaining tokens.
  • Updated CHANGELOG and added a type-ignore comment for OpenTelemetry context detachment.

Reviewed Changes

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

Show a summary per file
File Description
sdk/core/corehttp/tests/async_tests/test_authentication_async.py Updated test cases to pass auth_flows and modified the token credential method.
sdk/core/corehttp/tests/test_authentication.py Updated assertions and token request options for auth_flows.
sdk/core/corehttp/corehttp/runtime/policies/_authentication.py Changed on_request signature and added auth_flows support in token acquisition.
sdk/core/corehttp/corehttp/runtime/policies/_authentication_async.py Updated asynchronous on_request to support auth_flows.
sdk/core/azure-core/azure/core/tracing/opentelemetry.py Added "# type: ignore" for a detachment call.
sdk/core/azure-core/CHANGELOG.md Documented the addition of auth_flows support in BearerTokenCredentialPolicy.
Comments suppressed due to low confidence (1)

sdk/core/corehttp/tests/async_tests/test_authentication_async.py:278

  • Avoid using mutable default arguments. Change the default value of options to None and initialize it to {} within the function.
async def get_token_info(self, *scopes, options={):

Copy link
Member

@pvaneck pvaneck left a comment

Choose a reason for hiding this comment

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

Can you explain the workflow here and how auth_flows will be used inside a credential's get_token_info method? Not quite sure why we need it at the policy level.

@xiangyan99 xiangyan99 requested a review from pvaneck March 19, 2025 16:11
@pvaneck
Copy link
Member

pvaneck commented Mar 19, 2025

Could you also share some context on how auth_flows will be used inside a credential's get_token_info method?

@xiangyan99
Copy link
Member Author

xiangyan99 commented Mar 19, 2025

Could you also share some context on how auth_flows will be used inside a credential's get_token_info method?

get_token_info needs to get the meta data from auth_flows.

e.g. the credential needs to get the token url to know where the request should be sent to.

Under current design, auth_flows is a list of auth context.

We will share a sample in this release and in the sample, we will assume the first one in the list has the correct meta information for the credential.

@pvaneck pvaneck changed the title Core auth flows Corehttp auth flows Mar 19, 2025
Copy link
Member

@pvaneck pvaneck left a comment

Choose a reason for hiding this comment

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

Actually, looks like wrong changelog was updated

@xiangyan99 xiangyan99 requested a review from msyyc March 25, 2025 15:41
@xiangyan99 xiangyan99 merged commit 093efca into main Mar 26, 2025
55 checks passed
@xiangyan99 xiangyan99 deleted the core_auth_flows branch March 26, 2025 16:55
github-merge-queue bot pushed a commit to microsoft/typespec that referenced this pull request Mar 31, 2025
fix #6448
pending on new release of corehttp:
Azure/azure-sdk-for-python#40084

SDK API diff is here: Azure/autorest.python#3062

---------

Co-authored-by: iscai-msft <isabellavcai@gmail.com>
mario-guerra pushed a commit to microsoft/typespec that referenced this pull request Apr 2, 2025
fix #6448
pending on new release of corehttp:
Azure/azure-sdk-for-python#40084

SDK API diff is here: Azure/autorest.python#3062

---------

Co-authored-by: iscai-msft <isabellavcai@gmail.com>
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.

4 participants