Skip to content

Commit 589de01

Browse files
pvaneckvivekmore-msft
authored andcommitted
[Core] Add CAE flag to auth policies (#31012)
This first adds a keyword argument to the TokenCredential protocol method `get_token`. This enables users and client SDKs to pass in a flag to denote that `get_token` requests should be requesting CAE tokens. If the underlying credential's `get_token` implementation supports this flag, then a CAE token will be requested. Otherwise, a non-CAE token will be requested. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> (cherry picked from commit a7519f9)
1 parent 5df6c69 commit 589de01

File tree

34 files changed

+402
-82
lines changed

34 files changed

+402
-82
lines changed
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# coding=utf-8
2-
# --------------------------------------------------------------------------
1+
# -------------------------------------------------------------------------
32
# Copyright (c) Microsoft Corporation. All rights reserved.
43
# Licensed under the MIT License. See License.txt in the project root for
54
# license information.
65
# --------------------------------------------------------------------------
7-
from .v2019_01_01_preview.models import *
8-
from .v2020_05_01_preview.models import *
6+
from azure.core.credentials import AccessToken
7+
8+
9+
class FakeTokenCredential(object):
10+
def __init__(self):
11+
self.token = AccessToken("Fake Token", 0)
12+
13+
def get_token(self, *args, **kwargs):
14+
return self.token

sdk/communication/azure-communication-callautomation/tests/_shared/async_fake_token_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ class AsyncFakeTokenCredential(object):
1010
def __init__(self):
1111
self.token = AccessToken("Fake Token", 0)
1212

13-
async def get_token(self, *args):
13+
async def get_token(self, *args, **kwargs):
1414
return self.token

sdk/communication/azure-communication-callautomation/tests/_shared/fake_token_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ class FakeTokenCredential(object):
1010
def __init__(self):
1111
self.token = AccessToken("Fake Token", 0)
1212

13-
def get_token(self, *args):
13+
def get_token(self, *args, **kwargs):
1414
return self.token

sdk/communication/azure-communication-chat/tests/_shared/async_fake_token_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ class AsyncFakeTokenCredential(object):
1010
def __init__(self):
1111
self.token = AccessToken("Fake Token", 0)
1212

13-
async def get_token(self, *args):
13+
async def get_token(self, *args, **kwargs):
1414
return self.token

sdk/communication/azure-communication-chat/tests/_shared/fake_token_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ class FakeTokenCredential(object):
1010
def __init__(self):
1111
self.token = AccessToken("Fake Token", 0)
1212

13-
def get_token(self, *args):
13+
def get_token(self, *args, **kwargs):
1414
return self.token

sdk/communication/azure-communication-email/tests/_shared/async_fake_token_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ class AsyncFakeTokenCredential(object):
1010
def __init__(self):
1111
self.token = AccessToken("Fake Token", 0)
1212

13-
async def get_token(self, *args):
13+
async def get_token(self, *args, **kwargs):
1414
return self.token

sdk/communication/azure-communication-email/tests/_shared/fake_token_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ class FakeTokenCredential(object):
1010
def __init__(self):
1111
self.token = AccessToken("Fake Token", 0)
1212

13-
def get_token(self, *args):
13+
def get_token(self, *args, **kwargs):
1414
return self.token

sdk/communication/azure-communication-identity/tests/_shared/async_fake_token_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ class AsyncFakeTokenCredential(object):
1010
def __init__(self):
1111
self.token = AccessToken("Fake Token", 0)
1212

13-
async def get_token(self, *args):
13+
async def get_token(self, *args, **kwargs):
1414
return self.token

sdk/communication/azure-communication-identity/tests/_shared/fake_token_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ class FakeTokenCredential(object):
1010
def __init__(self):
1111
self.token = AccessToken("Fake Token", 0)
1212

13-
def get_token(self, *args):
13+
def get_token(self, *args, **kwargs):
1414
return self.token
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
6+
from azure.core.credentials import AccessToken
7+
8+
9+
class AsyncFakeTokenCredential(object):
10+
def __init__(self):
11+
self.token = AccessToken("Fake Token", 0)
12+
13+
async def get_token(self, *args, **kwargs):
14+
return self.token

0 commit comments

Comments
 (0)