Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ccd64b9
Add tests
mccoyp Sep 12, 2024
34fcfed
Implement CAE support
mccoyp Sep 12, 2024
d07e0a5
Share implementation across libraries
mccoyp Sep 13, 2024
84351af
Enable CAE; provide claims only in challenges
mccoyp Sep 18, 2024
c22cb08
Update tests for success scenarios
mccoyp Sep 19, 2024
d854071
Handle non-consecutive challenges (in Keys)
mccoyp Sep 19, 2024
6c19bbc
Cover invalid challenge flows
mccoyp Sep 20, 2024
c919056
Handle (in)valid challenge flows
mccoyp Sep 20, 2024
ff731e8
Share updates across libraries
mccoyp Sep 20, 2024
237c57b
Fix spelling, pylint
mccoyp Sep 20, 2024
013673b
Update changelogs
mccoyp Sep 26, 2024
5da13ff
Update tests for feedback
mccoyp Sep 26, 2024
36cb9fd
Use super() instead of private attribute
mccoyp Sep 26, 2024
f9ff176
Add live test; assert scope
mccoyp Sep 26, 2024
bf8f054
Fix auth policy to send scope correctly
mccoyp Sep 26, 2024
850e6e8
Async tests; sync challenge policy code
mccoyp Sep 26, 2024
e78d4e9
Ensure no re-sending claims in tests
mccoyp Oct 3, 2024
1a6c9f7
Fix policy to handle KV -> KV challenge
mccoyp Oct 3, 2024
3fad4db
Share bug fix across libraries
mccoyp Oct 3, 2024
ba2a954
Clarify test variable names
mccoyp Oct 4, 2024
92c6704
Correctly handle token refreshes
mccoyp Oct 5, 2024
8e65726
Bump Core dep for SupportsTokenInfo protocol support
mccoyp Oct 8, 2024
93c7eaa
(Async)SupportsTokenInfo support/tests
mccoyp Oct 8, 2024
bf25378
Pylint
mccoyp Oct 8, 2024
3cb6481
Mention Core bump, enable_cae kwarg in changelogs
mccoyp Oct 16, 2024
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
Prev Previous commit
Next Next commit
Fix spelling, pylint
  • Loading branch information
mccoyp committed Oct 7, 2024
commit 237c57b1d626049c3880705785e3828a156671fa
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
from copy import deepcopy
import time
from typing import Any, Awaitable, Callable, Optional, overload, TypeVar, Union
from typing_extensions import ParamSpec
from urllib.parse import urlparse

from typing_extensions import ParamSpec

