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

Managed Identity for Azure VM, App Service, Service Fabric, etc. #480

Merged
merged 6 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,23 @@ You may want to catch them to provide a better error message to your end users.

.. autoclass:: msal.IdTokenError


Managed Identity
================
MSAL supports
`Managed Identity <https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview>`_.

You can create one of these two kinds of managed identity configuration objects:

.. autoclass:: msal.SystemAssignedManagedIdentity
:members:

.. autoclass:: msal.UserAssignedManagedIdentity
:members:

And then feed the configuration object into a :class:`ManagedIdentityClient` object.

.. autoclass:: msal.ManagedIdentityClient
:members:

.. automethod:: __init__
7 changes: 7 additions & 0 deletions msal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@
from .oauth2cli.oidc import Prompt, IdTokenError
from .token_cache import TokenCache, SerializableTokenCache
from .auth_scheme import PopAuthScheme
from .managed_identity import (
SystemAssignedManagedIdentity, UserAssignedManagedIdentity,
ManagedIdentityClient,
ManagedIdentityError,
ArcPlatformNotSupportedError,
)

# Putting module-level exceptions into the package namespace, to make them
# 1. officially part of the MSAL public API, and
# 2. can still be caught by the user code even if we change the module structure.
from .oauth2cli.oauth2 import BrowserInteractionTimeoutError

6 changes: 5 additions & 1 deletion msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@ def __init__(
self.http_client.mount("https://", a)
self.http_client = ThrottledHttpClient(
self.http_client,
{} if http_cache is None else http_cache, # Default to an in-memory dict
http_cache=http_cache,
default_throttle_time=60
# The default value 60 was recommended mainly for PCA at the end of
# https://identitydivision.visualstudio.com/devex/_git/AuthLibrariesApiReview?version=GBdev&path=%2FService%20protection%2FIntial%20set%20of%20protection%20measures.md&_a=preview
if isinstance(self, PublicClientApplication) else 5,
)

self.app_name = app_name
Expand Down
Loading