Skip to content

Commit 74695f3

Browse files
linting issues fixed
1 parent a0c4efb commit 74695f3

File tree

10 files changed

+429
-391
lines changed

10 files changed

+429
-391
lines changed

ClientAdvisor/App/.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E501, E203
4+
exclude = .venv, frontend,

ClientAdvisor/App/app.py

Lines changed: 180 additions & 174 deletions
Large diffs are not rendered by default.

ClientAdvisor/App/backend/auth/auth_utils.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,41 @@
22
import json
33
import logging
44

5+
56
def get_authenticated_user_details(request_headers):
67
user_object = {}
78

8-
## check the headers for the Principal-Id (the guid of the signed in user)
9+
# check the headers for the Principal-Id (the guid of the signed in user)
910
if "X-Ms-Client-Principal-Id" not in request_headers.keys():
10-
## if it's not, assume we're in development mode and return a default user
11+
# if it's not, assume we're in development mode and return a default user
1112
from . import sample_user
13+
1214
raw_user_object = sample_user.sample_user
1315
else:
14-
## if it is, get the user details from the EasyAuth headers
15-
raw_user_object = {k:v for k,v in request_headers.items()}
16+
# if it is, get the user details from the EasyAuth headers
17+
raw_user_object = {k: v for k, v in request_headers.items()}
1618

17-
user_object['user_principal_id'] = raw_user_object.get('X-Ms-Client-Principal-Id')
18-
user_object['user_name'] = raw_user_object.get('X-Ms-Client-Principal-Name')
19-
user_object['auth_provider'] = raw_user_object.get('X-Ms-Client-Principal-Idp')
20-
user_object['auth_token'] = raw_user_object.get('X-Ms-Token-Aad-Id-Token')
21-
user_object['client_principal_b64'] = raw_user_object.get('X-Ms-Client-Principal')
22-
user_object['aad_id_token'] = raw_user_object.get('X-Ms-Token-Aad-Id-Token')
19+
user_object["user_principal_id"] = raw_user_object.get("X-Ms-Client-Principal-Id")
20+
user_object["user_name"] = raw_user_object.get("X-Ms-Client-Principal-Name")
21+
user_object["auth_provider"] = raw_user_object.get("X-Ms-Client-Principal-Idp")
22+
user_object["auth_token"] = raw_user_object.get("X-Ms-Token-Aad-Id-Token")
23+
user_object["client_principal_b64"] = raw_user_object.get("X-Ms-Client-Principal")
24+
user_object["aad_id_token"] = raw_user_object.get("X-Ms-Token-Aad-Id-Token")
2325

2426
return user_object
2527