from azure.core.credentials import AccessToken
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.pipeline import PipelineRequest, PipelineResponse
Expand Down Expand Up @@ -199,7 +200,7 @@ async def on_challenge(self, request: PipelineRequest, response: PipelineRespons
# Use the old scope for CAE challenges. The parsing will succeed here since it did before
if challenge.claims and old_scope:
resource_domain = urlparse(old_scope).netloc
challenge._parameters["scope"] = old_scope
challenge._parameters["scope"] = old_scope # pylint:disable=protected-access
challenge.tenant_id = old_tenant
else:
raise ValueError(f"The challenge contains invalid scope '{scope}'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def on_challenge(self, request: PipelineRequest, response: PipelineResponse) ->
# Use the old scope for CAE challenges. The parsing will succeed here since it did before
if challenge.claims and old_scope:
resource_domain = urlparse(old_scope).netloc
challenge._parameters["scope"] = old_scope
challenge._parameters["scope"] = old_scope # pylint:disable=protected-access
challenge.tenant_id = old_tenant
else:
raise ValueError(f"The challenge contains invalid scope '{scope}'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
from copy import deepcopy
import time
from typing import Any, Awaitable, Callable, Optional, overload, TypeVar, Union
from typing_extensions import ParamSpec
from urllib.parse import urlparse

from typing_extensions import ParamSpec

from azure.core.credentials import AccessToken
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.pipeline import PipelineRequest, PipelineResponse
Expand Down Expand Up @@ -199,7 +200,7 @@ async def on_challenge(self, request: PipelineRequest, response: PipelineRespons
# Use the old scope for CAE challenges. The parsing will succeed here since it did before
if challenge.claims and old_scope:
resource_domain = urlparse(old_scope).netloc
challenge._parameters["scope"] = old_scope
challenge._parameters["scope"] = old_scope # pylint:disable=protected-access
challenge.tenant_id = old_tenant
else:
raise ValueError(f"The challenge contains invalid scope '{scope}'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def on_challenge(self, request: PipelineRequest, response: PipelineResponse) ->
# Use the old scope for CAE challenges. The parsing will succeed here since it did before
if challenge.claims and old_scope:
resource_domain = urlparse(old_scope).netloc
challenge._parameters["scope"] = old_scope
challenge._parameters["scope"] = old_scope # pylint:disable=protected-access
challenge.tenant_id = old_tenant
else:
raise ValueError(f"The challenge contains invalid scope '{scope}'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
from copy import deepcopy
import time
from typing import Any, Awaitable, Callable, Optional, overload, TypeVar, Union
from typing_extensions import ParamSpec
from urllib.parse import urlparse

from typing_extensions import ParamSpec

from azure.core.credentials import AccessToken
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.pipeline import PipelineRequest, PipelineResponse
Expand Down Expand Up @@ -199,7 +200,7 @@ async def on_challenge(self, request: PipelineRequest, response: PipelineRespons
# Use the old scope for CAE challenges. The parsing will succeed here since it did before
if challenge.claims and old_scope:
resource_domain = urlparse(old_scope).netloc
challenge._parameters["scope"] = old_scope
challenge._parameters["scope"] = old_scope # pylint:disable=protected-access
challenge.tenant_id = old_tenant
else:
raise ValueError(f"The challenge contains invalid scope '{scope}'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def on_challenge(self, request: PipelineRequest, response: PipelineResponse) ->
# Use the old scope for CAE challenges. The parsing will succeed here since it did before
if challenge.claims and old_scope:
resource_domain = urlparse(old_scope).netloc
challenge._parameters["scope"] = old_scope
challenge._parameters["scope"] = old_scope # pylint:disable=protected-access
challenge.tenant_id = old_tenant
else:
raise ValueError(f"The challenge contains invalid scope '{scope}'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def get_token(*_, **kwargs):
claim = '{"access_token": {"foo": "bar"}}'
# Claim token is a string of the base64 encoding of the claim
claim_token = base64.b64encode(claim.encode()).decode()
# Note that no resource or scope is necessarily proovided in a CAE challenge
# Note that no resource or scope is necessarily provided in a CAE challenge
challenge = f'Bearer realm="", {url}, {cid}, {err}, claims="{claim_token}"'

claims_challenge = Mock(status_code=401, headers={"WWW-Authenticate": challenge})
Expand Down Expand Up @@ -693,7 +693,7 @@ def get_token(*_, **kwargs):
claim = '{"access_token": {"foo": "bar"}}'
# Claim token is a string of the base64 encoding of the claim
claim_token = base64.b64encode(claim.encode()).decode()
# Note that no resource or scope is necessarily proovided in a CAE challenge
# Note that no resource or scope is necessarily provided in a CAE challenge
challenge = f'Bearer realm="", {url}, {cid}, {err}, claims="{claim_token}"'

claims_challenge = Mock(status_code=401, headers={"WWW-Authenticate": challenge})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ async def get_token(*_, **kwargs):
claim = '{"access_token": {"foo": "bar"}}'
# Claim token is a string of the base64 encoding of the claim
claim_token = base64.b64encode(claim.encode()).decode()
# Note that no resource or scope is necessarily proovided in a CAE challenge
# Note that no resource or scope is necessarily provided in a CAE challenge
challenge = f'Bearer realm="", {url}, {cid}, {err}, claims="{claim_token}"'

# get_token is called for the first KV challenge and CAE challenge, but not the second KV challenge
Expand Down Expand Up @@ -660,7 +660,7 @@ async def get_token(*_, **kwargs):
claim = '{"access_token": {"foo": "bar"}}'
# Claim token is a string of the base64 encoding of the claim
claim_token = base64.b64encode(claim.encode()).decode()
# Note that no resource or scope is necessarily proovided in a CAE challenge
# Note that no resource or scope is necessarily provided in a CAE challenge
challenge = f'Bearer realm="", {url}, {cid}, {err}, claims="{claim_token}"'

claims_challenge = Mock(status_code=401, headers={"WWW-Authenticate": challenge})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
from copy import deepcopy
import time
from typing import Any, Awaitable, Callable, Optional, overload, TypeVar, Union
from typing_extensions import ParamSpec
from urllib.parse import urlparse

from typing_extensions import ParamSpec

from azure.core.credentials import AccessToken
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.pipeline import PipelineRequest, PipelineResponse
Expand Down Expand Up @@ -199,7 +200,7 @@ async def on_challenge(self, request: PipelineRequest, response: PipelineRespons
# Use the old scope for CAE challenges. The parsing will succeed here since it did before
if challenge.claims and old_scope:
resource_domain = urlparse(old_scope).netloc
challenge._parameters["scope"] = old_scope
challenge._parameters["scope"] = old_scope # pylint:disable=protected-access
challenge.tenant_id = old_tenant
else:
raise ValueError(f"The challenge contains invalid scope '{scope}'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def on_challenge(self, request: PipelineRequest, response: PipelineResponse) ->
# Use the old scope for CAE challenges. The parsing will succeed here since it did before
if challenge.claims and old_scope:
resource_domain = urlparse(old_scope).netloc
challenge._parameters["scope"] = old_scope
challenge._parameters["scope"] = old_scope # pylint:disable=protected-access
challenge.tenant_id = old_tenant
else:
raise ValueError(f"The challenge contains invalid scope '{scope}'.")
Expand Down