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

ConfidentialClientApplication federated by a Managed Identity #687

Draft
wants to merge 838 commits into
base: dev
Choose a base branch
from

Conversation

rayluo
Copy link
Collaborator

@rayluo rayluo commented Apr 10, 2024

This is a proof-of-concept. It provides a high-level API which allows your confidential client to federate with a managed identity.

import msal
cca = msal.ConfidentialClientApplication(
    "my_client_id",
    client_credential=msal.SystemAssignedManagedIdentity(),  # Or it can be an msal.UserAssignedManagedIdentity(client_id="guid")
    ...)
result = cca.acquire_token_for_client(scopes["scope1", "scope2"])  # It uses scopes

The high-level API also supports some variations. See the last purple box of the client_credential parameter's document for more details.

See how it is simpler than the low-level API in the coming-soon Managed Identity implementation.

Installation: pip install --force-reinstall "git+https://github.com/AzureAD/microsoft-authentication-library-for-python.git@fic-by-mi"

rayluo and others added 30 commits May 3, 2022 07:40
* implement response_mode

oidc supports passing the response_mode to allow redirects to send callback parameters as POST for increased security.

* Fix error check logic and modify test_ccs to include response_mode

* Add more comments

* Apply suggestions from code review

Co-authored-by: Ray Luo <[email protected]>

* PR review comments addressed

* remove extraneous line

Co-authored-by: Emmanuel Oche <[email protected]>
Co-authored-by: Ray Luo <[email protected]>
Emit warning when common or organizations is used in acquire_token_for_client()
Cloud Shell Detection

PoC: Silent flow utilizes Cloud Shell IMDS

Introduce get_accounts(username=msal.CURRENT_USER)

A reasonable-effort to convert scope to resource

Replace get_accounts(username=msal.CURRENT_USER) by acquire_token_interactive(..., prompt="none")

Detect unsupported Portal so that AzCLI could fallback
Bump cryptography
I stumbled upon this typo while investigating a different issue in this file.
acquire_token_interactive(..., prompt="none") acquires token via Cloud Shell's IMDS-like interface
Merge MSAL Python 1.18.0b1 back to dev
Merge MSAL Python 1.18.0 back to dev
Document our findings on addressing CVE-2022-29217
…nt (#484)

* Use provided authority port when building the tenant discovery endpoint

* address PR comment

* Polish the implementation

Co-authored-by: Ray Luo <[email protected]>
We got it right in PR 358 based on the specs at that time, but we were using a fragile approach, which caused the "login.microsoft.com" to be left out in subsequent PR 394.

Lesson learned. Explicit is better than implicit. https://peps.python.org/pep-0020/
Right regional endpoint for login.microsoft.com
Troubleshooting
rayluo and others added 27 commits May 24, 2024 12:30
Change all find() in application.py to search()

Update msal/token_cache.py

Co-authored-by: Jiashuo Li <[email protected]>

Refine inline comments
Enable public client ROPC via broker
Fix docs

Adjusting error message and docs

Fix typo
Error out on platforms other than Linux and Windows
* Update ROPC broker tests

* Get test account and password from .env

* update
sample/confidential_client_sample.py Dismissed Show dismissed Hide dismissed
sample/confidential_client_sample.py Dismissed Show dismissed Hide dismissed
sample/confidential_client_sample.py Dismissed Show dismissed Hide dismissed
sample/device_flow_sample.py Dismissed Show dismissed Hide dismissed
sample/device_flow_sample.py Dismissed Show dismissed Hide dismissed
sample/interactive_sample.py Dismissed Show dismissed Hide dismissed
sample/interactive_sample.py Dismissed Show dismissed Hide dismissed
sample/username_password_sample.py Dismissed Show dismissed Hide dismissed
sample/username_password_sample.py Dismissed Show dismissed Hide dismissed
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.