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

ClientAssertionCredential constructor fails if kwargs are provided #33673

Closed
ppaglilla opened this issue Dec 28, 2023 · 2 comments
Closed

ClientAssertionCredential constructor fails if kwargs are provided #33673

ppaglilla opened this issue Dec 28, 2023 · 2 comments
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@ppaglilla
Copy link

  • Package Name: azure-identity
  • Package Version: 1.15.0
  • Operating System: Linux 6.1.58+ x86_64 GNU/Linux
  • Python Version: 3.11.5 and 3.9.2

Describe the bug
The ClientAssertionCredential constructor accepts the authority and additionally_allowed_tenants arguments through kwargs. However, if any of those arguments are provided, they are incorrectly bubbled up through a super().init(**kwargs) call to GetTokenMixin and abc.ABC. That ultimately makes construction fail with:

super(GetTokenMixin, self).__init__(*args, **kwargs)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object.__init__() takes exactly one argument (the instance to initialize)

To Reproduce

from typing import Callable
from azure.identity import ClientAssertionCredential

tenant_id: str= "TENANT_ID"
client_id: str= "CLIENT_ID"
func: Callable[[], str] = lambda: "TOKEN"

credential: ClientAssertionCredential = ClientAssertionCredential(
    tenant_id=tenant_id,
    client_id=client_id,
    func=func,
    additionally_allowed_tenants=[])

Expected behavior
The ClientAssertionCredential object is built successfully.

Additional context
I'm currently working around this by forcefully inspecting the credential object and injecting the settings as needed.

credential: ClientAssertionCredential = ClientAssertionCredential(
    tenant_id=tenant_id,
    client_id=client_id,
    func=func)

credential._client._additionally_allowed_tenants = []
@github-actions github-actions bot added Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-triage Workflow: This issue needs the team to triage. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 28, 2023
@xiangyan99 xiangyan99 removed the needs-team-triage Workflow: This issue needs the team to triage. label Jan 2, 2024
@xiangyan99 xiangyan99 self-assigned this Jan 2, 2024
@xiangyan99
Copy link
Member

Thanks for the feedback, we’ll investigate asap.

@xiangyan99
Copy link
Member

The fix is merged. It will be available in next release.

@github-project-automation github-project-automation bot moved this from Untriaged to Done in Azure Identity SDK Improvements Jan 4, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Development

No branches or pull requests

2 participants