Skip to content
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
4 changes: 2 additions & 2 deletions infrastructure/simple-apim/create.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"\n",
"# 1) Define the Bicep parameters with serialized APIs\n",
"bicep_parameters = {\n",
" 'apimSku': {'value': apim_sku.value},\n",
" 'apis': {'value': [api.to_dict() for api in apis]}\n",
" 'apimSku' : {'value': apim_sku.value},\n",
" 'apis' : {'value': [api.to_dict() for api in apis]}\n",
"}\n",
"\n",
"# 2) Run the deployment\n",
Expand Down
21 changes: 16 additions & 5 deletions samples/authX/create.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"⚙️ **Supported infrastructures**: All infrastructures\n",
"\n",
"⌚ **Expected *Run All* runtime (excl. infrastructure prerequisite): ~[NOTEBOOK RUNTIME] minute**\n",
"⌚ **Expected *Run All* runtime (excl. infrastructure prerequisite): ~2-3 minutes**\n",
"\n",
"## Objectives\n",
"\n",
Expand Down Expand Up @@ -190,14 +190,25 @@
"from apimjwt import JwtPayload, SymmetricJwtToken\n",
"from apimtypes import HR_MEMBER_ROLE_ID, HR_ADMINISTRATOR_ROLE_ID, HR_ASSOCIATE_ROLE_ID\n",
"\n",
"# Preflight: Check if the infrastructure architecture deployment uses Azure Front Door. If so, assume that APIM is not directly accessible and use the Front Door URL instead.\n",
"endpoint_url = apim_gateway_url\n",
"utils.print_message('Checking if the infrastructure architecture deployment uses Azure Front Door.', blank_above = True)\n",
"afd_endpoint_url = utils.get_frontdoor_url(deployment, rg_name)\n",
"\n",
"if afd_endpoint_url:\n",
" endpoint_url = afd_endpoint_url\n",
" utils.print_message(f'Using Azure Front Door URL: {afd_endpoint_url}', blank_above = True)\n",
"else:\n",
" utils.print_message(f'Using APIM Gateway URL: {apim_gateway_url}', blank_above = True)\n",
"\n",
"# 1) HR Administrator\n",
"# Create a JSON Web Token with a payload and sign it with the symmetric key from above.\n",
"jwt_payload_hr_admin = JwtPayload(subject = 'user123', name = 'Angie Administrator', roles = [HR_MEMBER_ROLE_ID, HR_ADMINISTRATOR_ROLE_ID])\n",
"encoded_jwt_token_hr_admin = SymmetricJwtToken(jwt_key_value, jwt_payload_hr_admin).encode()\n",
"print(f'JWT token HR Admin: {encoded_jwt_token_hr_admin}') # this value is used to call the APIs via APIM\n",
"print(f'\\nJWT token HR Admin: {encoded_jwt_token_hr_admin}') # this value is used to call the APIs via APIM\n",
"\n",
"# Set up an APIM requests object with the JWT token\n",
"reqsApimAdmin = ApimRequests(apim_gateway_url)\n",
"reqsApimAdmin = ApimRequests(endpoint_url)\n",
"reqsApimAdmin.headers['Authorization'] = f'Bearer {encoded_jwt_token_hr_admin}'\n",
"\n",
"# Call APIM\n",
Expand All @@ -208,10 +219,10 @@
"# Create a JSON Web Token with a payload and sign it with the symmetric key from above.\n",
"jwt_payload_hr_associate = JwtPayload(subject = 'user789', name = 'Aaron Associate', roles = [HR_MEMBER_ROLE_ID, HR_ASSOCIATE_ROLE_ID])\n",
"encoded_jwt_token_hr_associate = SymmetricJwtToken(jwt_key_value, jwt_payload_hr_associate).encode()\n",
"print(f'\\n\\nJWT token HR Associate: {encoded_jwt_token_hr_associate}') # this value is used to call the APIs via APIM\n",
"print(f'\\nJWT token HR Associate: {encoded_jwt_token_hr_associate}') # this value is used to call the APIs via APIM\n",
"\n",
"# Set up an APIM requests object with the JWT token\n",
"reqsApimAssociate = ApimRequests(apim_gateway_url)\n",
"reqsApimAssociate = ApimRequests(endpoint_url)\n",
"reqsApimAssociate.headers['Authorization'] = f'Bearer {encoded_jwt_token_hr_associate}'\n",
"\n",
"# Call APIM\n",
Expand Down