28+
2629
def get_tenantid(client_principal_b64):
27-
tenant_id = ''
28-
if client_principal_b64:
30+
tenant_id = ""
31+
if client_principal_b64:
2932
try:
3033
# Decode the base64 header to get the JSON string
3134
decoded_bytes = base64.b64decode(client_principal_b64)
32-
decoded_string = decoded_bytes.decode('utf-8')
35+
decoded_string = decoded_bytes.decode("utf-8")
3336
# Convert the JSON string1into a Python dictionary
3437
user_info = json.loads(decoded_string)
3538
# Extract the tenant ID
36-
tenant_id = user_info.get('tid') # 'tid' typically holds the tenant ID
39+
tenant_id = user_info.get("tid") # 'tid' typically holds the tenant ID
3740
except Exception as ex:
3841
logging.exception(ex)
39-
return tenant_id
42+
return tenant_id
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
sample_user = {
2-
"Accept": "*/*",
3-
"Accept-Encoding": "gzip, deflate, br",
4-
"Accept-Language": "en",
5-
"Client-Ip": "22.222.222.2222:64379",
6-
"Content-Length": "192",
7-
"Content-Type": "application/json",
8-
"Cookie": "AppServiceAuthSession=/AuR5ENU+pmpoN3jnymP8fzpmVBgphx9uPQrYLEWGcxjIITIeh8NZW7r3ePkG8yBcMaItlh1pX4nzg5TFD9o2mxC/5BNDRe/uuu0iDlLEdKecROZcVRY7QsFdHLjn9KB90Z3d9ZeLwfVIf0sZowWJt03BO5zKGB7vZgL+ofv3QY3AaYn1k1GtxSE9HQWJpWar7mOA64b7Lsy62eY3nxwg3AWDsP3/rAta+MnDCzpdlZMFXcJLj+rsCppW+w9OqGhKQ7uCs03BPeon3qZOdmE8cOJW3+i96iYlhneNQDItHyQqEi1CHbBTSkqwpeOwWP4vcwGM22ynxPp7YFyiRw/X361DGYy+YkgYBkXq1AEIDZ44BCBz9EEaEi0NU+m6yUOpNjEaUtrJKhQywcM2odojdT4XAY+HfTEfSqp0WiAkgAuE/ueCu2JDOfvxGjCgJ4DGWCoYdOdXAN1c+MenT4OSvkMO41YuPeah9qk9ixkJI5s80lv8rUu1J26QF6pstdDkYkAJAEra3RQiiO1eAH7UEb3xHXn0HW5lX8ZDX3LWiAFGOt5DIKxBKFymBKJGzbPFPYjfczegu0FD8/NQPLl2exAX3mI9oy/tFnATSyLO2E8DxwP5wnYVminZOQMjB/I4g3Go14betm0MlNXlUbU1fyS6Q6JxoCNLDZywCoU9Y65UzimWZbseKsXlOwYukCEpuQ5QPT55LuEAWhtYier8LSh+fvVUsrkqKS+bg0hzuoX53X6aqUr7YB31t0Z2zt5TT/V3qXpdyD8Xyd884PqysSkJYa553sYx93ETDKSsfDguanVfn2si9nvDpvUWf6/R02FmQgXiaaaykMgYyIuEmE77ptsivjH3hj/MN4VlePFWokcchF4ciqqzonmICmjEHEx5zpjU2Kwa+0y7J5ROzVVygcnO1jH6ZKDy9bGGYL547bXx/iiYBYqSIQzleOAkCeULrGN2KEHwckX5MpuRaqTpoxdZH9RJv0mIWxbDA0kwGsbMICQd0ZODBkPUnE84qhzvXInC+TL7MbutPEnGbzgxBAS1c2Ct4vxkkjykOeOxTPxqAhxoefwUfIwZZax6A9LbeYX2bsBpay0lScHcA==",
9-
"Disguised-Host": "your_app_service.azurewebsites.net",
10-
"Host": "your_app_service.azurewebsites.net",
11-
"Max-Forwards": "10",
12-
"Origin": "https://your_app_service.azurewebsites.net",
13-
"Referer": "https://your_app_service.azurewebsites.net/",
14-
"Sec-Ch-Ua": "\"Microsoft Edge\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"",
15-
"Sec-Ch-Ua-Mobile": "?0",
16-
"Sec-Ch-Ua-Platform": "\"Windows\"",
17-
"Sec-Fetch-Dest": "empty",
18-
"Sec-Fetch-Mode": "cors",
19-
"Sec-Fetch-Site": "same-origin",
20-
"Traceparent": "00-24e9a8d1b06f233a3f1714845ef971a9-3fac69f81ca5175c-00",
21-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42",
22-
"Was-Default-Hostname": "your_app_service.azurewebsites.net",
23-
"X-Appservice-Proto": "https",
24-
"X-Arr-Log-Id": "4102b832-6c88-4c7c-8996-0edad9e4358f",
25-
"X-Arr-Ssl": "2048|256|CN=Microsoft Azure TLS Issuing CA 02, O=Microsoft Corporation, C=US|CN=*.azurewebsites.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US",
26-
"X-Client-Ip": "22.222.222.222",
27-
"X-Client-Port": "64379",
28-
"X-Forwarded-For": "22.222.222.22:64379",
29-
"X-Forwarded-Proto": "https",
30-
"X-Forwarded-Tlsversion": "1.2",
31-
"X-Ms-Client-Principal": "your_base_64_encoded_token",
32-
"X-Ms-Client-Principal-Id": "00000000-0000-0000-0000-000000000000",
33-
"X-Ms-Client-Principal-Idp": "aad",
34-
"X-Ms-Client-Principal-Name": "[email protected]",
35-
"X-Ms-Token-Aad-Id-Token": "your_aad_id_token",
36-
"X-Original-Url": "/chatgpt",
37-
"X-Site-Deployment-Id": "your_app_service",
38-
"X-Waws-Unencoded-Url": "/chatgpt"
2+
"Accept": "*/*",
3+
"Accept-Encoding": "gzip, deflate, br",
4+
"Accept-Language": "en",
5+
"Client-Ip": "22.222.222.2222:64379",
6+
"Content-Length": "192",
7+
"Content-Type": "application/json",
8+
"Cookie": "AppServiceAuthSession=/AuR5ENU+pmpoN3jnymP8fzpmVBgphx9uPQrYLEWGcxjIITIeh8NZW7r3ePkG8yBcMaItlh1pX4nzg5TFD9o2mxC/5BNDRe/uuu0iDlLEdKecROZcVRY7QsFdHLjn9KB90Z3d9ZeLwfVIf0sZowWJt03BO5zKGB7vZgL+ofv3QY3AaYn1k1GtxSE9HQWJpWar7mOA64b7Lsy62eY3nxwg3AWDsP3/rAta+MnDCzpdlZMFXcJLj+rsCppW+w9OqGhKQ7uCs03BPeon3qZOdmE8cOJW3+i96iYlhneNQDItHyQqEi1CHbBTSkqwpeOwWP4vcwGM22ynxPp7YFyiRw/X361DGYy+YkgYBkXq1AEIDZ44BCBz9EEaEi0NU+m6yUOpNjEaUtrJKhQywcM2odojdT4XAY+HfTEfSqp0WiAkgAuE/ueCu2JDOfvxGjCgJ4DGWCoYdOdXAN1c+MenT4OSvkMO41YuPeah9qk9ixkJI5s80lv8rUu1J26QF6pstdDkYkAJAEra3RQiiO1eAH7UEb3xHXn0HW5lX8ZDX3LWiAFGOt5DIKxBKFymBKJGzbPFPYjfczegu0FD8/NQPLl2exAX3mI9oy/tFnATSyLO2E8DxwP5wnYVminZOQMjB/I4g3Go14betm0MlNXlUbU1fyS6Q6JxoCNLDZywCoU9Y65UzimWZbseKsXlOwYukCEpuQ5QPT55LuEAWhtYier8LSh+fvVUsrkqKS+bg0hzuoX53X6aqUr7YB31t0Z2zt5TT/V3qXpdyD8Xyd884PqysSkJYa553sYx93ETDKSsfDguanVfn2si9nvDpvUWf6/R02FmQgXiaaaykMgYyIuEmE77ptsivjH3hj/MN4VlePFWokcchF4ciqqzonmICmjEHEx5zpjU2Kwa+0y7J5ROzVVygcnO1jH6ZKDy9bGGYL547bXx/iiYBYqSIQzleOAkCeULrGN2KEHwckX5MpuRaqTpoxdZH9RJv0mIWxbDA0kwGsbMICQd0ZODBkPUnE84qhzvXInC+TL7MbutPEnGbzgxBAS1c2Ct4vxkkjykOeOxTPxqAhxoefwUfIwZZax6A9LbeYX2bsBpay0lScHcA==",
9+
"Disguised-Host": "your_app_service.azurewebsites.net",
10+
"Host": "your_app_service.azurewebsites.net",
11+
"Max-Forwards": "10",
12+
"Origin": "https://your_app_service.azurewebsites.net",
13+
"Referer": "https://your_app_service.azurewebsites.net/",
14+
"Sec-Ch-Ua": '"Microsoft Edge";v="113", "Chromium";v="113", "Not-A.Brand";v="24"',
15+
"Sec-Ch-Ua-Mobile": "?0",
16+
"Sec-Ch-Ua-Platform": '"Windows"',
17+
"Sec-Fetch-Dest": "empty",
18+
"Sec-Fetch-Mode": "cors",
19+
"Sec-Fetch-Site": "same-origin",
20+
"Traceparent": "00-24e9a8d1b06f233a3f1714845ef971a9-3fac69f81ca5175c-00",
21+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42",
22+
"Was-Default-Hostname": "your_app_service.azurewebsites.net",
23+
"X-Appservice-Proto": "https",
24+
"X-Arr-Log-Id": "4102b832-6c88-4c7c-8996-0edad9e4358f",
25+
"X-Arr-Ssl": "2048|256|CN=Microsoft Azure TLS Issuing CA 02, O=Microsoft Corporation, C=US|CN=*.azurewebsites.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US",
26+
"X-Client-Ip": "22.222.222.222",
27+
"X-Client-Port": "64379",
28+
"X-Forwarded-For": "22.222.222.22:64379",
29+
"X-Forwarded-Proto": "https",
30+
"X-Forwarded-Tlsversion": "1.2",
31+
"X-Ms-Client-Principal": "your_base_64_encoded_token",
32+
"X-Ms-Client-Principal-Id": "00000000-0000-0000-0000-000000000000",
33+
"X-Ms-Client-Principal-Idp": "aad",
34+
"X-Ms-Client-Principal-Name": "[email protected]",
35+
"X-Ms-Token-Aad-Id-Token": "your_aad_id_token",
36+
"X-Original-Url": "/chatgpt",
37+
"X-Site-Deployment-Id": "your_app_service",
38+
"X-Waws-Unencoded-Url": "/chatgpt",
3939
}

0 commit comments

Comments
 (0)